diff --git a/README.md b/README.md index d3dae6c..9a62191 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,6 @@ The repository is organized as follows (listing the main folders and files): - ~~`BackgroundLemmas.lean`: Supporting lemmas needed for the main theorem.~~ - `LiveLeanTriathlonSorry/Mathlib/`: Contains any lemmas that are needed but not present in mathlib. -## Statistics - -The file `scripts/theorem_stats.json` contains statistics on the theorems in the dataset, including: - -* Counts of theorems by AMS classification -* Data on which theorems have unsorried formal proofs, informal proofs, or background lemma statements. - ## Licensing Copyright 2025 Project Numina. All software is licensed under the Apache License, @@ -79,94 +72,6 @@ materials distributed here under the Apache 2.0 license are distributed on an implied. See the license for the specific language governing permissions and limitations under the license. -## Sorry Variants and Benchmark JSONLs - -The scripts under [`scripts/create_sorries/`](scripts/create_sorries) derive -benchmark artifacts from the main `LiveLeanTriathlon/` tree by rewriting proofs to -`sorry`. There are two kinds of output: directory variants (full Lake libraries -the agent can build against) and JSONL files (one row per problem, suitable for -batch evaluation). - -Both scripts are pure Python (require Python 3.10+) and read from the -canonical `LiveLeanTriathlon/` source. The directory variants -(`LiveLeanTriathlonSorry/`, `LiveLeanTriathlonSorryNoLemmas/`) are gitignored and -regenerated on demand. The three JSONL files under -[`scripts/create_sorries/`](scripts/create_sorries) *are* checked in — CI -re-runs the generator and fails if the working tree drifts, so any source -change that affects them must be regenerated and committed. - -### `create_sorries.py` — directory variants - -Generates two sibling directories at the project root: - -- **`LiveLeanTriathlonSorry/`** — a copy of `LiveLeanTriathlon/` with every - `theorem`/`lemma` proof replaced by `:= by sorry`. Imports of - `LiveLeanTriathlon.Mathlib.*` and `LiveLeanTriathlon.Util.*` continue to point at - the original library; other `LiveLeanTriathlon.*` imports are rewritten to the - sibling tree. A top-level `LiveLeanTriathlonSorry.lean` index is also produced. -- **`LiveLeanTriathlonSorryNoLemmas/`** — same layout, but only `@[AMS]`-tagged - main theorems keep `:= by sorry`. Helper lemmas are demoted to `axiom`s, so - each non-Mathlib folder exposes exactly one open goal. - -Both variants are registered as `lean_lib` targets in `lakefile.toml`. - -```bash -# Generate both variants (default). -python3 scripts/create_sorries/create_sorries.py - -# Generate only one. -python3 scripts/create_sorries/create_sorries.py --variant Sorry -python3 scripts/create_sorries/create_sorries.py --variant SorryNoLemmas - -# Build a variant. -lake build LiveLeanTriathlonSorry -lake build LiveLeanTriathlonSorryNoLemmas -``` - -### `create_statement_jsonl.py` — flat benchmark JSONLs - -Writes three JSONL files into `scripts/create_sorries/`. Each row is a single -problem; the agent's task is to prove (or formalize) the goal in the row's -`code` field. Project-specific imports are collapsed to `import Mathlib` and -the `module` directive plus `@[AMS ...]` / `@[blueprint ...]` decorators are -stripped, so each row stands alone. - -| File | Granularity | What `code` contains | -|---|---|---| -| `statement.jsonl` | one row per `theorem`/`lemma` | imports + opens + everything from the file's start through the target, with all preceding proofs replaced by `sorry` | -| `statements_hard.jsonl` | one row per `@[AMS]` theorem | imports + opens + earlier same-file `@[AMS]` theorems as `axiom`s + the target with `sorry` | -| `statements_autoformalization.jsonl` | one row per `@[AMS]` theorem | imports + opens + the target with `sorry` only — *plus* `title`, `informal_statement`, and `informal_proof` fields drawn from the matching `blueprint/src/theorems/*.tex` file | - -Base schema (all three files): - -```json -{"project_name": "...", "name": "...", "type": "theorem"|"lemma", "code": "..."} -``` - -`statement.jsonl` rows from a file that imports project-local siblings (e.g. -`MainTheorem.lean` importing `BackgroundLemmas.lean`) additionally carry an -`imported_file` field with the transitive sibling content (proofs replaced by -`sorry`, separated by `-- File: ` markers). Rows whose file has no -project-local imports omit the field. - -`statements_autoformalization.jsonl` adds `title`, `informal_statement`, and -`informal_proof`. The script locates the relevant blueprint chapter by -`\lean{}` lookup against `blueprint/src/theorems/*.tex`. `title` comes -from the `\begin{theorem}[…]` optional argument (falling back to the chapter -heading), `informal_statement` is the body of the matching theorem -environment with `\label`/`\lean`/`\uses` stripped, and `informal_proof` is -the *entire* tex file content — chapter-level context for the whole proof, -not just the prose for one declaration. - -```bash -python3 scripts/create_sorries/create_statement_jsonl.py -``` - -Both scripts are exercised in the `build_sorry_variants` CI job -([.github/workflows/build-project-and-blueprint.yml](.github/workflows/build-project-and-blueprint.yml)), -which generates the variant trees, builds them with Lake, generates the JSONL -files, and validates each row's schema. - ## Acknowledgements We would like to thank Kim Morrison and Kevin Buzzard for identifying formalization errors in this development. diff --git a/scripts/check_blueprints.json b/scripts/check_blueprints.json deleted file mode 100644 index ce6e719..0000000 --- a/scripts/check_blueprints.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "environments": { - "require_label": ["definition", "lemma", "theorem"], - "require_proof": ["lemma", "theorem"], - "require_lean": ["definition", "lemma", "theorem"], - "must_be_referenced": ["definition", "lemma"] - }, - "rules": { - "check_label_uniqueness": true, - "check_dependencies": true, - "check_circular_dependencies": true, - "check_transitive_usage": true, - "check_file_references": true, - "check_proof_bindings": true, - "check_lean_blocks": true, - "check_chapter_first": true, - "check_lean_ams_tags": true, - "check_theorem_env_present": true - }, - "paths": { - "blueprint_dir": "blueprint/src", - "theorems_dir": "blueprint/src/theorems", - "content_file": "blueprint/src/content.tex" - } -} diff --git a/scripts/check_blueprints.py b/scripts/check_blueprints.py deleted file mode 100644 index e1ddc23..0000000 --- a/scripts/check_blueprints.py +++ /dev/null @@ -1,1265 +0,0 @@ -#!/usr/bin/env -S uv run python -"""A comprehensive tool for validating LaTeX blueprint files to ensure proper structure and consistency. - -Usage: - uv run python check_blueprints.py [options] - - or make the script executable and run directly: - chmod +x check_blueprints.py - ./check_blueprints.py [options] - -Options: - -c, --config PATH Path to configuration file (default: check_blueprints.json) - -v, --verbose Show all information including warnings (default: True) - --conclusion Print detailed environment block information and conclusion (default: True) - -h, --help Show this help message and exit - -Examples: - # Run with default settings - python check_blueprints.py - - # Run with custom config file - python check_blueprints.py --config my_config.json - - # Run with minimal output (errors only) - python check_blueprints.py --no-verbose --no-conclusion - -Check items: -1. Label validation: Ensures lemma/def/theorem environments have unique labels within each file, warns about cross-file duplicates -2. Proof binding: Verifies proof environments are properly bound to their parent lemma/theorem blocks -3. Lean block validation: Ensures definition/lemma/theorem environments contain \\lean{{}} blocks -4. Dependency tracking: Validates that all \\uses{} references point to existing labels and identifies unused labels -5. Circular dependencies: Detects circular dependencies in \\uses{} references within each file -6. Transitive usage: Ensures all environments are used transitively by the final environment in each file -7. File inclusion: Confirms all theorem files in the theorems folder are properly referenced in content.tex -8. Chapter structure: Ensures theorem files contain \\chapter commands and that \\chapter comes before any \\section commands -9. Theorem folder correspondence: Ensures each theorem .tex file in theorems/ has a matching CamelCase folder in LiveLeanTriathlon/ -10. AMS tags: Ensures the final environment in each theorem file has @[AMS ...] on its Lean declaration -11. File header format: Ensures each theorem file starts with \\chapter, followed by a proof-description line, followed by a \\url reference somewhere in the opening paragraph -12. Theorem environment presence: Ensures each .tex file in theorems/ contains at least one labelled environment (theorem/lemma/definition) - -TODO: -1. Ensure that theorems are in order: If A \\uses B, then B should appear before A in the file, - or in a file recursively imported by the file that holds A -""" - -import re -import json -import argparse -from pathlib import Path -from typing import Dict, List, Set, Optional -from dataclasses import dataclass -from collections import defaultdict - - -@dataclass -class CheckResult: - """Check result""" - - success: bool - message: str - file_path: str - line_number: Optional[int] = None - is_warning: bool = False # Whether it's a warning (non-critical error) - - -@dataclass -class EnvironmentBlock: - """LaTeX environment block""" - - env_type: str - label: Optional[str] - uses: List[str] - start_line: int - end_line: int - content: str - file_path: str # File path where this block is located - has_lean: bool = False # Whether this block contains \lean{} command - proof_block: Optional["EnvironmentBlock"] = None # Bound proof block - parent_block: Optional["EnvironmentBlock"] = None # Parent lemma/theorem block - - -class BlueprintChecker: - """Blueprint checker""" - - def __init__(self, config_path: str = None): - """Initialize checker""" - self.config = self._load_config(config_path) - self.workspace_root = Path(__file__).parent.parent - self.blueprint_dir = self.workspace_root / self.config["paths"]["blueprint_dir"] - self.theorems_dir = self.workspace_root / self.config["paths"]["theorems_dir"] - self.content_file = self.workspace_root / self.config["paths"]["content_file"] - - # Store check results - self.results: List[CheckResult] = [] - self.all_labels: Dict[str, Set[str]] = defaultdict( - set - ) # label -> set of file_paths - self.file_labels: Dict[str, Set[str]] = defaultdict( - set - ) # file_path -> set of labels - self.environment_blocks: List[EnvironmentBlock] = [] - - def _load_config(self, config_path: str = None) -> Dict: - """Load configuration file""" - if config_path is None: - config_path = Path(__file__).parent / "check_blueprints.json" - - try: - with open(config_path, "r", encoding="utf-8") as f: - return json.load(f) - except FileNotFoundError: - # If config file doesn't exist, use default config - return { - "environments": { - "require_label": ["lemma", "def", "theorem"], - "require_proof": ["lemma", "theorem"], - "must_be_referenced": ["lemma", "theorem"], - }, - "rules": { - "check_label_uniqueness": True, - "check_dependencies": True, - "check_file_references": True, - "check_proof_bindings": True, - "check_chapter_first": True, - "check_theorem_folder_correspondence": True, - }, - "paths": { - "blueprint_dir": "blueprint/src", - "theorems_dir": "blueprint/src/theorems", - "content_file": "blueprint/src/content.tex", - }, - } - - def _strip_latex_comments(self, content: str) -> str: - """Strip LaTeX comments (% to end of line), respecting escaped \\%""" - return re.sub(r"(? List[EnvironmentBlock]: - """Extract LaTeX environment blocks and process binding relationships""" - # First extract all environment blocks - all_blocks = self._extract_all_environment_blocks(content, file_path) - - # Process binding relationships - return self._process_block_bindings(all_blocks) - - def _extract_all_environment_blocks( - self, content: str, file_path: str - ) -> List[EnvironmentBlock]: - """Extract all LaTeX environment blocks (without processing binding relationships)""" - blocks = [] - lines = content.split("\n") - - # Regex pattern to match environment start and end - env_pattern = ( - r"\\begin\{(" - + "|".join( - self.config["environments"]["require_label"] - + ["proof"] # proof environment always needs checking - ) - + r")\}" - ) - - i = 0 - while i < len(lines): - line = lines[i] - match = re.search(env_pattern, line) - if match: - env_type = match.group(1) - start_line = i + 1 - - # Find corresponding \end{env_type} - end_line = self._find_end_environment(lines, i, env_type) - if end_line == -1: - i += 1 - continue - - # Extract environment content - env_content = "\n".join(lines[i : end_line + 1]) - - # Extract label - label = self._extract_label(env_content) - - # Extract uses - uses = self._extract_uses(env_content) - - # Extract lean - has_lean = self._extract_lean(env_content) - - block = EnvironmentBlock( - env_type=env_type, - label=label, - uses=uses, - start_line=start_line, - end_line=end_line + 1, - content=env_content, - file_path=file_path, - has_lean=has_lean, - ) - blocks.append(block) - - # Recursively process nested environments (inside the found environment) - nested_content = "\n".join(lines[i + 1 : end_line]) - nested_blocks = self._extract_all_environment_blocks( - nested_content, file_path - ) - # Adjust line numbers for nested blocks - for nested_block in nested_blocks: - nested_block.start_line += i + 1 - nested_block.end_line += i + 1 - blocks.extend(nested_blocks) - - i = end_line + 1 - else: - i += 1 - - return blocks - - def _process_block_bindings( - self, blocks: List[EnvironmentBlock] - ) -> List[EnvironmentBlock]: - """Process environment block binding relationships""" - # Sort by line number - blocks.sort(key=lambda x: x.start_line) - - result_blocks = [] - i = 0 - - while i < len(blocks): - block = blocks[i] - - # If environment type requires proof, check if followed by proof - if block.env_type in self.config["environments"]["require_proof"]: - # Check if next block is proof (allow any number of empty lines in between) - if i + 1 < len(blocks) and blocks[i + 1].env_type == "proof": - proof_block = blocks[i + 1] - # Bind proof to lemma/theorem - block.proof_block = proof_block - proof_block.parent_block = block - - # Merge proof's uses into lemma/theorem - block.uses.extend(proof_block.uses) - - result_blocks.append(block) - i += 2 # Skip proof block - else: - result_blocks.append(block) - i += 1 - else: - # proof block should already be bound, skip - if block.parent_block is None: - result_blocks.append(block) - i += 1 - - return result_blocks - - def _find_end_environment( - self, lines: List[str], start_idx: int, env_type: str - ) -> int: - """Find environment end position""" - end_pattern = rf"\\end\{{{re.escape(env_type)}\}}" - depth = 1 - - for i in range(start_idx + 1, len(lines)): - line = lines[i] - - # Check if new environment of same type starts - begin_pattern = rf"\\begin\{{{re.escape(env_type)}\}}" - if re.search(begin_pattern, line): - depth += 1 - - # Check if environment ends - if re.search(end_pattern, line): - depth -= 1 - if depth == 0: - return i - - return -1 - - def _extract_label(self, content: str) -> Optional[str]: - """Extract label""" - label_pattern = r"\\label\{([^}]+)\}" - match = re.search(label_pattern, content) - return match.group(1) if match else None - - def _extract_uses(self, content: str) -> List[str]: - """Extract uses references""" - uses_pattern = r"\\uses\{([^}]+)\}" - matches = re.findall(uses_pattern, content) - - # Handle comma-separated multiple references - all_uses = [] - for match in matches: - # Split by comma and strip whitespace - uses = [use.strip() for use in match.split(",")] - all_uses.extend(uses) - - return all_uses - - def _extract_lean(self, content: str) -> bool: - """Check if content contains \\lean{} command""" - lean_pattern = r"\\lean\{[^}]*\}" - return bool(re.search(lean_pattern, content)) - - def _extract_lean_name(self, content: str) -> Optional[str]: - """Extract the Lean declaration name from \\lean{name} command""" - lean_pattern = r"\\lean\{([^}]+)\}" - match = re.search(lean_pattern, content) - return match.group(1).strip() if match else None - - def _check_tex_file(self, file_path: Path) -> List[CheckResult]: - """Check single .tex file""" - results = [] - - try: - with open(file_path, "r", encoding="utf-8") as f: - content = f.read() - except Exception as e: - results.append( - CheckResult( - success=False, - message=f"Cannot read file: {e}", - file_path=str(file_path), - ) - ) - return results - - # Extract environment blocks (strip comments first) - blocks = self._extract_environment_blocks( - self._strip_latex_comments(content), str(file_path) - ) - self.environment_blocks.extend(blocks) - - # Check each environment block - for block in blocks: - # Check label requirements - if block.env_type in self.config["environments"]["require_label"]: - if not block.label: - results.append( - CheckResult( - success=False, - message=f"{block.env_type} environment missing \\label", - file_path=str(file_path), - line_number=block.start_line, - ) - ) - else: - # Check label uniqueness - current_file = str(file_path) - - # Check for duplicates within same file - if block.label in self.file_labels[current_file]: - results.append( - CheckResult( - success=False, - message=f"Duplicate label within same file: {block.label}", - file_path=current_file, - line_number=block.start_line, - ) - ) - else: - # Record to file label set - self.file_labels[current_file].add(block.label) - - # Check for duplicates across files - if block.label in self.all_labels: - other_files = self.all_labels[block.label] - results.append( - CheckResult( - success=True, - message=f"Duplicate label across files: {block.label} (already used in {', '.join(other_files)})", - file_path=current_file, - line_number=block.start_line, - is_warning=True, - ) - ) - - # Add current file to this label's file set - self.all_labels[block.label].add(current_file) - - # Check if has lean block - if ( - self.config["rules"]["check_lean_blocks"] - and block.env_type in self.config["environments"]["require_lean"] - and not block.has_lean - ): - results.append( - CheckResult( - success=False, - message=f"{block.env_type} environment {block.label} missing \\lean{{}} block", - file_path=str(file_path), - line_number=block.start_line, - ) - ) - - # Check if followed by proof block - if ( - self.config["rules"]["check_proof_bindings"] - and block.env_type in self.config["environments"]["require_proof"] - and not block.proof_block - ): - results.append( - CheckResult( - success=False, - message=f"{block.env_type} environment {block.label} missing \\proof block", - file_path=str(file_path), - line_number=block.start_line, - ) - ) - - elif block.env_type == "proof": - # Check for standalone proof blocks - if ( - self.config["rules"]["check_proof_bindings"] - and not block.parent_block - ): - results.append( - CheckResult( - success=False, - message=f"Found standalone \\proof block, should be bound to {', '.join(self.config['environments']['require_proof'])} environment", - file_path=str(file_path), - line_number=block.start_line, - ) - ) - - return results - - def _build_dependency_graph( - self, blocks: List[EnvironmentBlock] - ) -> Dict[str, Set[str]]: - """Build dependency graph from blocks (label -> set of labels it uses)""" - graph = {} - for block in blocks: - if block.label: - graph[block.label] = set(block.uses) - return graph - - def _detect_cycle( - self, - graph: Dict[str, Set[str]], - start_node: str, - visited: Set[str], - rec_stack: Set[str], - ) -> Optional[List[str]]: - """Detect cycle in directed graph using DFS. Returns cycle path if found.""" - visited.add(start_node) - rec_stack.add(start_node) - - if start_node in graph: - for neighbor in graph[start_node]: - if neighbor not in visited: - cycle = self._detect_cycle(graph, neighbor, visited, rec_stack) - if cycle: - return [start_node] + cycle - elif neighbor in rec_stack: - # Found a cycle - return [start_node, neighbor] - - rec_stack.remove(start_node) - return None - - def _find_all_cycles(self, graph: Dict[str, Set[str]]) -> List[List[str]]: - """Find all cycles in the dependency graph""" - visited = set() - cycles = [] - - for node in graph: - if node not in visited: - rec_stack = set() - cycle = self._detect_cycle(graph, node, visited, rec_stack) - if cycle: - cycles.append(cycle) - - return cycles - - def _compute_reachable( - self, graph: Dict[str, Set[str]], start_nodes: Set[str] - ) -> Set[str]: - """Compute all nodes reachable from start_nodes (transitive closure)""" - reachable = set() - stack = list(start_nodes) - - while stack: - node = stack.pop() - if node in reachable: - continue - reachable.add(node) - - if node in graph: - for neighbor in graph[node]: - if neighbor not in reachable: - stack.append(neighbor) - - return reachable - - def _check_circular_dependencies(self) -> List[CheckResult]: - """Check for circular dependencies within each file""" - results = [] - - if not self.config["rules"].get("check_circular_dependencies", True): - return results - - # Group blocks by file - blocks_by_file = defaultdict(list) - for block in self.environment_blocks: - if ( - block.label - and block.env_type in self.config["environments"]["require_label"] - ): - blocks_by_file[block.file_path].append(block) - - # Check each file separately - for file_path, blocks in blocks_by_file.items(): - # Build dependency graph for this file only - graph = self._build_dependency_graph(blocks) - - # Get all labels defined in this file - file_labels = {block.label for block in blocks} - - # Filter graph to only include edges between labels defined in this file - filtered_graph = { - label: deps & file_labels - for label, deps in graph.items() - if label in file_labels - } - - # Find cycles - cycles = self._find_all_cycles(filtered_graph) - - for cycle in cycles: - # Format cycle path - cycle_path = " -> ".join(cycle) - if cycle[0] == cycle[-1]: - cycle_path = " -> ".join(cycle) - else: - cycle_path = " -> ".join(cycle) + " -> " + cycle[0] - - # Report error for the first block in the cycle - first_label = cycle[0] - block = next((b for b in blocks if b.label == first_label), None) - if block: - results.append( - CheckResult( - success=False, - message=f"Circular dependency detected: {cycle_path}", - file_path=file_path, - line_number=block.start_line, - ) - ) - - return results - - def _check_transitive_usage(self) -> List[CheckResult]: - """Check that all environments are used transitively by the final environment in each file""" - results = [] - - if not self.config["rules"].get("check_transitive_usage", True): - return results - - # Group blocks by file - blocks_by_file = defaultdict(list) - for block in self.environment_blocks: - if ( - block.label - and block.env_type in self.config["environments"]["require_label"] - ): - blocks_by_file[block.file_path].append(block) - - # Check each file separately - for file_path, blocks in blocks_by_file.items(): - if not blocks: - continue - - # Sort blocks by line number to find the final environment - sorted_blocks = sorted(blocks, key=lambda b: b.start_line) - final_block = sorted_blocks[-1] - - # Build dependency graph - graph = self._build_dependency_graph(blocks) - - # Find all labels defined in this file - file_labels = {block.label for block in blocks} - - # Compute all labels reachable from the final block - reachable = self._compute_reachable(graph, {final_block.label}) - - # Check if all other labels in the file are reachable - for block in blocks: - if block.label != final_block.label and block.label not in reachable: - results.append( - CheckResult( - success=False, - message=f"{block.env_type} '{block.label}' is not used (transitively) by the final environment '{final_block.label}' in this file", - file_path=file_path, - line_number=block.start_line, - ) - ) - - return results - - def _check_dependencies(self) -> List[CheckResult]: - """Check dependencies""" - results = [] - - if not self.config["rules"]["check_dependencies"]: - return results - - # Collect all defined labels - all_defined_labels = { - block.label for block in self.environment_blocks if block.label - } - - # Collect blocks that must be referenced (based on configuration) - blocks_to_check = { - block.label: block - for block in self.environment_blocks - if block.label - and block.env_type - in self.config["environments"].get("must_be_referenced", []) - } - - # Collect all uses references - all_uses = set() - for block in self.environment_blocks: - all_uses.update(block.uses) - - # Check for undefined uses references - for block in self.environment_blocks: - for use_ref in block.uses: - if use_ref not in all_defined_labels: - results.append( - CheckResult( - success=False, - message=f"Undefined reference in \\uses: {use_ref}", - file_path=block.file_path, - line_number=block.start_line, - ) - ) - - # Check for unused labels - for label, block in blocks_to_check.items(): - if label not in all_uses: - results.append( - CheckResult( - success=False, - message=f"Unused {block.env_type}: {label}", - file_path=block.file_path, - line_number=block.start_line, - ) - ) - - return results - - def _check_file_references(self) -> List[CheckResult]: - """Check file references - ensures content.tex contains imports of exactly those files in theorems folder""" - results = [] - - if not self.config["rules"]["check_file_references"]: - return results - - # Read content.tex file - try: - with open(self.content_file, "r", encoding="utf-8") as f: - content = f.read() - except Exception as e: - results.append( - CheckResult( - success=False, - message=f"Cannot read content.tex: {e}", - file_path=str(self.content_file), - ) - ) - return results - - # Extract all \input{} references that point to theorems folder - input_pattern = r"\\input\{([^}]+)\}" - referenced_theorem_files = set() - all_referenced_files = set() - - for match in re.finditer(input_pattern, content): - ref_path = match.group(1) - # Add .tex extension if not present - if not ref_path.endswith(".tex"): - ref_path += ".tex" - all_referenced_files.add(ref_path) - - # Check if this reference points to theorems folder - if ref_path.startswith("theorems/"): - referenced_theorem_files.add(ref_path) - - # Get actual files in theorems folder - actual_theorem_files = set() - if self.theorems_dir.exists(): - for tex_file in self.theorems_dir.glob("*.tex"): - relative_path = f"theorems/{tex_file.name}" - actual_theorem_files.add(relative_path) - - # Check for files in theorems folder that are not referenced - missing_references = actual_theorem_files - referenced_theorem_files - for missing_file in missing_references: - filename = missing_file.replace("theorems/", "") - results.append( - CheckResult( - success=False, - message=f"File {filename} exists in theorems folder but not referenced in content.tex", - file_path=str(self.theorems_dir / filename), - ) - ) - - # Check for references to theorems files that don't exist - invalid_references = referenced_theorem_files - actual_theorem_files - for invalid_ref in invalid_references: - filename = invalid_ref.replace("theorems/", "") - results.append( - CheckResult( - success=False, - message=f"content.tex references {invalid_ref} but file does not exist in theorems folder", - file_path=str(self.content_file), - ) - ) - - return results - - def _check_chapter_first(self) -> List[CheckResult]: - """Check that chapter comes first before any sections in theorems files""" - results = [] - - if not self.config["rules"]["check_chapter_first"]: - return results - - # Check files in theorems folder - if self.theorems_dir.exists(): - for tex_file in self.theorems_dir.glob("*.tex"): - file_results = self._check_single_file_chapter_section_order(tex_file) - results.extend(file_results) - - return results - - def _kebab_to_camel_case(self, kebab_str: str) -> str: - """Convert kebab-case to UpperCamelCase""" - components = kebab_str.split("-") - return "".join(word.capitalize() for word in components) - - def _camel_to_kebab_case(self, camel_str: str) -> str: - """Convert UpperCamelCase to kebab-case""" - result = [] - for i, char in enumerate(camel_str): - if char.isupper() and i > 0: - result.append("-") - result.append(char.lower()) - return "".join(result) - - def _check_single_file_chapter_section_order( - self, file_path: Path - ) -> List[CheckResult]: - """Check chapter/section order in a single file""" - results = [] - - try: - with open(file_path, "r", encoding="utf-8") as f: - content = f.read() - except Exception as e: - results.append( - CheckResult( - success=False, - message=f"Cannot read file: {e}", - file_path=str(file_path), - ) - ) - return results - - lines = content.split("\n") - - # Scan line by line until we find \chapter or \section - for i, line in enumerate(lines): - line_number = i + 1 # Convert to 1-based line number - - # Check for \chapter command - if re.search(r"\\chapter\{", line): - # Found \chapter first, this is correct - return results - - # Check for \section command - if re.search(r"\\section\{", line): - # Found \section before any \chapter, this is an error - results.append( - CheckResult( - success=False, - message="First \\section command found before any \\chapter command", - file_path=str(file_path), - line_number=line_number, - ) - ) - return results - - # If we reach here, no \chapter was found - results.append( - CheckResult( - success=False, - message="File must contain at least one \\chapter command", - file_path=str(file_path), - ) - ) - - return results - - def _check_file_header_format(self) -> List[CheckResult]: - """Check that each theorem file starts with \\chapter, then proof description, then a \\url somewhere in the opening paragraph""" - results = [] - - if not self.theorems_dir.exists(): - return results - - for tex_file in self.theorems_dir.glob("*.tex"): - try: - with open(tex_file, "r", encoding="utf-8") as f: - lines = f.readlines() - except Exception as e: - results.append( - CheckResult( - success=False, - message=f"Cannot read file: {e}", - file_path=str(tex_file), - ) - ) - continue - - # Collect non-blank, non-comment lines with their 1-based line numbers - text_lines = [] - for i, line in enumerate(lines): - stripped = line.strip() - if stripped and not stripped.startswith("%"): - text_lines.append((i + 1, stripped)) - - # Check line 1: must be \chapter{...} - if not text_lines or not re.match(r"\\chapter\{", text_lines[0][1]): - lineno = text_lines[0][0] if text_lines else None - results.append( - CheckResult( - success=False, - message="First non-blank line must be a \\chapter{} command", - file_path=str(tex_file), - line_number=lineno, - ) - ) - continue - - # Check line 2: must match "This section contains a (stub of a) proof of ..." or "This section contains a proof of ..." - if len(text_lines) < 2 or not re.match( - r"This section contains a (\(stub of a\) )?proof of ", text_lines[1][1] - ): - lineno = text_lines[1][0] if len(text_lines) >= 2 else None - results.append( - CheckResult( - success=False, - message='Second non-blank line must be "This section contains a (stub of a) proof of ..." or "This section contains a proof of ..."', - file_path=str(tex_file), - line_number=lineno, - ) - ) - continue - - # Check opening paragraph: must contain a \url{...} reference somewhere - # before the first \begin{...} environment - opening_lines = [] - for lineno, content in text_lines[2:]: - if re.match(r"\\begin\{", content): - break - opening_lines.append((lineno, content)) - if not any( - re.search(r"\\url\{[^}]+\}", content) for _, content in opening_lines - ): - lineno = ( - opening_lines[-1][0] - if opening_lines - else (text_lines[2][0] if len(text_lines) >= 3 else None) - ) - results.append( - CheckResult( - success=False, - message="Opening paragraph must contain a \\url{} reference", - file_path=str(tex_file), - line_number=lineno, - ) - ) - - return results - - def _check_theorem_folder_correspondence(self) -> List[CheckResult]: - """Check that theorem files correspond to LiveLeanTriathlon folders""" - results = [] - - if not self.config["rules"].get("check_theorem_folder_correspondence", True): - return results - - # Get theorem files (without .tex extension) - theorem_files = set() - if self.theorems_dir.exists(): - for tex_file in self.theorems_dir.glob("*.tex"): - theorem_files.add(tex_file.stem) - - # Get LiveLeanTriathlon folders - live_lean_triathlon_dir = self.workspace_root / "LiveLeanTriathlon" - live_lean_triathlon_folders = set() - if live_lean_triathlon_dir.exists(): - for item in live_lean_triathlon_dir.iterdir(): - if item.is_dir() and item.name not in ["Mathlib", "Mistakes"]: - live_lean_triathlon_folders.add(item.name) - - # Check that each theorem file has a corresponding folder - for theorem_file in theorem_files: - expected_folder = self._kebab_to_camel_case(theorem_file) - if expected_folder not in live_lean_triathlon_folders: - results.append( - CheckResult( - success=False, - message=f"Theorem file {theorem_file}.tex has no corresponding folder. Expected: LiveLeanTriathlon/{expected_folder}/", - file_path=str(self.theorems_dir / f"{theorem_file}.tex"), - ) - ) - - return results - - def _check_theorem_env_present(self) -> List[CheckResult]: - """Check that each .tex file in theorems/ contains at least one labelled - environment (theorem/lemma/definition).""" - results = [] - - if not self.config["rules"].get("check_theorem_env_present", True): - return results - - if not self.theorems_dir.exists(): - return results - - required_envs = set(self.config["environments"]["require_label"]) - - # Group blocks by file path - blocks_by_file: Dict[str, list] = defaultdict(list) - for block in self.environment_blocks: - if block.env_type in required_envs: - blocks_by_file[block.file_path].append(block) - - for tex_file in sorted(self.theorems_dir.glob("*.tex")): - file_path = str(tex_file) - if not blocks_by_file.get(file_path): - results.append( - CheckResult( - success=False, - message=( - f"Theorem file contains no labelled environment " - f"(expected at least one of: {sorted(required_envs)})" - ), - file_path=file_path, - ) - ) - - return results - - def _check_lean_ams_tags(self) -> List[CheckResult]: - """Check that the final environment in each theorem file has @[AMS ...] in the corresponding Lean file, - and that the specific codes match those recorded in scripts/theorem_stats.json.""" - results = [] - - if not self.config["rules"].get("check_lean_ams_tags", True): - return results - - lean_dir = self.workspace_root / "LiveLeanTriathlon" - if not lean_dir.exists(): - return results - - # Load the expected AMS codes from the stats file - stats_file = self.workspace_root / "scripts" / "theorem_stats.json" - expected_codes: Dict[str, List[int]] = {} - if stats_file.exists(): - try: - stats = json.loads(stats_file.read_text(encoding="utf-8")) - expected_codes = { - name: (info["ams_codes"] if isinstance(info, dict) else info) - for name, info in stats.get("theorems", {}).items() - if (info["ams_codes"] if isinstance(info, dict) else info) - } - except Exception: - pass # treat as empty; missing/malformed stats file won't cause false positives - - # Build a map from lean declaration name -> sorted list of AMS codes - # by scanning all .lean files once - lean_ams_codes: Dict[str, List[int]] = {} - decl_keywords = ( - r"(?:theorem|lemma|def|noncomputable\s+def|abbrev|structure|class|instance)" - ) - ams_decl_pattern = re.compile( - r"@\[[^\]]*\bAMS\b([^\]]*)\]" # capture the numbers after AMS - r"(?:\s*@\[[^\]]*\][^\S\n]*)*" # optional additional attributes - r"\s+" - r"(?:" + decl_keywords + r")\s+" - r"([\w.]+)", # declaration name (may include namespace dots) - re.MULTILINE, - ) - for lean_file in lean_dir.rglob("*.lean"): - try: - content = lean_file.read_text(encoding="utf-8") - except Exception: - continue - for m in ams_decl_pattern.finditer(content): - nums = sorted(set(int(x) for x in m.group(1).split() if x.isdigit())) - decl = m.group(2) - lean_ams_codes[decl] = nums - lean_ams_codes[decl.split(".")[-1]] = nums - - # Group environment blocks by file, restricted to theorem files - theorem_files: Set[str] = set() - if self.theorems_dir.exists(): - for tex_file in self.theorems_dir.glob("*.tex"): - theorem_files.add(str(tex_file)) - - blocks_by_file: Dict[str, list] = defaultdict(list) - for block in self.environment_blocks: - if ( - block.label - and block.env_type in self.config["environments"]["require_label"] - and block.file_path in theorem_files - ): - blocks_by_file[block.file_path].append(block) - - for file_path, blocks in blocks_by_file.items(): - if not blocks: - continue - - # Find the final environment (highest line number) - final_block = max(blocks, key=lambda b: b.start_line) - - lean_name = self._extract_lean_name(final_block.content) - if not lean_name: - continue # Missing \lean{} already caught by check_lean_blocks - - # Also check the short name: declaration may live inside a `namespace` block, - # so the file contains e.g. `theorem dilworth` while the tex uses `PartialOrder.dilworth` - short_name = lean_name.split(".")[-1] - actual_codes = lean_ams_codes.get(lean_name) or lean_ams_codes.get( - short_name - ) - - if not actual_codes: - results.append( - CheckResult( - success=False, - message=f"Final environment '{final_block.label}' (lean: {lean_name}) is missing @[AMS ...] attribute in Lean file", - file_path=file_path, - line_number=final_block.start_line, - ) - ) - continue - - # Look up what the stats file expects for this declaration - expected = expected_codes.get(lean_name) or expected_codes.get(short_name) - if expected is None: - # Declaration has an AMS tag but is not tracked in theorem_stats.json - results.append( - CheckResult( - success=False, - message=( - f"Final environment '{final_block.label}' (lean: {lean_name}) " - f"has @[AMS {actual_codes}] but is not recorded in scripts/theorem_stats.json. " - f"Run: python3 scripts/generate_theorem_stats.py" - ), - file_path=file_path, - line_number=final_block.start_line, - ) - ) - elif sorted(actual_codes) != sorted(expected): - results.append( - CheckResult( - success=False, - message=( - f"Final environment '{final_block.label}' (lean: {lean_name}) " - f"has @[AMS {actual_codes}] but scripts/theorem_stats.json expects {expected}. " - f"Run: python3 scripts/generate_theorem_stats.py" - ), - file_path=file_path, - line_number=final_block.start_line, - ) - ) - - return results - - def check_all(self) -> List[CheckResult]: - """Execute all checks""" - self.results = [] - self.all_labels = defaultdict(set) - self.file_labels = defaultdict(set) - self.environment_blocks = [] - - # Check all .tex files - if self.blueprint_dir.exists(): - for tex_file in self.blueprint_dir.rglob("*.tex"): - if tex_file.name != "content.tex": # content.tex handled separately - self.results.extend(self._check_tex_file(tex_file)) - - # Check dependencies - self.results.extend(self._check_dependencies()) - - # Check circular dependencies - self.results.extend(self._check_circular_dependencies()) - - # Check transitive usage - self.results.extend(self._check_transitive_usage()) - - # Check file references - self.results.extend(self._check_file_references()) - - # Check chapter/section order - self.results.extend(self._check_chapter_first()) - - # Check file header format (chapter, proof description, url line) - self.results.extend(self._check_file_header_format()) - - # Check theorem folder correspondence - self.results.extend(self._check_theorem_folder_correspondence()) - - # Check AMS tags on final environments - self.results.extend(self._check_lean_ams_tags()) - - # Check that each theorem .tex file has at least one labelled environment - self.results.extend(self._check_theorem_env_present()) - - return self.results - - def print_results(self, verbose: bool = True, show_blocks: bool = False): - """Print check results""" - if show_blocks and self.environment_blocks: - print("=== Environment Blocks Information ===") - print(f"Found {len(self.environment_blocks)} environment blocks:") - for i, block in enumerate(self.environment_blocks, 1): - print(f" {i}. {block.env_type}") - print(f" Label: {block.label}") - print(f" Uses: {block.uses}") - print(f" File: {block.file_path}") - print(f" Line range: {block.start_line}-{block.end_line}") - print(f" Bound proof: {'Yes' if block.proof_block else 'No'}") - print( - f" Parent block: {block.parent_block.label if block.parent_block else 'None'}" - ) - print( - f" Content preview: {block.content[:100].replace(chr(10), ' ')}..." - ) - print() - - # Statistics - env_types = {} - for block in self.environment_blocks: - env_types[block.env_type] = env_types.get(block.env_type, 0) + 1 - - print(f"📊 Block Statistics:") - print(f" Total blocks: {len(self.environment_blocks)}") - print(f" Environment type distribution: {env_types}") - - # All labels - labels = [block.label for block in self.environment_blocks if block.label] - print(f" Found labels: {labels}") - - # All uses references - all_uses = [use for block in self.environment_blocks for use in block.uses] - print(f" Found uses references: {all_uses}") - - # Binding relationships - print(f"\n🔗 Binding Relationships:") - for block in self.environment_blocks: - if block.env_type in ["lemma", "theorem"]: - if block.proof_block: - print( - f" ✅ {block.env_type} {block.label} -> proof (line {block.proof_block.start_line})" - ) - else: - print(f" ❌ {block.env_type} {block.label} -> missing proof") - elif block.env_type == "proof": - if block.parent_block: - print( - f" ✅ proof (line {block.start_line}) -> {block.parent_block.env_type} {block.parent_block.label}" - ) - else: - print( - f" ❌ proof (line {block.start_line}) -> standalone proof block" - ) - print() - - if not self.results: - print("✅ All checks passed!") - return - - # Separate errors and warnings - errors = [r for r in self.results if not r.success] - warnings = [r for r in self.results if r.success and r.is_warning] - - if errors: - print(f"❌ Found {len(errors)} errors:\n") - for i, result in enumerate(errors, 1): - location = ( - f" ({result.file_path}:{result.line_number})" - if result.line_number - else f" ({result.file_path})" - ) - print(f"{i}. ❌ {result.message}{location}") - - if warnings and verbose: - print(f"\n⚠️ Found {len(warnings)} warnings:\n") - for i, result in enumerate(warnings, 1): - location = ( - f" ({result.file_path}:{result.line_number})" - if result.line_number - else f" ({result.file_path})" - ) - print(f"{i}. ⚠️ {result.message}{location}") - elif warnings and not verbose: - print(f"\n⚠️ Found {len(warnings)} warnings (use --verbose to see details)") - - if not errors and not warnings: - print("✅ All checks passed!") - - -def main(): - """Main function""" - parser = argparse.ArgumentParser(description="Check Blueprint LaTeX files") - parser.add_argument( - "--config", - "-c", - help="Configuration file path (default: check_blueprints.json)", - ) - - # Output control group - output_group = parser.add_mutually_exclusive_group() - output_group.add_argument( - "--verbose", - "-v", - action="store_true", - default=True, - help="Show all information including warnings (default: True)", - ) - - # Block information control - parser.add_argument( - "--conclusion", - action="store_true", - default=True, - help="Print detailed environment block information and conclusion (default: True)", - ) - - args = parser.parse_args() - - # Determine output modes - verbose = args.verbose - show_blocks = args.conclusion - - checker = BlueprintChecker(args.config) - results = checker.check_all() - checker.print_results(verbose=verbose, show_blocks=show_blocks) - - # If there are errors (not warnings), exit with code 1 - errors = [r for r in results if not r.success] - if errors: - exit(1) - - -if __name__ == "__main__": - main() diff --git a/scripts/create_sorries/create_sorries.py b/scripts/create_sorries/create_sorries.py deleted file mode 100644 index 8fb8368..0000000 --- a/scripts/create_sorries/create_sorries.py +++ /dev/null @@ -1,776 +0,0 @@ -"""Generate benchmark variant directories from LiveLeanTriathlon/. - -Variants: - Sorry - copy of LiveLeanTriathlon/ where every theorem/lemma - proof is replaced with `sorry`. Each project folder - keeps its single ``All.lean``. - Easy - derived from Sorry. Each project folder's ``All.lean`` - is split into ``Background.lean`` (everything except - the final theorem) and ``MainTheorem.lean`` (the final - theorem only); ``MainTheorem.lean`` imports - ``Background.lean``. - Hard - derived from Sorry. Each project folder's ``All.lean`` - is collapsed to ``MainTheorem.lean`` containing only - the definitions, opens/section scaffolding, and the - final theorem; all non-final lemmas/theorems are - removed. - Autoformalization - same as Hard, plus the corresponding - ``blueprint/src/theorems/.tex`` is copied into - each project folder. - -In every variant the ``Mathlib/`` and ``Util/`` subdirectories are copied -unchanged (no proof transformation, no structural changes); only their imports -are rewritten so the variant tree is internally consistent. - -Each variant gets a top-level index file at ``/LiveLeanTriathlon.lean``. - -Usage: - python3 scripts/create_sorries/create_sorries.py - python3 scripts/create_sorries/create_sorries.py --variant Hard -""" - -import argparse -import datetime -import re -import shutil -from pathlib import Path - -from scripts.create_sorries.extract_sublemmas import ( - add_newlines_before_keys, - create_proof_with_sorries, -) - -VARIANTS = ["Sorry", "Easy", "Hard", "Autoformalization"] - -# Subdirs whose contents are not transformed beyond import rewriting. -UNTOUCHED_SUBDIRS = ("Mathlib", "Util") - -LOG_FILE = Path(__file__).parent / "create_sorries.log" - -NEWLINE_KEYS = [ - "theorem", - "lemma", - "def", - "abbrev", - "instance", - "class", - "variable", - "open", - "namespace", - "set_option", - "universe", - "scoped", - "section", - "end", - "structure", - "inductive", -] - -IMPORT_RE = re.compile(r"^(\s*)(public\s+)?import\s+(\S+)(.*)$") - -EMPTY_BLUEPRINT_FIELD_RE = re.compile(r"\s*\((?:statement|proof)\s*:=\s*\)") - -DECL_LINE_RE = re.compile( - r"^(?P[ \t]*)" - r"(?P(?:private[ \t]+|protected[ \t]+|noncomputable[ \t]+|partial[ \t]+|unsafe[ \t]+|@\[expose\][ \t]+)*)" - r"(?Ptheorem|lemma|def|abbrev|structure|class|instance|inductive)[ \t]+" - r"(?P[\w.]+)" -) -NEEDED_COMMENT = "-- Needed for def" - - -# --------------------------------------------------------------------- log - - -def log_message(message: str) -> None: - timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") - with open(LOG_FILE, "a", encoding="utf-8") as f: - f.write(f"[{timestamp}] {message}\n") - - -def find_project_root() -> Path: - current = Path(__file__).resolve().parent - while current != current.parent: - if (current / "lean-toolchain").exists(): - return current - current = current.parent - raise RuntimeError("Could not find project root with lean-toolchain file") - - -# --------------------------------------------------------------------- imports - - -def transform_imports(text: str, mapping: dict[str, str]) -> str: - """Rewrite ``import`` and ``public import`` lines using ``mapping``. - - Each entry ``old -> new`` rewrites any import whose module path equals - ``old`` or starts with ``old + '.'``. Imports unaffected by ``mapping`` - pass through unchanged. - """ - out_lines: list[str] = [] - for line in text.split("\n"): - m = IMPORT_RE.match(line) - if not m: - out_lines.append(line) - continue - indent, public, module_path, rest = ( - m.group(1), - m.group(2) or "", - m.group(3), - m.group(4), - ) - new_module = module_path - # Apply longest-prefix-wins so e.g. a more specific mapping like - # "LiveLeanTriathlon.X.All" beats "LiveLeanTriathlon". - candidates = sorted( - (k for k in mapping if module_path == k or module_path.startswith(k + ".")), - key=len, - reverse=True, - ) - if candidates: - k = candidates[0] - new_module = mapping[k] + module_path[len(k) :] - out_lines.append(f"{indent}{public}import {new_module}{rest}") - return "\n".join(out_lines) - - -def rewrite_all_to_main(text: str, variant: str, project_folders: set[str]) -> str: - """Rewrite ``LiveLeanTriathlon..All`` to - ``LiveLeanTriathlon..MainTheorem`` in import lines, when ```` is - a project folder. Used by Easy/Hard/Autoformalization where each project - folder no longer has an ``All.lean``.""" - prefix = f"LiveLeanTriathlon{variant}." - out_lines: list[str] = [] - for line in text.split("\n"): - m = IMPORT_RE.match(line) - if not m: - out_lines.append(line) - continue - indent, public, module_path, rest = ( - m.group(1), - m.group(2) or "", - m.group(3), - m.group(4), - ) - if module_path.startswith(prefix) and module_path.endswith(".All"): - inner = module_path[len(prefix) : -len(".All")] - if inner in project_folders: - module_path = f"{prefix}{inner}.MainTheorem" - out_lines.append(f"{indent}{public}import {module_path}{rest}") - return "\n".join(out_lines) - - -# --------------------------------------------------------------------- proofs - - -def sorry_fy(text: str) -> str: - """Replace every theorem/lemma proof with ``sorry``. - - ``create_proof_with_sorries`` runs through ``LeanCodeParser``, which strips - all comments — including the leading ``/- … -/`` license block and the - ``-- Needed for def`` annotations produced by - ``scripts/mark_needed_for_def.py``. Both are restored afterwards so the - information propagates to derived variant trees. - """ - m = LICENSE_HEADER_RE.match(text) - license_block = m.group(1) if m else "" - needed = find_needed_decl_keys_and_names(text) - - text = create_proof_with_sorries(text, keys=["theorem", "lemma"]) - text = EMPTY_BLUEPRINT_FIELD_RE.sub("", text) - text = add_newlines_before_keys(text, keys=NEWLINE_KEYS) - if license_block and not text.lstrip().startswith("/-"): - text = license_block + "\n\n" + text.lstrip() - text = reannotate_needed_decls(text, needed) - return text - - -# --------------------------------------------------------------------- declarations - - -DECORATOR_IN_RE = re.compile( - r"^\s*(?:open|omit|attribute|set_option|include|variable)\b[^\n]*\bin\s*$" -) -BARE_MODIFIER_RE = re.compile( - r"^\s*(?:private|protected|noncomputable|partial|unsafe)\s*$" -) - - -def find_decoration_start(lines: list[str], decl_idx: int) -> int: - """Return the earliest line index that's part of the decorations preceding - the declaration at ``decl_idx``: ``@[...]`` attributes (which may span - multiple lines), ``/-- ... -/`` docstrings, and ``open X in`` prefixes.""" - j = decl_idx - 1 - start = decl_idx - while j >= 0: - s = lines[j].strip() - if not s: - j -= 1 - continue - if s.startswith("@["): - depth = lines[j].count("[") - lines[j].count("]") - attr_start = j - while depth > 0 and attr_start > 0: - attr_start -= 1 - depth += lines[attr_start].count("[") - lines[attr_start].count("]") - start = attr_start - j = attr_start - 1 - continue - if s.endswith("-/"): - k = j - while k >= 0 and "/--" not in lines[k]: - k -= 1 - if k >= 0: - start = k - j = k - 1 - continue - break - if DECORATOR_IN_RE.match(lines[j]): - start = j - j -= 1 - continue - if BARE_MODIFIER_RE.match(lines[j]): - start = j - j -= 1 - continue - if s == NEEDED_COMMENT: - start = j - j -= 1 - continue - break - return start - - -def find_decl_block_end(lines: list[str], decl_idx: int) -> int: - """Return the last line index belonging to the declaration block starting - at ``decl_idx``. - - The block extends through: - - every more-indented line (the proof body and continuations); - - signature continuations at equal/lower indent that appear before the - proof-introducing ``:=`` (e.g. wrapped parameter lists); - - ``termination_by``/``decreasing_by`` clauses at the same indent. - """ - decl_line = lines[decl_idx] - base_indent = len(decl_line) - len(decl_line.lstrip()) - end = decl_idx - walrus_seen = ":=" in decl_line - k = decl_idx + 1 - while k < len(lines): - line = lines[k] - if not line.strip(): - k += 1 - continue - line_indent = len(line) - len(line.lstrip()) - s = line.lstrip() - if line_indent > base_indent: - end = k - if ":=" in line: - walrus_seen = True - k += 1 - continue - if s.startswith("termination_by") or s.startswith("decreasing_by"): - end = k - k += 1 - continue - if not walrus_seen: - end = k - if ":=" in line: - walrus_seen = True - k += 1 - continue - break - return end - - -def find_all_decls(text: str, keys: tuple[str, ...]) -> list[dict]: - """Return ordered list of declarations matching any of ``keys``. - - Each entry has ``decl_line`` (line index of the keyword), ``start_line`` - (earliest decoration line), ``end_line`` (last proof/body line), - ``key``, and ``name``. - """ - lines = text.split("\n") - decls: list[dict] = [] - i = 0 - while i < len(lines): - m = DECL_LINE_RE.match(lines[i]) - if m and m.group("key") in keys: - start_line = find_decoration_start(lines, i) - end_line = find_decl_block_end(lines, i) - decls.append( - { - "decl_line": i, - "start_line": start_line, - "end_line": end_line, - "key": m.group("key"), - "name": m.group("name"), - } - ) - i = end_line + 1 - else: - i += 1 - return decls - - -def has_needed_for_def_comment(body_lines: list[str], decl: dict) -> bool: - """True if the decl's decoration block contains a ``-- Needed for def`` comment.""" - return any( - body_lines[i].strip() == NEEDED_COMMENT - for i in range(decl["start_line"], decl["decl_line"]) - ) - - -def find_needed_decl_keys_and_names(text: str) -> set[tuple[str, str]]: - """Return ``(key, name)`` for ``lemma``/``theorem`` declarations carrying - a ``-- Needed for def`` comment.""" - lines = text.split("\n") - return { - (d["key"], d["name"]) - for d in find_all_decls(text, keys=("lemma", "theorem")) - if has_needed_for_def_comment(lines, d) - } - - -def reannotate_needed_decls(text: str, needed: set[tuple[str, str]]) -> str: - """Insert ``-- Needed for def`` above each ``(key, name)`` in ``needed`` - whose block does not already carry the comment. Used after ``sorry_fy`` - strips comments so the source-file annotation propagates to derived - variant trees.""" - if not needed: - return text - lines = text.split("\n") - decls = find_all_decls(text, keys=("lemma", "theorem")) - insertions: dict[int, str] = {} - for d in decls: - if (d["key"], d["name"]) not in needed: - continue - if has_needed_for_def_comment(lines, d): - continue - indent_match = re.match(r"^([ \t]*)", lines[d["decl_line"]]) - indent = indent_match.group(1) if indent_match else "" - insertions[d["start_line"]] = f"{indent}{NEEDED_COMMENT}" - if not insertions: - return text - out: list[str] = [] - for i, line in enumerate(lines): - if i in insertions: - out.append(insertions[i]) - out.append(line) - return "\n".join(out) - - -# --------------------------------------------------------------------- file parsing - - -LICENSE_HEADER_RE = re.compile(r"\A\s*(/-.*?-/)", re.DOTALL) -EXPOSE_RE = re.compile(r"^\s*@\[expose\]\s+public\s+section\s*$") -MODULE_RE = re.compile(r"^\s*module\s*$") - - -def parse_all_lean(text: str) -> dict: - """Return ``{license, header_lines, body_lines, body_start_line}``. - - ``license`` is the leading ``/- … -/`` block (without trailing newlines) - or empty. ``header_lines`` is everything from start through the - ``@[expose] public section`` line. ``body_lines`` is everything after. - """ - m = LICENSE_HEADER_RE.match(text) - license_header = m.group(1) if m else "" - - lines = text.split("\n") - expose_idx = None - for i, line in enumerate(lines): - if EXPOSE_RE.match(line): - expose_idx = i - break - - if expose_idx is None: - return { - "license": license_header, - "header_lines": lines, - "body_lines": [], - "body_start_line": len(lines), - } - return { - "license": license_header, - "header_lines": lines[: expose_idx + 1], - "body_lines": lines[expose_idx + 1 :], - "body_start_line": expose_idx + 1, - } - - -# --------------------------------------------------------------------- copy - - -def copy_lean_tree(source: Path, target: Path) -> None: - """Copy the entire ``source`` tree to ``target``, replacing ``target``.""" - if target.exists(): - shutil.rmtree(target) - shutil.copytree(source, target) - - -def project_folder_names(root: Path) -> set[str]: - """Names of subdirectories of ``root`` that contain an ``All.lean``.""" - return { - p.name - for p in root.iterdir() - if p.is_dir() and p.name not in UNTOUCHED_SUBDIRS and (p / "All.lean").is_file() - } - - -def is_project_file(file_path: Path, variant_root: Path) -> bool: - """True if ``file_path`` is inside a project folder (not Mathlib/Util).""" - try: - rel = file_path.relative_to(variant_root) - except ValueError: - return False - if not rel.parts: - return False - return rel.parts[0] not in UNTOUCHED_SUBDIRS - - -# --------------------------------------------------------------------- index - - -def write_index(project_root: Path, variant_dir: Path, variant: str) -> Path: - target_prefix = f"LiveLeanTriathlon{variant}" - lean_files = sorted(variant_dir.rglob("*.lean")) - lines = ["module -- shake: keep-all", ""] - for f in lean_files: - rel = f.relative_to(variant_dir).with_suffix("") - module = ".".join(rel.parts) - lines.append(f"public import {target_prefix}.{module}") - index_path = project_root / f"{target_prefix}.lean" - index_path.write_text("\n".join(lines) + "\n", encoding="utf-8") - return index_path - - -# --------------------------------------------------------------------- Sorry - - -def build_sorry(project_root: Path) -> None: - source = project_root / "LiveLeanTriathlon" - target = project_root / "LiveLeanTriathlonSorry" - log_message("=== building Sorry ===") - copy_lean_tree(source, target) - - mapping = {"LiveLeanTriathlon": "LiveLeanTriathlonSorry"} - - for f in sorted(target.rglob("*.lean")): - text = f.read_text(encoding="utf-8") - text = transform_imports(text, mapping) - if is_project_file(f, target) and f.name == "All.lean": - text = sorry_fy(text) - f.write_text(text, encoding="utf-8") - - write_index(project_root, target, "Sorry") - log_message(f"wrote {target}") - - -# --------------------------------------------------------------------- Easy - - -DECL_KEYS_ALL = ( - "theorem", - "lemma", - "def", - "abbrev", - "structure", - "class", - "instance", - "inductive", -) - - -def _final_theorem_decl(body: list[str]) -> dict | None: - """Find the last ``theorem`` declaration in ``body``.""" - final = None - for d in find_all_decls("\n".join(body), keys=("theorem",)): - final = d - return final - - -def filter_drop_final_theorem(body: list[str]) -> list[str]: - """Return ``body`` with the final-theorem declaration block removed.""" - final = _final_theorem_decl(body) - if final is None: - return body - drop = set(range(final["start_line"], final["end_line"] + 1)) - return _collapse_blank_runs([line for i, line in enumerate(body) if i not in drop]) - - -def filter_keep_scaffolding_and_final( - body: list[str], - keep_keys: tuple[str, ...], - keep_needed_for_def: bool = False, -) -> list[str]: - """Return a copy of ``body`` keeping only: - - the final ``theorem`` declaration block; - - declaration blocks whose key is in ``keep_keys`` (e.g. defs/structures); - - lemmas annotated with ``-- Needed for def`` (when - ``keep_needed_for_def=True``); - - non-declaration scaffolding (sections, namespaces, opens, set_options, - variables, etc.). - - Other declaration blocks (lemmas, non-final theorems, and defs not in - ``keep_keys``) are removed along with their decorations. - """ - decls = find_all_decls("\n".join(body), keys=DECL_KEYS_ALL) - theorem_decls = [d for d in decls if d["key"] == "theorem"] - final = theorem_decls[-1] if theorem_decls else None - drop = set() - for d in decls: - if d is final: - continue - if d["key"] in keep_keys: - continue - if ( - keep_needed_for_def - and d["key"] in ("lemma", "theorem") - and has_needed_for_def_comment(body, d) - ): - continue - drop.update(range(d["start_line"], d["end_line"] + 1)) - return _collapse_blank_runs([line for i, line in enumerate(body) if i not in drop]) - - -def _scaffolding_header_lines(license_block: str, imports: list[str]) -> list[str]: - out: list[str] = [] - if license_block: - out.append(license_block) - out.append("") - out.append("module") - out.append("") - out.extend(imports) - out.append("") - out.append("@[expose] public section") - out.append("") - return out - - -def split_for_easy(all_text: str, parent_module: str) -> tuple[str, str]: - """Split ``all_text`` (an ``All.lean`` body) into Background and MainTheorem - file contents. - - Background.lean keeps everything from ``All.lean`` minus the final theorem - block. MainTheorem.lean keeps the section/namespace/open scaffolding and - the final theorem only (so the theorem compiles in the same namespace - context it had in ``All.lean``); it imports ``parent_module`` to pick up - the definitions and lemmas from Background. - """ - parsed = parse_all_lean(all_text) - body = parsed["body_lines"] - - bg_body = filter_drop_final_theorem(body) - background_text = "\n".join(parsed["header_lines"] + bg_body) - if not background_text.endswith("\n"): - background_text += "\n" - - # MainTheorem keeps scaffolding + final theorem; defs/lemmas come from Background. - main_body = filter_keep_scaffolding_and_final(body, keep_keys=()) - main_lines = _scaffolding_header_lines( - parsed["license"], [f"public import {parent_module}"] - ) - main_lines.extend(main_body) - main_text = "\n".join(main_lines) - if not main_text.endswith("\n"): - main_text += "\n" - return background_text, main_text - - -def _collapse_blank_runs(lines: list[str]) -> list[str]: - out: list[str] = [] - blank_run = 0 - for line in lines: - if not line.strip(): - blank_run += 1 - if blank_run <= 1: - out.append(line) - else: - blank_run = 0 - out.append(line) - while out and not out[-1].strip(): - out.pop() - return out - - -def build_easy(project_root: Path) -> None: - sorry_dir = project_root / "LiveLeanTriathlonSorry" - target = project_root / "LiveLeanTriathlonEasy" - if not sorry_dir.is_dir(): - raise RuntimeError(f"{sorry_dir} not found; run with --variant Sorry first") - - log_message("=== building Easy ===") - copy_lean_tree(sorry_dir, target) - - mapping = {"LiveLeanTriathlonSorry": "LiveLeanTriathlonEasy"} - project_folders = project_folder_names(target) - - for f in sorted(target.rglob("*.lean")): - text = f.read_text(encoding="utf-8") - text = transform_imports(text, mapping) - f.write_text(text, encoding="utf-8") - - for folder in sorted(target.iterdir()): - if not folder.is_dir() or folder.name in UNTOUCHED_SUBDIRS: - continue - all_lean = folder / "All.lean" - if not all_lean.is_file(): - continue - - all_text = all_lean.read_text(encoding="utf-8") - all_text = rewrite_all_to_main(all_text, "Easy", project_folders) - - bg_text, main_text = split_for_easy( - all_text, f"LiveLeanTriathlonEasy.{folder.name}.Background" - ) - (folder / "Background.lean").write_text(bg_text, encoding="utf-8") - (folder / "MainTheorem.lean").write_text(main_text, encoding="utf-8") - all_lean.unlink() - - write_index(project_root, target, "Easy") - log_message(f"wrote {target}") - - -# --------------------------------------------------------------------- Hard - - -def strip_non_final_theorems_lemmas(text: str) -> str: - """Remove all theorem and lemma blocks except the final ``theorem``; - preserve definitions, lemmas annotated ``-- Needed for def``, and - section/namespace/open scaffolding so the kept theorem compiles in the - same context.""" - parsed = parse_all_lean(text) - body = parsed["body_lines"] - new_body = filter_keep_scaffolding_and_final( - body, - keep_keys=("def", "abbrev", "structure", "class", "instance", "inductive"), - keep_needed_for_def=True, - ) - return "\n".join(parsed["header_lines"] + new_body) + "\n" - - -def build_hard(project_root: Path) -> None: - sorry_dir = project_root / "LiveLeanTriathlonSorry" - target = project_root / "LiveLeanTriathlonHard" - if not sorry_dir.is_dir(): - raise RuntimeError(f"{sorry_dir} not found; run with --variant Sorry first") - - log_message("=== building Hard ===") - copy_lean_tree(sorry_dir, target) - - mapping = {"LiveLeanTriathlonSorry": "LiveLeanTriathlonHard"} - project_folders = project_folder_names(target) - - for f in sorted(target.rglob("*.lean")): - text = f.read_text(encoding="utf-8") - text = transform_imports(text, mapping) - f.write_text(text, encoding="utf-8") - - for folder in sorted(target.iterdir()): - if not folder.is_dir() or folder.name in UNTOUCHED_SUBDIRS: - continue - all_lean = folder / "All.lean" - if not all_lean.is_file(): - continue - all_text = all_lean.read_text(encoding="utf-8") - all_text = rewrite_all_to_main(all_text, "Hard", project_folders) - main_text = strip_non_final_theorems_lemmas(all_text) - (folder / "MainTheorem.lean").write_text(main_text, encoding="utf-8") - all_lean.unlink() - - write_index(project_root, target, "Hard") - log_message(f"wrote {target}") - - -# --------------------------------------------------------------------- Autoformalization - - -def _camel_to_kebab(s: str) -> str: - out: list[str] = [] - for i, c in enumerate(s): - if c.isupper() and i > 0: - out.append("-") - out.append(c.lower()) - return "".join(out) - - -def build_autoformalization(project_root: Path) -> None: - sorry_dir = project_root / "LiveLeanTriathlonSorry" - target = project_root / "LiveLeanTriathlonAutoformalization" - tex_dir = project_root / "blueprint" / "src" / "theorems" - if not sorry_dir.is_dir(): - raise RuntimeError(f"{sorry_dir} not found; run with --variant Sorry first") - - log_message("=== building Autoformalization ===") - copy_lean_tree(sorry_dir, target) - - mapping = {"LiveLeanTriathlonSorry": "LiveLeanTriathlonAutoformalization"} - project_folders = project_folder_names(target) - - for f in sorted(target.rglob("*.lean")): - text = f.read_text(encoding="utf-8") - text = transform_imports(text, mapping) - f.write_text(text, encoding="utf-8") - - missing_tex: list[str] = [] - for folder in sorted(target.iterdir()): - if not folder.is_dir() or folder.name in UNTOUCHED_SUBDIRS: - continue - all_lean = folder / "All.lean" - if not all_lean.is_file(): - continue - all_text = all_lean.read_text(encoding="utf-8") - all_text = rewrite_all_to_main(all_text, "Autoformalization", project_folders) - main_text = strip_non_final_theorems_lemmas(all_text) - (folder / "MainTheorem.lean").write_text(main_text, encoding="utf-8") - all_lean.unlink() - - stem = _camel_to_kebab(folder.name) - tex_src = tex_dir / f"{stem}.tex" - if tex_src.is_file(): - shutil.copy2(tex_src, folder / f"{stem}.tex") - else: - missing_tex.append(folder.name) - - write_index(project_root, target, "Autoformalization") - if missing_tex: - print( - f"Warning: no .tex found for {len(missing_tex)} folders: " - + ", ".join(missing_tex) - ) - log_message(f"wrote {target}") - - -# --------------------------------------------------------------------- main - - -def main() -> None: - ap = argparse.ArgumentParser( - description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter - ) - ap.add_argument( - "--variant", - choices=[*VARIANTS, "all"], - default="all", - help="Which variant to generate (default: all).", - ) - args = ap.parse_args() - - project_root = find_project_root() - targets = VARIANTS if args.variant == "all" else [args.variant] - - builders = { - "Sorry": build_sorry, - "Easy": build_easy, - "Hard": build_hard, - "Autoformalization": build_autoformalization, - } - for variant in targets: - builders[variant](project_root) - print(f"Built {variant}") - - -if __name__ == "__main__": - main() diff --git a/scripts/create_sorries/create_statement_jsonl.py b/scripts/create_sorries/create_statement_jsonl.py deleted file mode 100644 index 6d0d0a1..0000000 --- a/scripts/create_sorries/create_statement_jsonl.py +++ /dev/null @@ -1,597 +0,0 @@ -""" -Build benchmark JSONL files from the LiveLeanTriathlon tree. - -Three outputs are produced in this script's directory: - - statement.jsonl — "easy mode" — one row per `theorem`/`lemma` - in the project. ``code`` is the file content - from the top through the target declaration, - with every preceding theorem/lemma's proof - replaced by ``sorry``. Earlier declarations - stay as ``lemma X ... := by sorry``, so the - agent can either prove or treat them as - black-box givens. When the target's file - imports project-local sibling files (e.g. - ``MainTheorem.lean`` importing - ``BackgroundLemmas.lean``), their content - with proofs sorry'd is included in an - ``imported_file`` field. - - statements_hard.jsonl — "hard mode" — one row per ``@[AMS ...]``-tagged - theorem. ``code`` contains imports, opens, - any earlier AMS-tagged theorems in the same - file as ``axiom``s, and the target as - ``theorem ... := by sorry``. No sublemmas; - the agent must re-prove the main result. - - statements_autoformalization.jsonl — "autoformalization mode" — one row per - ``@[AMS ...]``-tagged theorem. ``code`` - contains only imports, opens, and the target - theorem (no preceding axioms or lemmas). - Adds ``title``, ``informal_statement``, and - ``informal_proof`` fields. ``title`` and - ``informal_statement`` come from the - surrounding ``\\begin{theorem}…\\end{theorem}`` - environment in the corresponding - ``blueprint/src/theorems/*.tex`` file (located - by ``\\lean{}``). ``informal_proof`` - contains the full text of that ``.tex`` file, - so the agent has the chapter's worth of - context, not just the proof prose for one - declaration. - -Easy and hard rows use the schema:: - - {"project_name": str, "name": str, "type": "theorem"|"lemma", "code": str} - -Autoformalization rows extend it with ``title``, ``informal_statement``, and -``informal_proof``. - -``code`` strings are normalized to be self-contained: project-specific imports -are collapsed to ``import Mathlib``, ``module`` / ``@[expose] public section`` -directives and project attributes (``@[AMS ...]``, ``@[blueprint ...]``) are -stripped. -""" - -import json -import re -from pathlib import Path - -from scripts.create_sorries.create_sorries import ( - EMPTY_BLUEPRINT_FIELD_RE, - NEWLINE_KEYS, - SHARED_SUBDIRS, - find_project_root, -) -from scripts.create_sorries.extract_sublemmas import ( - LeanCodeParser, - add_newlines_before_keys, - create_proof_with_sorries, -) - -PROJECT_ATTRS = ("@[AMS", "@[blueprint") -IMPORT_LINE_RE = re.compile(r"^\s*(public\s+)?import\s+\S") -MODULE_DIRECTIVE_RE = re.compile(r"^\s*module(\s|$)") -EXPOSE_SECTION_RE = re.compile(r"^\s*@\[expose\]\s+public\s+section\s*$") - - -def _strip_project_attrs(text: str) -> str: - """Strip ``@[AMS ...]`` and ``@[blueprint ...]`` decorators. - - Multi-line, with nested brackets, embedded docstrings, and string literals. - Other attributes (``@[simp]``, ``@[ext]`` …) are left untouched. - """ - out: list[str] = [] - i = 0 - n = len(text) - while i < n: - if any(text.startswith(prefix, i) for prefix in PROJECT_ATTRS): - j = i + 2 - depth = 1 - while j < n and depth > 0: - c = text[j] - if c == '"': - j += 1 - while j < n and text[j] != '"': - if text[j] == "\\" and j + 1 < n: - j += 2 - else: - j += 1 - j = min(j + 1, n) - continue - if text.startswith("/--", j): - j += 3 - ddepth = 1 - while j < n and ddepth > 0: - if text.startswith("/-", j): - ddepth += 1 - j += 2 - elif text.startswith("-/", j): - ddepth -= 1 - j += 2 - else: - j += 1 - continue - if c == "[": - depth += 1 - elif c == "]": - depth -= 1 - j += 1 - while j < n and text[j] in " \t": - j += 1 - if j < n and text[j] == "\n": - j += 1 - i = j - continue - out.append(text[i]) - i += 1 - return "".join(out) - - -def _replace_imports_with_mathlib(text: str) -> str: - """Collapse every ``import`` / ``public import`` line to a single ``import Mathlib``.""" - lines = text.split("\n") - out: list[str] = [] - inserted = False - for line in lines: - if IMPORT_LINE_RE.match(line): - if not inserted: - out.append("import Mathlib") - inserted = True - continue - out.append(line) - if not inserted: - out = ["import Mathlib", ""] + out - return "\n".join(out) - - -def _strip_module_mode(text: str) -> str: - """Remove ``module`` directives and ``@[expose] public section`` lines.""" - lines = text.split("\n") - out: list[str] = [] - for line in lines: - if MODULE_DIRECTIVE_RE.match(line): - continue - if EXPOSE_SECTION_RE.match(line): - continue - out.append(line) - return "\n".join(out) - - -def _normalize(text: str) -> str: - text = _strip_project_attrs(text) - text = _strip_module_mode(text) - text = _replace_imports_with_mathlib(text) - text = EMPTY_BLUEPRINT_FIELD_RE.sub("", text) - text = add_newlines_before_keys(text, keys=NEWLINE_KEYS) - return text - - -PROJECT_IMPORT_RE = re.compile( - r"^\s*(?:public\s+)?import\s+(LiveLeanTriathlon\.[\w.]+)" -) - - -def _module_to_path(module: str, src_root: Path) -> Path | None: - """Map ``LiveLeanTriathlon.Foo.Bar`` to ``/Foo/Bar.lean`` (or - ``Foo/Bar/Foo/Bar.lean`` for nested layouts). Returns ``None`` if the file - doesn't exist. - """ - parts = module.split(".") - if not parts or parts[0] != "LiveLeanTriathlon": - return None - rel = Path(*parts[1:]).with_suffix(".lean") - candidate = src_root / rel - return candidate if candidate.exists() else None - - -def _collect_project_imports(file_path: Path, src_root: Path) -> list[Path]: - """Return the transitive set of project-local imports of ``file_path``, - restricted to files in the *same project subdirectory* (same first path - component under ``LiveLeanTriathlon/``). Returned in topological order with - dependencies first. - """ - rel = file_path.relative_to(src_root) - if not rel.parts: - return [] - project = rel.parts[0] - project_prefix = f"LiveLeanTriathlon.{project}." - - visited: dict[Path, bool] = {} - order: list[Path] = [] - - def dfs(path: Path) -> None: - if path in visited: - return - visited[path] = True - for line in path.read_text(encoding="utf-8").splitlines(): - m = PROJECT_IMPORT_RE.match(line) - if not m: - continue - module = m.group(1) - if not module.startswith(project_prefix): - continue - dep = _module_to_path(module, src_root) - if dep is None or dep == file_path or dep == path: - continue - dfs(dep) - if path != file_path: - order.append(path) - - dfs(file_path) - return order - - -def _format_imported_file(text: str) -> str: - """Strip imports/module/expose/project-attr lines and replace every proof - with ``sorry``, leaving the surrounding declarations and comments intact. - """ - text = create_proof_with_sorries(text, keys=["theorem", "lemma"]) - text = _strip_project_attrs(text) - text = _strip_module_mode(text) - lines = [ln for ln in text.split("\n") if not IMPORT_LINE_RE.match(ln)] - text = "\n".join(lines) - text = EMPTY_BLUEPRINT_FIELD_RE.sub("", text) - return text.strip("\n") - - -def _build_imported_file(file_path: Path, src_root: Path) -> str: - """Concatenate the formatted contents of every transitive project-local - dependency of ``file_path``, separated by ``-- File: `` markers. - Returns ``""`` when there are no project-local imports. - """ - deps = _collect_project_imports(file_path, src_root) - if not deps: - return "" - chunks: list[str] = [] - for dep in deps: - rel = dep.relative_to(src_root).with_suffix("") - module = "LiveLeanTriathlon." + ".".join(rel.parts) - body = _format_imported_file(dep.read_text(encoding="utf-8")) - if body: - chunks.append(f"-- File: {module}\n{body}") - return "\n\n".join(chunks) - - -def build_easy_entries( - text: str, - project_name: str, - file_path: Path | None = None, - src_root: Path | None = None, -) -> list[dict]: - """One entry per theorem/lemma in ``text``. - - When ``file_path`` and ``src_root`` are supplied, every entry from a file - that imports project-local siblings (e.g. ``MainTheorem.lean`` importing - ``BackgroundLemmas.lean``) gets an ``imported_file`` field carrying those - siblings' content with proofs replaced by ``sorry``. - """ - parser = LeanCodeParser(text) - blocks = parser.extract_all_blocks(keys=["theorem", "lemma"], allow_overlap=False) - imported = "" - if file_path is not None and src_root is not None: - imported = _build_imported_file(file_path, src_root) - entries: list[dict] = [] - for block in blocks: - snippet = "\n".join(parser.cleaned_lines[: block["end"] + 1]) - snippet = create_proof_with_sorries(snippet, keys=["theorem", "lemma"]) - snippet = _normalize(snippet) - entry: dict = { - "project_name": project_name, - "name": block["info"]["name"], - "type": block["key"], - "code": snippet, - } - if imported: - entry["imported_file"] = imported - entries.append(entry) - return entries - - -def build_hard_entries(text: str, project_name: str) -> list[dict]: - """One entry per ``@[AMS]``-tagged theorem in ``text``. - - Earlier AMS-tagged theorems in the same file appear as ``axiom``s; sublemmas - are dropped entirely. - """ - parser = LeanCodeParser(text) - blocks = parser.extract_all_blocks(keys=["theorem", "lemma"], allow_overlap=False) - - ams_blocks: list[dict] = [] - prev_end = -1 - for block in blocks: - gap = parser.cleaned_lines[prev_end + 1 : block["start"]] - if any("@[AMS" in line for line in gap): - ams_blocks.append(block) - prev_end = block["end"] - - if not ams_blocks: - return [] - - headers = parser.extract_headers() - - entries: list[dict] = [] - for i, target in enumerate(ams_blocks): - parts: list[str] = [] - if headers["set_option_lines"]: - parts.extend(headers["set_option_lines"]) - parts.append("") - if headers["open_lines"]: - parts.extend(headers["open_lines"]) - parts.append("") - for prev in ams_blocks[:i]: - parts.append(parser.block_to_axiom(prev)) - parts.append("") - target_str = "\n".join( - parser.cleaned_lines[target["start"] : target["end"] + 1] - ) - target_str = create_proof_with_sorries(target_str, keys=["theorem", "lemma"]) - parts.append(target_str) - - code = _normalize("\n".join(parts)) - entries.append( - { - "project_name": project_name, - "name": target["info"]["name"], - "type": target["key"], - "code": code, - } - ) - return entries - - -AMS_ATTR_RE = re.compile(r"@\[(?:[^\[\]]*?,\s*)?AMS\b") -NAMESPACE_OPEN_RE = re.compile(r"^\s*namespace\s+([\w.]+)\s*$") -NAMESPACE_END_RE = re.compile(r"^\s*end\s+([\w.]+)\s*$") -LEAN_REF_RE = re.compile(r"\\lean\{([^}]+)\}") - - -def _build_name_to_tex(tex_dir: Path) -> dict[str, Path]: - """Map every name appearing in ``\\lean{...}`` to its containing ``.tex`` file. - - Comma-separated forms like ``\\lean{foo, bar}`` are split so each name maps - individually. Last write wins on collisions; collisions are rare and noted - in the audit. - """ - name_to_tex: dict[str, Path] = {} - for tex in sorted(tex_dir.rglob("*.tex")): - text = tex.read_text(encoding="utf-8") - for m in LEAN_REF_RE.finditer(text): - for raw in m.group(1).split(","): - bare = raw.strip() - if bare: - name_to_tex[bare] = tex - return name_to_tex - - -def _resolve_tex( - name: str, namespaces: list[str], name_to_tex: dict[str, Path] -) -> Path | None: - """Look up the .tex file for a Lean declaration. - - Tries the fully-qualified name (with current namespace prefix), then the - bare name. Falls back to a suffix match against any registered key, which - catches cases where the .tex labels a theorem with a different namespace - prefix than the surrounding Lean ``namespace`` block. - """ - if namespaces: - full = ".".join([*namespaces, name]) - if full in name_to_tex: - return name_to_tex[full] - if name in name_to_tex: - return name_to_tex[name] - suffix = "." + name - for key, path in name_to_tex.items(): - if key.endswith(suffix): - return path - return None - - -def _extract_env(tex: str, env: str, lean_name: str) -> str | None: - """Return the body of the ``\\begin{}…\\end{}`` block whose - ``\\lean{...}`` argument matches ``lean_name``. Strips ``\\label``, - ``\\lean``, and ``\\uses`` metadata commands. Returns ``None`` if no such - block exists. - """ - pattern = re.compile( - rf"\\begin\{{{env}\}}(?:\[[^\]]*\])?(.*?)\\end\{{{env}\}}", - re.DOTALL, - ) - for m in pattern.finditer(tex): - body = m.group(1) - if any( - ref.strip() == lean_name or lean_name in (s.strip() for s in ref.split(",")) - for ref in LEAN_REF_RE.findall(body) - ): - cleaned = re.sub( - r"^[ \t]*\\(?:label|lean|uses)\{[^}]*\}[ \t]*\r?\n", - "", - body, - flags=re.MULTILINE, - ) - return cleaned.strip() - return None - - -def _extract_title(tex: str, env: str, lean_name: str, fallback_chapter: bool) -> str: - """Optional ``\\begin{theorem}[Title]`` argument, falling back to the chapter - title at the top of the file. - """ - pattern = re.compile( - rf"\\begin\{{{env}\}}\[([^\]]*)\](.*?)\\end\{{{env}\}}", - re.DOTALL, - ) - for m in pattern.finditer(tex): - body = m.group(2) - if any( - ref.strip() == lean_name or lean_name in (s.strip() for s in ref.split(",")) - for ref in LEAN_REF_RE.findall(body) - ): - return m.group(1).strip() - if fallback_chapter: - m = re.search(r"\\chapter\{([^}]*)\}", tex) - if m: - return m.group(1).strip() - return "" - - -def build_autoformalization_entries( - text: str, - project_name: str, - name_to_tex: dict[str, Path], -) -> list[dict]: - """One entry per ``@[AMS ...]``-tagged theorem in ``text``. - - ``code`` contains only imports, opens, and the target theorem with a - ``sorry`` proof. ``title`` / ``informal_statement`` come from the matching - ``\\begin{theorem}…\\end{theorem}`` environment in - ``blueprint/src/theorems/.tex`` (located via ``\\lean{}``). - ``informal_proof`` is the entire ``.tex`` file content, so the agent has the - chapter-level context surrounding the target theorem. - """ - parser = LeanCodeParser(text) - blocks = parser.extract_all_blocks(keys=["theorem", "lemma"], allow_overlap=False) - if not blocks: - return [] - headers = parser.extract_headers() - - namespaces: list[str] = [] - cleaned = parser.cleaned_lines - namespace_at_line: list[list[str]] = [[] for _ in cleaned] - current: list[str] = [] - for idx, line in enumerate(cleaned): - m_open = NAMESPACE_OPEN_RE.match(line) - if m_open: - current.append(m_open.group(1)) - m_close = NAMESPACE_END_RE.match(line) - if m_close and current and current[-1] == m_close.group(1): - current.pop() - namespace_at_line[idx] = list(current) - - ams_blocks: list[dict] = [] - prev_end = -1 - for block in blocks: - gap = cleaned[prev_end + 1 : block["start"]] - if any(AMS_ATTR_RE.search(line) for line in gap): - ams_blocks.append(block) - prev_end = block["end"] - - if not ams_blocks: - return [] - - entries: list[dict] = [] - for target in ams_blocks: - name = target["info"]["name"] - if not name or name == "this": - continue - ns = ( - namespace_at_line[target["start"]] - if target["start"] < len(namespace_at_line) - else [] - ) - tex_path = _resolve_tex(name, ns, name_to_tex) - full_name = ".".join([*ns, name]) if ns else name - - if tex_path is not None: - tex_text = tex_path.read_text(encoding="utf-8") - title = ( - _extract_title(tex_text, "theorem", name, fallback_chapter=False) - or _extract_title( - tex_text, "theorem", full_name, fallback_chapter=False - ) - or _extract_title(tex_text, "lemma", name, fallback_chapter=False) - or _extract_title(tex_text, "lemma", full_name, fallback_chapter=False) - or _extract_title(tex_text, "theorem", name, fallback_chapter=True) - ) - informal_statement = ( - _extract_env(tex_text, "theorem", name) - or _extract_env(tex_text, "theorem", full_name) - or _extract_env(tex_text, "lemma", name) - or _extract_env(tex_text, "lemma", full_name) - or "" - ) - informal_proof = tex_text - else: - title = "" - informal_statement = "" - informal_proof = "" - - target_str = "\n".join(cleaned[target["start"] : target["end"] + 1]) - target_str = create_proof_with_sorries(target_str, keys=["theorem", "lemma"]) - - parts: list[str] = [] - if headers["set_option_lines"]: - parts.extend(headers["set_option_lines"]) - parts.append("") - if headers["open_lines"]: - parts.extend(headers["open_lines"]) - parts.append("") - parts.append(target_str) - code = _normalize("\n".join(parts)) - - entries.append( - { - "project_name": project_name, - "name": name, - "type": target["key"], - "title": title, - "informal_statement": informal_statement, - "informal_proof": informal_proof, - "code": code, - } - ) - return entries - - -def iter_lean_files(project_root: Path): - """Yield every Lean file under ``LiveLeanTriathlon/`` excluding shared subdirs.""" - src = project_root / "LiveLeanTriathlon" - for f in sorted(src.rglob("*.lean")): - rel = f.relative_to(src) - if rel.parts and rel.parts[0] in SHARED_SUBDIRS: - continue - yield f - - -def write_jsonl(path: Path, entries: list[dict]) -> None: - with open(path, "w", encoding="utf-8") as f: - for entry in entries: - f.write(json.dumps(entry, ensure_ascii=False) + "\n") - - -def main(): - project_root = find_project_root() - out_dir = Path(__file__).parent - name_to_tex = _build_name_to_tex(project_root / "blueprint" / "src" / "theorems") - - easy_entries: list[dict] = [] - hard_entries: list[dict] = [] - auto_entries: list[dict] = [] - - src_root = project_root / "LiveLeanTriathlon" - for f in iter_lean_files(project_root): - text = f.read_text(encoding="utf-8") - rel_parts = f.relative_to(src_root).parts - project_name = rel_parts[0] if rel_parts else f.stem - easy_entries.extend( - build_easy_entries(text, project_name, file_path=f, src_root=src_root) - ) - hard_entries.extend(build_hard_entries(text, project_name)) - auto_entries.extend( - build_autoformalization_entries(text, project_name, name_to_tex) - ) - - easy_path = out_dir / "statement.jsonl" - hard_path = out_dir / "statements_hard.jsonl" - auto_path = out_dir / "statements_autoformalization.jsonl" - write_jsonl(easy_path, easy_entries) - write_jsonl(hard_path, hard_entries) - write_jsonl(auto_path, auto_entries) - - print(f"Wrote {easy_path} ({len(easy_entries)} entries)") - print(f"Wrote {hard_path} ({len(hard_entries)} entries)") - print(f"Wrote {auto_path} ({len(auto_entries)} entries)") - - -if __name__ == "__main__": - main() diff --git a/scripts/create_sorries/extract_sublemmas.py b/scripts/create_sorries/extract_sublemmas.py deleted file mode 100644 index c245420..0000000 --- a/scripts/create_sorries/extract_sublemmas.py +++ /dev/null @@ -1,739 +0,0 @@ -import re -from copy import copy -from typing import Any - -DOT_KEYS = [".", "·"] -DOT_KEYS_TUPLE = (".", "·") - -# Lean 4 modifiers that may appear before a `theorem` / `lemma` / `def` / etc. keyword. -# Detected so the parser still recognizes the declaration even when prefixed. -DECL_MODIFIERS = frozenset( - {"private", "protected", "noncomputable", "partial", "unsafe", "@[expose]"} -) - - -# ==================================================== -# parser -# ==================================================== -class LeanCodeParser: - def __init__(self, code: str): - self.original_code = code - self.original_lines = code.splitlines() - self.cleaned_lines = self.strip_comments_and_blank_lines(code) - self.cleaned_code = "\n".join(self.cleaned_lines) - - def formatting(self, code: str, keys: list[str] | None = None) -> str: - """Format the code by adding spaces around operators.""" - if keys is None: - keys = [":="] - ret = re.sub(r":=", " := ", code, flags=re.DOTALL) - ret = re.sub(r" :=", " :=", ret, flags=re.DOTALL) - ret = re.sub(r":= ", ":= ", ret, flags=re.DOTALL) - ret = re.sub(r":= \n", ":=\n", ret, flags=re.DOTALL) - return ret # noqa RET504 - - def strip_brackets(self, code: str) -> str: - pattern = r"\([^()]*?\)|{[^{}]*?}|\[[^\[\]]*?\]" - return re.sub(pattern, "", code) - - @staticmethod - def _strip_comments(code: str) -> str: - """Strip ``/- ... -/`` block comments and ``-- ...`` line comments. - - Preserves ``/-- ... -/`` docstrings and string literals so that - ``--`` inside ``"foo--bar"`` or inside a docstring is left intact. - Block comments may nest (Lean syntax). String literals support ``\\`` - escapes. - """ - out: list[str] = [] - i = 0 - n = len(code) - while i < n: - c = code[i] - # String literal - if c == '"': - j = i + 1 - while j < n: - if code[j] == "\\" and j + 1 < n: - j += 2 - continue - if code[j] == '"': - j += 1 - break - j += 1 - out.append(code[i:j]) - i = j - continue - # Docstring /-- ... -/ - if c == "/" and code.startswith("/--", i): - depth = 1 - j = i + 3 - while j < n and depth > 0: - if code.startswith("/-", j): - depth += 1 - j += 2 - elif code.startswith("-/", j): - depth -= 1 - j += 2 - else: - j += 1 - out.append(code[i:j]) - i = j - continue - # Block comment /- ... -/ - if c == "/" and code.startswith("/-", i): - depth = 1 - j = i + 2 - while j < n and depth > 0: - if code.startswith("/-", j): - depth += 1 - j += 2 - elif code.startswith("-/", j): - depth -= 1 - j += 2 - else: - j += 1 - i = j - continue - # Line comment -- ... - if c == "-" and code.startswith("--", i): - j = code.find("\n", i) - if j == -1: - break - i = j # keep the newline - continue - out.append(c) - i += 1 - return "".join(out) - - def strip_comments_and_blank_lines(self, code: str) -> list[str]: - cleaned = [] - tmp_code = self._strip_comments(code) - tmp_code = self.formatting(tmp_code) - for line in tmp_code.splitlines(): - stripped_line = line.rstrip() - if not stripped_line.strip(): - continue - noind_stripped = stripped_line.lstrip() - if noind_stripped.startswith((". ", "· ")): - indent = len(stripped_line) - len(noind_stripped) - dot_line = " " * indent + "." - rest_line = " " * (indent + 2) + noind_stripped[2:] - cleaned.append(dot_line) - if rest_line.strip(): - cleaned.append(rest_line) - else: - cleaned.append(stripped_line) - return cleaned - - def get_indent(self, line: str) -> int: - return len(line) - len(line.lstrip(" ")) - - def extract_headers(self) -> dict: - """ - each import and opens should only in one line - - out: - { - "import_list": ["Mathlib", "Aesop"], - "open_list": ["Nat", "Real", "Polynomial"], - "set_option_list": ["set_option maxHeartbeats 0"] - } - """ - import_list = [] - open_list = [] - set_option_list = [] - import_lines = [] - open_lines = [] - set_option_lines = [] - for line in self.cleaned_lines: - tokens = line.split() - key = tokens[0] - if key == "import": - import_list.extend( - copy(tokens[1:]), - ) # Use extend instead of append in loop - import_lines.append(line) - elif key == "open": - open_list.extend( - copy(tokens[1:]), - ) # Use extend instead of append in loop - open_lines.append(line) - elif key == "set_option": - set_option_list.append(line) - set_option_lines.append(line) - if "scoped" in open_list: - open_list.remove("scoped") - return { - "import_list": import_list, - "open_list": open_list, - "set_option_list": set_option_list, - "import_lines": import_lines, - "open_lines": open_lines, - "set_option_lines": set_option_lines, - } - - def extract_other( - self, - keys: list[str] | None = None, - except_line_prefix_list: list[str] | None = None, - ) -> str: - if keys is None: - keys = ["theorem", "lemma"] - - if except_line_prefix_list is None: - except_line_prefix_list = ["import", "open", "set_option"] - - blocks = self.extract_all_blocks( - keys=keys, - allow_overlap=False, - ) - - # except key blocks - if not blocks: - selected_lines = self.cleaned_lines - else: - in_block_ranges = sorted( - [(block["start"], block["end"]) for block in blocks] - ) - selected_lines = [] - current_bid = 0 - for lid, line in enumerate(self.cleaned_lines): - while ( - current_bid < len(in_block_ranges) - and lid > in_block_ranges[current_bid][1] - ): - current_bid += 1 - - is_in_block = False - if current_bid < len(in_block_ranges): - block_start, block_end = in_block_ranges[current_bid] - if block_start <= lid <= block_end: - is_in_block = True - if not is_in_block: - selected_lines.append(line) - - # except lines with specific prefix - return "\n".join( - [ - line - for line in selected_lines - if not any( - line.strip().startswith(prefix) - for prefix in except_line_prefix_list - ) - ], - ).strip() - - @staticmethod - def extract_name_from_code(code: str, key: str, default="this") -> str | None: - """ - examples: - 'key v1 : xxx' -> 'v1' - 'key : xxx' -> 'this' - 'key := xxx' -> 'this' - 'key t1 (x : T) : ...' -> 't1' - 'key (x : T) : ...' -> 'this' - 'private key v1 : xxx' -> 'v1' (modifiers stripped) - """ - code = code.strip() - while True: - tokens = code.split(maxsplit=1) - if tokens and tokens[0] in DECL_MODIFIERS: - code = tokens[1] if len(tokens) > 1 else "" - else: - break - if not code.startswith(f"{key} "): - return None - - rest = code[len(key) :].strip() - - # Use tuple for multiple startswith checks - if rest.startswith((":", "(", ":=")): - return default - - match = re.match(r"^([^ :\{\[\(]+)", rest) - if match: - return match.group(1) - - # Shouldn't goto here if there's no error - return None - - @staticmethod - def get_all_theorem_names(code: str) -> list[str]: - """ - get all theorem names from the code - """ - p = LeanCodeParser(code) - blocks = p.extract_all_blocks(keys=["theorem", "lemma"]) - return [block["info"]["name"] for block in blocks] - - @staticmethod - def get_theorem_name(code: str, default: str = "this") -> str: - """ - examples: - 'theorem v1 : xxx' -> 'v1' - 'theorem : xxx' -> 'this' - 'theorem := xxx' -> 'this' - 'theorem t1 (x : T) : ...' -> 't1' - """ - assert code.startswith( - ("theorem", "lemma") - ), f"code must start with 'theorem' or 'lemma', but got {code}" - if code.startswith("theorem"): - return LeanCodeParser.extract_name_from_code(code, "theorem", default) - return LeanCodeParser.extract_name_from_code(code, "lemma", default) - - def extract_statement_and_proof_from_code( - self, - code: str, - ) -> tuple[str, str] | None: - """ - example: - 'have : 1 + 1 = 2 := by sorry' -> ('have : 1 + 1 = 2', 'by sorry') - """ - if ":=" not in code: - return None - - pos = _find_top_level_walrus(code) - if pos is not None: - statement = code[:pos].strip() - proof = code[pos + 2:].strip() - return (statement, proof) - - parts = code.split(":=", maxsplit=1) - statement = parts[0].strip() - proof = parts[1].strip() if len(parts) == 2 else "" - return (statement, proof) - - def parse_block(self, lines: list[str], key: str): - """ - in: - Make sure lines is actually a have block - - out: - { - "name" : str - "statement" : str "theorem ___ {_} (_):__" - "proof" : str "by ___" or "___" - "with_sorry" : Bool - "proof_style" : str "tactic" / "term" / "unknown" - "inner_indent" : inner_indent - } - """ - - raw = "\n".join(lines) - - if key in DOT_KEYS: - name = "." - - statement = "." - proof = raw.lstrip()[1:].lstrip() - - else: - name = self.extract_name_from_code(lines[0], key=key) - - statement, proof = self.extract_statement_and_proof_from_code(raw) or ( - "", - "", - ) - - with_sorry = "sorry" in raw.split() - - proof_style = ( - "tactic" - if proof.startswith("by") - else ("dot_block" if key in DOT_KEYS else ("term" if proof else "unknown")) - ) - - # inner_indent - cleaned_raw_proof = re.sub(r"^[^\n]*", "", proof, count=1) - cleaned_raw_proof = re.sub(r"^(?:\s*\n)+", "", cleaned_raw_proof, count=1) - inner_indent = len(cleaned_raw_proof) - len(cleaned_raw_proof.lstrip()) - if inner_indent <= 0: - inner_indent = self.get_indent(lines[0]) + 2 - - return { - "name": name, - "statement": statement, - "proof": proof, - "with_sorry": with_sorry, - "proof_style": proof_style, - "inner_indent": inner_indent, - } - - def get_block_from_lid( - self, - start_line_index: int, - keys: list[str] | None = None, - ) -> dict[str, Any]: - """Get a block from a line index. - out: - { - "key" : str - "start" : start line (int) - "end" : end line (int) - "lines" : content (List[str]) - "indent" : base indent (int) - "key" : key - "info" : call parse_block (Dict) - } - """ - - if keys is None: - keys = ["theorem"] - - if start_line_index >= len(self.cleaned_lines): - return None - - start_line = self.cleaned_lines[start_line_index] - tokens = start_line.split() - i = 0 - while i < len(tokens) and tokens[i] in DECL_MODIFIERS: - i += 1 - if i >= len(tokens) or tokens[i] not in keys: - return None - key = tokens[i] - - start_indent = self.get_indent(start_line) - block_lines = [start_line] - i = start_line_index + 1 - while i < len(self.cleaned_lines): - line = self.cleaned_lines[i] - line_indent = self.get_indent(line) - if line_indent > start_indent: - block_lines.append(line) - i += 1 - elif not line.strip(): - # actually not necessary, but put it here for safe - i += 1 - elif line_indent == start_indent: - if key in DOT_KEYS: - break - # in case someone wrote the statement in multiple line and didn't indent - if ":=" not in self.strip_brackets("\n".join(block_lines)): - block_lines.append(line) - i += 1 - else: - break - else: - break - - info = self.parse_block(block_lines, key=key) - - return { - "start": start_line_index, - "end": i - 1, - "lines": block_lines, - "indent": start_indent, - "key": key, - "info": info, - } - - def _docstring_line_indices(self) -> set[int]: - """Return the set of cleaned-line indices that fall inside a ``/-- ... -/`` docstring. - - Used so block detection ignores lines like ``Using lemma \\ref{lem:foo}`` - that appear inside attribute docstrings and would otherwise be parsed - as Lean declarations. - """ - indices: set[int] = set() - code = "\n".join(self.cleaned_lines) - i = 0 - n = len(code) - line = 0 - depth = 0 - doc_start_line = -1 - while i < n: - if code[i] == "\n": - if depth > 0 and line > doc_start_line: - indices.add(line) - line += 1 - i += 1 - continue - if depth == 0 and code.startswith("/--", i): - depth = 1 - doc_start_line = line - i += 3 - continue - if depth > 0: - if code.startswith("/-", i): - depth += 1 - i += 2 - continue - if code.startswith("-/", i): - depth -= 1 - i += 2 - continue - i += 1 - return indices - - def extract_all_blocks( - self, - keys: list[str] | None = None, - allow_overlap: bool = True, - min_proof_lines: int = 0, - max_proof_lines: int = 10000, - ) -> Any: - """Extract all blocks from the code.""" - if keys is None: - keys = ["theorem"] - - in_doc = self._docstring_line_indices() - blocks = [] - i = 0 - while i < len(self.cleaned_lines): - if i in in_doc: - i += 1 - continue - block = self.get_block_from_lid(i, keys=keys) - - if ( - block - and min_proof_lines - <= len(block["info"]["proof"].splitlines()) - <= max_proof_lines - ): - blocks.append(block) - if not allow_overlap: - i = block["end"] - i += 1 - return blocks - - def block_to_axiom(self, block: dict) -> str: - """ - convert a block to an axiom - - replace statement[key] -> axiom - remove proof - """ - res = block["info"]["statement"].replace(block["key"], "axiom", 1) - return res - - -# ==================================================== -# tools -# ==================================================== - - -def create_statement_with_lemmas( - original_statement: str, - lemmas: list[str], -) -> str: - """ - headers : import / open - original_statement : - should contain exactly one theorem, no def / abbrev - 'theorem' should be at the beginning of one line - the proof should have nonempty indentation - lemmas : - should only contain theorems / lemmas, no def / abbrev - 'theorem / lemma' should be at the beginning of one line - the proof should have nonempty indentation - """ - final_import_set = set() - final_open_set = set() - final_set_option_set = set() - final_other_set = set() - final_lemma_codes = [] - final_main_theorem_codes = [] - - # handle original_statement - p = LeanCodeParser(original_statement) - headers = p.extract_headers() - blocks = p.extract_all_blocks(keys=["theorem", "lemma"], allow_overlap=False) - other = p.extract_other() - if len(other) > 0: - final_other_set.add(other) - final_import_set = final_import_set.union(headers["import_list"]) - final_open_set = final_open_set.union(headers["open_list"]) - final_set_option_set = final_set_option_set.union(headers["set_option_list"]) - final_main_theorem_codes = ["\n".join(block["lines"]) for block in blocks] - - # handle lemmas - for lemma_raw in lemmas: - p = LeanCodeParser(lemma_raw) - headers = p.extract_headers() - blocks = p.extract_all_blocks(keys=["theorem", "lemma"], allow_overlap=False) - other = p.extract_other() - if len(other) > 0: - final_other_set.add(other) - final_import_set = final_import_set.union(headers["import_list"]) - final_open_set = final_open_set.union(headers["open_list"]) - final_set_option_set = final_set_option_set.union(headers["set_option_list"]) - for block in blocks: - raw = "\n".join(block["lines"]) - raw = raw.replace("theorem ", "lemma ", 1) - final_lemma_codes.append(raw) - - final_code = "" - for x in sorted(final_import_set): - final_code += f"import {x}" - final_code += "\n" - final_code += "\n" - - if len(final_set_option_set) > 0: - for x in sorted(final_set_option_set): - final_code += x.strip() - final_code += "\n" - final_code += "\n" - - if len(final_open_set) > 0: - final_code += "open" - for x in sorted(final_open_set): - final_code += f" {x}" - final_code += "\n" - - if len(final_other_set) > 0: - final_code += "\n" - for x in sorted(final_other_set): - final_code += x - final_code += "\n\n" - - final_code += "\n" - for x in final_lemma_codes: - final_code += x - final_code += "\n\n" - final_code += "\n" - - for x in final_main_theorem_codes: - final_code += x - final_code += "\n\n" - - return final_code, final_lemma_codes - - -def _find_top_level_walrus(text: str) -> int | None: - """Return the position of the first proof-introducing ``:=`` in ``text``. - - "Proof-introducing" excludes ``:=`` that belong to ``let``-bindings inside - the theorem signature (e.g. ``lemma foo : let x := 1; … := by …``). The - algorithm tracks bracket depth (so default values inside ``(x := default)`` - are skipped) and a per-``let`` counter (so each ``let``'s ``:=`` is also - skipped before we accept the proof boundary). - """ - paren = bracket = brace = 0 - let_pending = 0 - i = 0 - n = len(text) - while i < n - 1: - c = text[i] - if c == "(": - paren += 1 - i += 1 - continue - if c == ")": - paren -= 1 - i += 1 - continue - if c == "[": - bracket += 1 - i += 1 - continue - if c == "]": - bracket -= 1 - i += 1 - continue - if c == "{": - brace += 1 - i += 1 - continue - if c == "}": - brace -= 1 - i += 1 - continue - if ( - paren == 0 - and bracket == 0 - and brace == 0 - and text.startswith("let ", i) - and (i == 0 or not (text[i - 1].isalnum() or text[i - 1] == "_")) - ): - let_pending += 1 - i += 4 - continue - if c == ":" and text[i + 1] == "=" and paren == 0 and bracket == 0 and brace == 0: - if let_pending > 0: - let_pending -= 1 - i += 2 - continue - return i - i += 1 - return None - - -def gen_one_sorry_of_block( - original_cleaned: str, block_to_replace: dict[str, Any] -) -> str: - blockinfo = block_to_replace["info"] - raw_block = "\n".join(block_to_replace["lines"]) - sorry_str = "by sorry" if blockinfo["proof_style"] in ["tactic"] else "sorry" - - walrus_pos = _find_top_level_walrus(raw_block) - if walrus_pos is None: - # No top-level := found — leave the original unchanged. - return original_cleaned - - raw_block_with_sorry = raw_block[:walrus_pos] + ":= " + sorry_str - return original_cleaned.replace(raw_block, raw_block_with_sorry, 1) - - -def create_proof_with_sorries( - original_statement: str, - keys: list[str] = ["have", "replace"], - max_sorry_cnt: int = 100000, - min_proof_lines: int = 0, - max_proof_lines: int = 100000, -) -> str: - p = LeanCodeParser(original_statement) - blocks = p.extract_all_blocks( - keys=keys, - allow_overlap=False, - min_proof_lines=min_proof_lines, - max_proof_lines=max_proof_lines, - ) - blocks = sorted(blocks, key=lambda x: x["end"] - x["start"], reverse=True) - blocks = blocks[:max_sorry_cnt] - raw_cleaned = "\n".join(p.cleaned_lines) - for block in blocks: - raw_cleaned = gen_one_sorry_of_block(raw_cleaned, block) - return raw_cleaned - -def add_newlines_before_keys(code: str, keys: list[str]) -> str: - """ - add newlines before the lines that start with the keys - """ - lines = code.splitlines() - result_lines = [] - - for line in lines: - if any(line.startswith(key) for key in keys): - result_lines.append("") - result_lines.append(line) - - return "\n".join(result_lines) - -def remove_imports(code: str, prefixes: list[str]) -> str: - lines = code.splitlines() - result_lines = [] - for line in lines: - if not line.startswith("import"): - result_lines.append(line) - continue - package_name = line.split()[1] - if any(package_name.startswith(prefix) for prefix in prefixes): - continue - result_lines.append(line) - return "\n".join(result_lines) - -def convert_not_last_to_axiom(code: str, keys: list[str] = ["theorem", "lemma"]) -> str: - """ - convert all theorems and lemmas to axioms, except the last one - """ - p = LeanCodeParser(code) - blocks = p.extract_all_blocks(keys=keys, allow_overlap=False) - for block in blocks[:-1]: - orig_str = "\n".join(block["lines"]) - axiom_str = p.block_to_axiom(block) - code = code.replace(orig_str, axiom_str, 1) - return code diff --git a/scripts/create_sorries/statement.jsonl b/scripts/create_sorries/statement.jsonl deleted file mode 100644 index 08c9a36..0000000 --- a/scripts/create_sorries/statement.jsonl +++ /dev/null @@ -1,675 +0,0 @@ -{"project_name": "AndersonTheorem", "name": "nullMeasurable_to_nullMeasurableSet", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry"} -{"project_name": "AndersonTheorem", "name": "nullMeasurableSet_to_nullMeasurable", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry"} -{"project_name": "AndersonTheorem", "name": "volume_smul_rspace", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry"} -{"project_name": "AndersonTheorem", "name": "aemeasurable_indicator_of_nms", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry"} -{"project_name": "AndersonTheorem", "name": "volume_image_add_right", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry"} -{"project_name": "AndersonTheorem", "name": "nullMeasurable_smul_set", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry"} -{"project_name": "AndersonTheorem", "name": "nonempty_smul", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry"} -{"project_name": "AndersonTheorem", "name": "sum_eq_lam_smul_inv_smul", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry"} -{"project_name": "AndersonTheorem", "name": "brunn_minkowski_1d_compact", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry"} -{"project_name": "AndersonTheorem", "name": "brunn_minkowski_1d", "type": "theorem", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry"} -{"project_name": "AndersonTheorem", "name": "euclidean1Equiv_measurePreserving", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry"} -{"project_name": "AndersonTheorem", "name": "euclidean1Equiv_linear", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry"} -{"project_name": "AndersonTheorem", "name": "prekopa_leindler_real", "type": "theorem", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry"} -{"project_name": "AndersonTheorem", "name": "truncEN_le", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry"} -{"project_name": "AndersonTheorem", "name": "truncEN_le_n", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry"} -{"project_name": "AndersonTheorem", "name": "truncEN_mono_n", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry"} -{"project_name": "AndersonTheorem", "name": "truncEN_measurable", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry"} -{"project_name": "AndersonTheorem", "name": "ENNReal_iSup_min_natCast", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry"} -{"project_name": "AndersonTheorem", "name": "truncEN_iSup", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry"} -{"project_name": "AndersonTheorem", "name": "lintegral_truncEN_iSup", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry"} -{"project_name": "AndersonTheorem", "name": "truncEN_toReal_integrable", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry"} -{"project_name": "AndersonTheorem", "name": "norm_convex_le_of_le", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry"} -{"project_name": "AndersonTheorem", "name": "truncEN_toReal_bound", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry"} -{"project_name": "AndersonTheorem", "name": "truncEN_lintegral_bound", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry"} -{"project_name": "AndersonTheorem", "name": "ENNReal_iSup_rpow_monotone", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry"} -{"project_name": "AndersonTheorem", "name": "ENNReal_iSup_mul_monotone", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry"} -{"project_name": "AndersonTheorem", "name": "prekopa_leindler_ennreal_1d", "type": "theorem", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry"} -{"project_name": "AndersonTheorem", "name": "euclideanSuccEquiv_measurePreserving", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry"} -{"project_name": "AndersonTheorem", "name": "euclideanSuccEquiv_affine", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry"} -{"project_name": "AndersonTheorem", "name": "fubini_euclidean_succ", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry"} -{"project_name": "AndersonTheorem", "name": "lintegral_euclidean_succ", "type": "lemma", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry"} -{"project_name": "AndersonTheorem", "name": "prekopa_leindler_for_anderson_ind", "type": "theorem", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry"} -{"project_name": "AndersonTheorem", "name": "prekopa_leindler_for_anderson", "type": "theorem", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\n\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry"} -{"project_name": "AndersonTheorem", "name": "brunn_minkowski_mul", "type": "theorem", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\n\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\n\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry"} -{"project_name": "AndersonTheorem", "name": "brunn_minkowski", "type": "theorem", "code": "import Mathlib\n\nopen Classical\n\nopen MeasureTheory Set\n\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\n\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\n\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\n\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\n\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\n\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry\n\ntheorem brunn_minkowski (hn : 0 < n) (A B C : Set (RSpace n)) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n (volume A) ^ (n : ℝ)⁻¹ + (volume B) ^ (n : ℝ)⁻¹ ≤ volume C ^ (n : ℝ)⁻¹ := by sorry"} -{"project_name": "AndersonTheorem", "name": "nullMeasurableSet_to_nullMeasurable", "type": "lemma", "code": "import Mathlib\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry", "imported_file": "-- File: LiveLeanTriathlon.AndersonTheorem.BackgroundLemmas\nopen Classical\nopen MeasureTheory Set\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry\ntheorem brunn_minkowski (hn : 0 < n) (A B C : Set (RSpace n)) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n (volume A) ^ (n : ℝ)⁻¹ + (volume B) ^ (n : ℝ)⁻¹ ≤ volume C ^ (n : ℝ)⁻¹ := by sorry"} -{"project_name": "AndersonTheorem", "name": "restrict_superlevel_eq_volume_translate", "type": "lemma", "code": "import Mathlib\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma restrict_superlevel_eq_volume_translate {n : ℕ} {y : RSpace n}\n {E : Set (RSpace n)} {f : (RSpace n) → ℝ} (u : ℝ)\n (hE : NullMeasurableSet E volume) :\n (volume.restrict E) {x : RSpace n | u ≤ f (x + y)} =\n volume (((· + y) '' E) ∩ (f ⁻¹' (Ici u))) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.AndersonTheorem.BackgroundLemmas\nopen Classical\nopen MeasureTheory Set\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry\ntheorem brunn_minkowski (hn : 0 < n) (A B C : Set (RSpace n)) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n (volume A) ^ (n : ℝ)⁻¹ + (volume B) ^ (n : ℝ)⁻¹ ≤ volume C ^ (n : ℝ)⁻¹ := by sorry"} -{"project_name": "AndersonTheorem", "name": "neg_translate_inter_eq", "type": "lemma", "code": "import Mathlib\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma restrict_superlevel_eq_volume_translate {n : ℕ} {y : RSpace n}\n {E : Set (RSpace n)} {f : (RSpace n) → ℝ} (u : ℝ)\n (hE : NullMeasurableSet E volume) :\n (volume.restrict E) {x : RSpace n | u ≤ f (x + y)} =\n volume (((· + y) '' E) ∩ (f ⁻¹' (Ici u))) := by sorry\nprivate lemma neg_translate_inter_eq {n : ℕ} {y : RSpace n}\n {E K : Set (RSpace n)}\n (hE : E = -E) (hK : K = -K) :\n ((· + (-y)) '' E) ∩ K = -((· + y) '' E ∩ K) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.AndersonTheorem.BackgroundLemmas\nopen Classical\nopen MeasureTheory Set\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry\ntheorem brunn_minkowski (hn : 0 < n) (A B C : Set (RSpace n)) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n (volume A) ^ (n : ℝ)⁻¹ + (volume B) ^ (n : ℝ)⁻¹ ≤ volume C ^ (n : ℝ)⁻¹ := by sorry"} -{"project_name": "AndersonTheorem", "name": "convex_inclusion", "type": "lemma", "code": "import Mathlib\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma restrict_superlevel_eq_volume_translate {n : ℕ} {y : RSpace n}\n {E : Set (RSpace n)} {f : (RSpace n) → ℝ} (u : ℝ)\n (hE : NullMeasurableSet E volume) :\n (volume.restrict E) {x : RSpace n | u ≤ f (x + y)} =\n volume (((· + y) '' E) ∩ (f ⁻¹' (Ici u))) := by sorry\nprivate lemma neg_translate_inter_eq {n : ℕ} {y : RSpace n}\n {E K : Set (RSpace n)}\n (hE : E = -E) (hK : K = -K) :\n ((· + (-y)) '' E) ∩ K = -((· + y) '' E ∩ K) := by sorry\nprivate lemma convex_inclusion {n : ℕ} {c : ℝ} {y : RSpace n}\n {E : Set (RSpace n)} {K_u : Set (RSpace n)}\n (E_convex : Convex ℝ E) (K_convex : Convex ℝ K_u) (hc : 0 ≤ c ∧ c ≤ 1) :\n let α := (1 + c) / 2\n let A := (· + y) '' E ∩ K_u\n let B := (· + (-y)) '' E ∩ K_u\n let C := (· + (c • y)) '' E ∩ K_u\n ∀ x, x ∈ α • A + (1 - α) • B → x ∈ C := by sorry", "imported_file": "-- File: LiveLeanTriathlon.AndersonTheorem.BackgroundLemmas\nopen Classical\nopen MeasureTheory Set\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry\ntheorem brunn_minkowski (hn : 0 < n) (A B C : Set (RSpace n)) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n (volume A) ^ (n : ℝ)⁻¹ + (volume B) ^ (n : ℝ)⁻¹ ≤ volume C ^ (n : ℝ)⁻¹ := by sorry"} -{"project_name": "AndersonTheorem", "name": "volume_neg_eq", "type": "lemma", "code": "import Mathlib\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma restrict_superlevel_eq_volume_translate {n : ℕ} {y : RSpace n}\n {E : Set (RSpace n)} {f : (RSpace n) → ℝ} (u : ℝ)\n (hE : NullMeasurableSet E volume) :\n (volume.restrict E) {x : RSpace n | u ≤ f (x + y)} =\n volume (((· + y) '' E) ∩ (f ⁻¹' (Ici u))) := by sorry\nprivate lemma neg_translate_inter_eq {n : ℕ} {y : RSpace n}\n {E K : Set (RSpace n)}\n (hE : E = -E) (hK : K = -K) :\n ((· + (-y)) '' E) ∩ K = -((· + y) '' E ∩ K) := by sorry\nprivate lemma convex_inclusion {n : ℕ} {c : ℝ} {y : RSpace n}\n {E : Set (RSpace n)} {K_u : Set (RSpace n)}\n (E_convex : Convex ℝ E) (K_convex : Convex ℝ K_u) (hc : 0 ≤ c ∧ c ≤ 1) :\n let α := (1 + c) / 2\n let A := (· + y) '' E ∩ K_u\n let B := (· + (-y)) '' E ∩ K_u\n let C := (· + (c • y)) '' E ∩ K_u\n ∀ x, x ∈ α • A + (1 - α) • B → x ∈ C := by sorry\nprivate lemma volume_neg_eq {n : ℕ} (S : Set (RSpace n)) :\n volume (-S) = volume S := sorry", "imported_file": "-- File: LiveLeanTriathlon.AndersonTheorem.BackgroundLemmas\nopen Classical\nopen MeasureTheory Set\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry\ntheorem brunn_minkowski (hn : 0 < n) (A B C : Set (RSpace n)) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n (volume A) ^ (n : ℝ)⁻¹ + (volume B) ^ (n : ℝ)⁻¹ ≤ volume C ^ (n : ℝ)⁻¹ := by sorry"} -{"project_name": "AndersonTheorem", "name": "ennreal_rpow_split", "type": "lemma", "code": "import Mathlib\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma restrict_superlevel_eq_volume_translate {n : ℕ} {y : RSpace n}\n {E : Set (RSpace n)} {f : (RSpace n) → ℝ} (u : ℝ)\n (hE : NullMeasurableSet E volume) :\n (volume.restrict E) {x : RSpace n | u ≤ f (x + y)} =\n volume (((· + y) '' E) ∩ (f ⁻¹' (Ici u))) := by sorry\nprivate lemma neg_translate_inter_eq {n : ℕ} {y : RSpace n}\n {E K : Set (RSpace n)}\n (hE : E = -E) (hK : K = -K) :\n ((· + (-y)) '' E) ∩ K = -((· + y) '' E ∩ K) := by sorry\nprivate lemma convex_inclusion {n : ℕ} {c : ℝ} {y : RSpace n}\n {E : Set (RSpace n)} {K_u : Set (RSpace n)}\n (E_convex : Convex ℝ E) (K_convex : Convex ℝ K_u) (hc : 0 ≤ c ∧ c ≤ 1) :\n let α := (1 + c) / 2\n let A := (· + y) '' E ∩ K_u\n let B := (· + (-y)) '' E ∩ K_u\n let C := (· + (c • y)) '' E ∩ K_u\n ∀ x, x ∈ α • A + (1 - α) • B → x ∈ C := by sorry\nprivate lemma volume_neg_eq {n : ℕ} (S : Set (RSpace n)) :\n volume (-S) = volume S := sorry\nprivate lemma ennreal_rpow_split (a : ℝ≥0∞) (α : ℝ) (hα : 0 ≤ α) (hα1 : α ≤ 1) :\n a = a ^ α * a ^ (1 - α) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.AndersonTheorem.BackgroundLemmas\nopen Classical\nopen MeasureTheory Set\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry\ntheorem brunn_minkowski (hn : 0 < n) (A B C : Set (RSpace n)) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n (volume A) ^ (n : ℝ)⁻¹ + (volume B) ^ (n : ℝ)⁻¹ ≤ volume C ^ (n : ℝ)⁻¹ := by sorry"} -{"project_name": "AndersonTheorem", "name": "anderson_superlevel_measure", "type": "lemma", "code": "import Mathlib\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma restrict_superlevel_eq_volume_translate {n : ℕ} {y : RSpace n}\n {E : Set (RSpace n)} {f : (RSpace n) → ℝ} (u : ℝ)\n (hE : NullMeasurableSet E volume) :\n (volume.restrict E) {x : RSpace n | u ≤ f (x + y)} =\n volume (((· + y) '' E) ∩ (f ⁻¹' (Ici u))) := by sorry\nprivate lemma neg_translate_inter_eq {n : ℕ} {y : RSpace n}\n {E K : Set (RSpace n)}\n (hE : E = -E) (hK : K = -K) :\n ((· + (-y)) '' E) ∩ K = -((· + y) '' E ∩ K) := by sorry\nprivate lemma convex_inclusion {n : ℕ} {c : ℝ} {y : RSpace n}\n {E : Set (RSpace n)} {K_u : Set (RSpace n)}\n (E_convex : Convex ℝ E) (K_convex : Convex ℝ K_u) (hc : 0 ≤ c ∧ c ≤ 1) :\n let α := (1 + c) / 2\n let A := (· + y) '' E ∩ K_u\n let B := (· + (-y)) '' E ∩ K_u\n let C := (· + (c • y)) '' E ∩ K_u\n ∀ x, x ∈ α • A + (1 - α) • B → x ∈ C := by sorry\nprivate lemma volume_neg_eq {n : ℕ} (S : Set (RSpace n)) :\n volume (-S) = volume S := sorry\nprivate lemma ennreal_rpow_split (a : ℝ≥0∞) (α : ℝ) (hα : 0 ≤ α) (hα1 : α ≤ 1) :\n a = a ^ α * a ^ (1 - α) := by sorry\nprivate lemma anderson_superlevel_measure {n : ℕ} (hn : 0 < n) {c : ℝ} {y : RSpace n}\n {E : Set (RSpace n)} {f : (RSpace n) → ℝ}\n (E_symm : E = -E) (E_convex : Convex ℝ E)\n (f_symm : ∀ x, f (-x) = f x)\n (f_unimodal : ∀ t, 0 ≤ t → Convex ℝ (f ⁻¹' (Ici t)))\n (hc : 0 ≤ c ∧ c ≤ 1) (u : ℝ) (hu : 0 ≤ u) :\n (volume.restrict E) {x : RSpace n | u ≤ f (x + y)} ≤\n (volume.restrict E) {x : RSpace n | u ≤ f (x + c • y)} := by sorry", "imported_file": "-- File: LiveLeanTriathlon.AndersonTheorem.BackgroundLemmas\nopen Classical\nopen MeasureTheory Set\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry\ntheorem brunn_minkowski (hn : 0 < n) (A B C : Set (RSpace n)) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n (volume A) ^ (n : ℝ)⁻¹ + (volume B) ^ (n : ℝ)⁻¹ ≤ volume C ^ (n : ℝ)⁻¹ := by sorry"} -{"project_name": "AndersonTheorem", "name": "anderson", "type": "theorem", "code": "import Mathlib\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma restrict_superlevel_eq_volume_translate {n : ℕ} {y : RSpace n}\n {E : Set (RSpace n)} {f : (RSpace n) → ℝ} (u : ℝ)\n (hE : NullMeasurableSet E volume) :\n (volume.restrict E) {x : RSpace n | u ≤ f (x + y)} =\n volume (((· + y) '' E) ∩ (f ⁻¹' (Ici u))) := by sorry\nprivate lemma neg_translate_inter_eq {n : ℕ} {y : RSpace n}\n {E K : Set (RSpace n)}\n (hE : E = -E) (hK : K = -K) :\n ((· + (-y)) '' E) ∩ K = -((· + y) '' E ∩ K) := by sorry\nprivate lemma convex_inclusion {n : ℕ} {c : ℝ} {y : RSpace n}\n {E : Set (RSpace n)} {K_u : Set (RSpace n)}\n (E_convex : Convex ℝ E) (K_convex : Convex ℝ K_u) (hc : 0 ≤ c ∧ c ≤ 1) :\n let α := (1 + c) / 2\n let A := (· + y) '' E ∩ K_u\n let B := (· + (-y)) '' E ∩ K_u\n let C := (· + (c • y)) '' E ∩ K_u\n ∀ x, x ∈ α • A + (1 - α) • B → x ∈ C := by sorry\nprivate lemma volume_neg_eq {n : ℕ} (S : Set (RSpace n)) :\n volume (-S) = volume S := sorry\nprivate lemma ennreal_rpow_split (a : ℝ≥0∞) (α : ℝ) (hα : 0 ≤ α) (hα1 : α ≤ 1) :\n a = a ^ α * a ^ (1 - α) := by sorry\nprivate lemma anderson_superlevel_measure {n : ℕ} (hn : 0 < n) {c : ℝ} {y : RSpace n}\n {E : Set (RSpace n)} {f : (RSpace n) → ℝ}\n (E_symm : E = -E) (E_convex : Convex ℝ E)\n (f_symm : ∀ x, f (-x) = f x)\n (f_unimodal : ∀ t, 0 ≤ t → Convex ℝ (f ⁻¹' (Ici t)))\n (hc : 0 ≤ c ∧ c ≤ 1) (u : ℝ) (hu : 0 ≤ u) :\n (volume.restrict E) {x : RSpace n | u ≤ f (x + y)} ≤\n (volume.restrict E) {x : RSpace n | u ≤ f (x + c • y)} := by sorry\n\ntheorem anderson {n : ℕ} (hn : 0 < n) {c : ℝ} {y : RSpace n} {E : Set (RSpace n)} {f : (RSpace n) → ℝ}\n (E_symm : E = -E) (E_convex : Convex ℝ E)\n (f_nonneg : ∀ x, 0 ≤ f x) (f_symm : ∀ x, f (-x) = f x)\n (f_int : Integrable f volume) (f_unimodal : ∀ t, 0 ≤ t → Convex ℝ (f ⁻¹' (Ici t)))\n (hc : 0 ≤ c ∧ c ≤ 1) :\n ∫ x in E, f (x + y) ≤ ∫ x in E, f (x + c • y) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.AndersonTheorem.BackgroundLemmas\nopen Classical\nopen MeasureTheory Set\nopen scoped Pointwise ENNReal\n/-- The `n`-dimensional real space -/\nabbrev RSpace (n : ℕ) := EuclideanSpace ℝ (Fin n)\nvariable {n : ℕ}\nprivate lemma nullMeasurable_to_nullMeasurableSet {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (h : NullMeasurable A μ) :\n NullMeasurableSet A μ := by sorry\nprivate lemma nullMeasurableSet_to_nullMeasurable {α : Type*} [MeasurableSpace α]\n {μ : MeasureTheory.Measure α} {A : Set α}\n (h : NullMeasurableSet A μ) : NullMeasurable A μ := by sorry\nprivate lemma volume_smul_rspace (r : ℝ) (hr : 0 ≤ r) (A : Set (RSpace n)) :\n volume (r • A) = ENNReal.ofReal (r ^ n) * volume A := by sorry\nprivate lemma aemeasurable_indicator_of_nms {α : Type*} [MeasurableSpace α]\n {μ : Measure α} (A : Set α) (hA : NullMeasurableSet A μ) :\n AEMeasurable (A.indicator (fun _ => (1 : ℝ))) μ := by sorry\nprivate lemma volume_image_add_right (v : RSpace n) (S : Set (RSpace n)) :\n volume ((· + v) '' S) = volume S := by sorry\nprivate lemma nullMeasurable_smul_set (A : Set (RSpace n))\n (hA : NullMeasurable A) (r : ℝ) (hr : 0 < r) :\n NullMeasurable (r • A) := by sorry\nprivate lemma nonempty_smul (A : Set (RSpace n))\n (hA : A.Nonempty) (r : ℝ) :\n (r • A).Nonempty := by sorry\nprivate lemma sum_eq_lam_smul_inv_smul (A B : Set (RSpace n))\n {lam : ℝ} (hlam_pos : 0 < lam) (hlam_lt_one : lam < 1) :\n ∀ x, (∃ y ∈ A, ∃ z ∈ B, x = y + z) ↔\n ∃ y ∈ lam⁻¹ • A, ∃ z ∈ (1 - lam)⁻¹ • B, x = lam • y + (1 - lam) • z := by sorry\nprivate lemma brunn_minkowski_1d_compact (K L : Set ℝ) (hK : IsCompact K) (hL : IsCompact L)\n (hKne : K.Nonempty) (hLne : L.Nonempty) :\n volume K + volume L ≤ volume (K + L) := by sorry\ntheorem brunn_minkowski_1d (A B C : Set ℝ) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC₁ : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n volume A + volume B ≤ volume C := by sorry\nprivate noncomputable def euclidean1Equiv : EuclideanSpace ℝ (Fin 1) ≃ᵐ ℝ :=\n ((MeasurableEquiv.toLp 2 (Fin 1 → ℝ)).symm).trans (MeasurableEquiv.funUnique (Fin 1) ℝ)\nprivate lemma euclidean1Equiv_measurePreserving :\n MeasurePreserving euclidean1Equiv := by sorry\nprivate lemma euclidean1Equiv_linear (lam : ℝ) (x y : EuclideanSpace ℝ (Fin 1)) :\n euclidean1Equiv (lam • x + (1 - lam) • y) =\n lam * euclidean1Equiv x + (1 - lam) * euclidean1Equiv y := by sorry\nprivate theorem prekopa_leindler_real (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ)\n (hF₁ : ∀ x, 0 ≤ F x) (hF₂ : Integrable F)\n (hG₁ : ∀ x, 0 ≤ G x) (hG₂ : Integrable G)\n (hH₁ : ∀ x, 0 ≤ H x) (hH₂ : Integrable H)\n (hbound : ∀ x y : ℝ, (F x) ^ lam * (G y) ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫ x, F x) ^ lam * (∫ x, G x) ^ (1 - lam) ≤ ∫ x, H x := by sorry\nprivate noncomputable def truncEN (F : ℝ → ℝ≥0∞) (n : ℕ) : ℝ → ℝ≥0∞ :=\n fun x => if ‖x‖ ≤ (n : ℝ) then min (F x) (n : ℝ≥0∞) else 0\nprivate lemma truncEN_le (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ F x := by sorry\nprivate lemma truncEN_le_n (F : ℝ → ℝ≥0∞) (n : ℕ) (x : ℝ) : truncEN F n x ≤ (n : ℝ≥0∞) := by sorry\nprivate lemma truncEN_mono_n (F : ℝ → ℝ≥0∞) {n m : ℕ} (hnm : n ≤ m) (x : ℝ) :\n truncEN F n x ≤ truncEN F m x := by sorry\nprivate lemma truncEN_measurable {F : ℝ → ℝ≥0∞} (hF : Measurable F) (n : ℕ) :\n Measurable (truncEN F n) := sorry\nprivate lemma ENNReal_iSup_min_natCast (v : ℝ≥0∞) : ⨆ n : ℕ, min v (n : ℝ≥0∞) = v := by sorry\nprivate lemma truncEN_iSup (F : ℝ → ℝ≥0∞) (x : ℝ) : ⨆ n : ℕ, truncEN F n x = F x := by sorry\nprivate lemma lintegral_truncEN_iSup (F : ℝ → ℝ≥0∞) (hF : Measurable F) :\n ∫⁻ x, F x = ⨆ n : ℕ, ∫⁻ x, truncEN F n x := by sorry\nprivate lemma truncEN_toReal_integrable (F : ℝ → ℝ≥0∞) (hF : Measurable F) (n : ℕ) :\n Integrable (fun x => ENNReal.toReal (truncEN F n x)) := by sorry\nprivate lemma norm_convex_le_of_le (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (x y : ℝ) (n : ℕ) (hxn : ‖x‖ ≤ (n : ℝ)) (hyn : ‖y‖ ≤ (n : ℝ)) :\n ‖lam * x + (1 - lam) * y‖ ≤ (n : ℝ) := sorry\nprivate lemma truncEN_toReal_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) (x y : ℝ) :\n (ENNReal.toReal (truncEN F n x)) ^ lam *\n (ENNReal.toReal (truncEN G n y)) ^ (1 - lam) ≤\n ENNReal.toReal (truncEN H n (lam * x + (1 - lam) * y)) := by sorry\nprivate lemma truncEN_lintegral_bound (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y))\n (n : ℕ) :\n (∫⁻ x, truncEN F n x) ^ lam * (∫⁻ x, truncEN G n x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate lemma ENNReal_iSup_rpow_monotone (lam : ℝ) (hlam : 0 < lam)\n (a : ℕ → ℝ≥0∞) (ha : Monotone a) : (⨆ n, a n) ^ lam = ⨆ n, (a n) ^ lam := by sorry\nprivate lemma ENNReal_iSup_mul_monotone (a b : ℕ → ℝ≥0∞) (ha : Monotone a) (hb : Monotone b) :\n ⨆ n, a n * b n = (⨆ n, a n) * (⨆ n, b n) := by sorry\n/-- ENNReal 1D Prékopa-Leindler for Measurable functions -/\nprivate theorem prekopa_leindler_ennreal_1d\n (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (F G H : ℝ → ℝ≥0∞) (hF : Measurable F) (hG : Measurable G) (hH : Measurable H)\n (hbound : ∀ x y : ℝ, F x ^ lam * G y ^ (1 - lam) ≤ H (lam * x + (1 - lam) * y)) :\n (∫⁻ x, F x) ^ lam * (∫⁻ x, G x) ^ (1 - lam) ≤ ∫⁻ x, H x := by sorry\nprivate noncomputable def euclideanSuccEquiv (m : ℕ) :\n EuclideanSpace ℝ (Fin (m + 1)) ≃ᵐ ℝ × EuclideanSpace ℝ (Fin m) :=\n (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm |>.trans\n ((MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0).trans\n ((MeasurableEquiv.refl ℝ).prodCongr (MeasurableEquiv.toLp 2 (Fin m → ℝ))))\nprivate lemma euclideanSuccEquiv_measurePreserving (m : ℕ) :\n MeasurePreserving (euclideanSuccEquiv m) := by sorry\nprivate lemma euclideanSuccEquiv_affine (m : ℕ) (lam : ℝ) (x y : EuclideanSpace ℝ (Fin (m+1))) :\n euclideanSuccEquiv m (lam • x + (1 - lam) • y) =\n (lam * (euclideanSuccEquiv m x).1 + (1 - lam) * (euclideanSuccEquiv m y).1,\n lam • (euclideanSuccEquiv m x).2 + (1 - lam) • (euclideanSuccEquiv m y).2) := by sorry\nprivate lemma fubini_euclidean_succ (m : ℕ) (f : EuclideanSpace ℝ (Fin (m+1)) → ℝ)\n (hf : Integrable f) :\n ∫ x, f x = ∫ x₀ : ℝ, ∫ x' : EuclideanSpace ℝ (Fin m),\n f ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate lemma lintegral_euclidean_succ (m : ℕ) (F : EuclideanSpace ℝ (Fin (m+1)) → ℝ≥0∞)\n (hF : Measurable F) :\n ∫⁻ x, F x = ∫⁻ x₀ : ℝ, ∫⁻ x' : EuclideanSpace ℝ (Fin m),\n F ((euclideanSuccEquiv m).symm (x₀, x')) := by sorry\nprivate theorem prekopa_leindler_for_anderson_ind (nn : ℕ) (lam : ℝ) (hlam₁ : 0 < lam)\n (hlam₂ : lam < 1)\n (f g h : EuclideanSpace ℝ (Fin nn) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := by sorry\ntheorem prekopa_leindler_for_anderson (lam : ℝ) (hlam₁ : 0 < lam) (hlam₂ : lam < 1)\n (f g h : (RSpace n) → ℝ)\n (hf₁ : ∀ x, 0 ≤ f x) (hf₂ : Measurable f)\n (hg₁ : ∀ x, 0 ≤ g x) (hg₂ : Measurable g)\n (hh₁ : ∀ x, 0 ≤ h x) (hh₂ : Measurable h) (hhInt : Integrable h)\n (hbound : ∀ x y, (f x) ^ lam * (g y) ^ (1 - lam) ≤ h (lam • x + (1 - lam) • y)) :\n (∫ x, f x) ^ lam * (∫ x, g x) ^ (1 - lam) ≤ ∫ x, h x := sorry\ntheorem brunn_minkowski_mul (hn : 0 < n) (A B C : Set (RSpace n))\n (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (lam : ℝ) (hlam₁ : 0 ≤ lam) (hlam₂ : lam ≤ 1)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = lam • y + (1 - lam) • z) :\n (volume A) ^ lam * (volume B) ^ (1 - lam) ≤ volume C := by sorry\ntheorem brunn_minkowski (hn : 0 < n) (A B C : Set (RSpace n)) (hA₁ : NullMeasurable A) (hB₁ : NullMeasurable B)\n (hC : NullMeasurable C)\n (hA₂ : A.Nonempty) (hB₂ : B.Nonempty)\n (h : ∀ x, x ∈ C ↔ ∃ y ∈ A, ∃ z ∈ B, x = y + z) :\n (volume A) ^ (n : ℝ)⁻¹ + (volume B) ^ (n : ℝ)⁻¹ ≤ volume C ^ (n : ℝ)⁻¹ := by sorry"} -{"project_name": "Apery", "name": "apery", "type": "theorem", "code": "import Mathlib\n\nuniverse u\n/-- https://en.wikipedia.org/wiki/Ap%C3%A9ry%27s_theorem -/\n\ntheorem apery : Irrational (riemannZeta 3).re := by sorry"} -{"project_name": "AztecDiamond", "name": "aztecDiamond_tiling", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n/-- Domino tiling of a set of integers:\n$f$ assigns each member of the grid the other member of its domino -/\n\nstructure DominoTiling (s : Set (ℤ × ℤ)) where\n /-- The function $f$ that pairs each point with its domino partner. -/\n f : s → s\n /-- $f$ is an involution, so the dominos are indeed pairs. -/\n inv : f^[2] = id\n /-- The tiling condition: each point is paired with a neighbor,\n so the sum of the distances in each coordinate is 1. -/\n tilt : ∀ x : s, |(f x).val.1 - x.val.1| + |(f x).val.2 - x.val.2| = 1\n/--\nThe set of points in the Aztec diamond of order $n$.\n-/\n\ndef AztecDiamond (n : ℕ) : Set (ℤ × ℤ) :=\n {x : ℤ × ℤ | |(↑x.1 : ℝ) - 0.5| + |(↑x.2 : ℝ) - 0.5| ≤ n}\n/-- The Aztec diamond of order $n$ has $2 ^(choose (n + 1) 2)$ Domino tilings. -/\n\ntheorem aztecDiamond_tiling (n : ℕ) :\n Nat.card (DominoTiling (AztecDiamond n)) = 2 ^ ((n + 1).choose 2) := by sorry"} -{"project_name": "BanachMazur", "name": "compact_hausdorff_coincide", "type": "lemma", "code": "import Mathlib\n\nopen TopologicalSpace Set\n\nopen scoped Topology\n\nuniverse u v\n\nvariable {K : Type u} {X : Type v}\n\nlemma compact_hausdorff_coincide\n {τ τ' : TopologicalSpace K}\n (hτ : @IsCompact K τ Set.univ)\n (hτ' : @T2Space K τ')\n (h : τ ≤ τ') :\n τ = τ' := by sorry"} -{"project_name": "BanachMazur", "name": "separable_implies_compact_metrizable_weak_star", "type": "lemma", "code": "import Mathlib\n\nopen TopologicalSpace Set\n\nopen scoped Topology\n\nuniverse u v\n\nvariable {K : Type u} {X : Type v}\n\nlemma compact_hausdorff_coincide\n {τ τ' : TopologicalSpace K}\n (hτ : @IsCompact K τ Set.univ)\n (hτ' : @T2Space K τ')\n (h : τ ≤ τ') :\n τ = τ' := by sorry\n\nlemma separable_implies_compact_metrizable_weak_star\n [NormedAddCommGroup X] [NormedSpace ℝ X] [SeparableSpace X] :\n let B := WeakDual.toStrongDual ⁻¹' Metric.closedBall (0 : StrongDual ℝ X) 1;\n IsCompact B ∧ IsSeparable B := by sorry"} -{"project_name": "BanachMazur", "name": "separable_banach_implies_embeds_cont", "type": "lemma", "code": "import Mathlib\n\nopen TopologicalSpace Set\n\nopen scoped Topology\n\nuniverse u v\n\nvariable {K : Type u} {X : Type v}\n\nlemma compact_hausdorff_coincide\n {τ τ' : TopologicalSpace K}\n (hτ : @IsCompact K τ Set.univ)\n (hτ' : @T2Space K τ')\n (h : τ ≤ τ') :\n τ = τ' := by sorry\n\nlemma separable_implies_compact_metrizable_weak_star\n [NormedAddCommGroup X] [NormedSpace ℝ X] [SeparableSpace X] :\n let B := WeakDual.toStrongDual ⁻¹' Metric.closedBall (0 : StrongDual ℝ X) 1;\n IsCompact B ∧ IsSeparable B := by sorry\n\nlemma separable_banach_implies_embeds_cont\n [NormedAddCommGroup X] [NormedSpace ℝ X] :\n ∃ (K : Type v), ∃ _ : TopologicalSpace K, ∃ _ : CompactSpace K,\n ∃ f : X → C(K, ℝ), Isometry f := by sorry"} -{"project_name": "BanachMazur", "name": "compact_metrizable_implies_embeds", "type": "lemma", "code": "import Mathlib\n\nopen TopologicalSpace Set\n\nopen scoped Topology\n\nuniverse u v\n\nvariable {K : Type u} {X : Type v}\n\nlemma compact_hausdorff_coincide\n {τ τ' : TopologicalSpace K}\n (hτ : @IsCompact K τ Set.univ)\n (hτ' : @T2Space K τ')\n (h : τ ≤ τ') :\n τ = τ' := by sorry\n\nlemma separable_implies_compact_metrizable_weak_star\n [NormedAddCommGroup X] [NormedSpace ℝ X] [SeparableSpace X] :\n let B := WeakDual.toStrongDual ⁻¹' Metric.closedBall (0 : StrongDual ℝ X) 1;\n IsCompact B ∧ IsSeparable B := by sorry\n\nlemma separable_banach_implies_embeds_cont\n [NormedAddCommGroup X] [NormedSpace ℝ X] :\n ∃ (K : Type v), ∃ _ : TopologicalSpace K, ∃ _ : CompactSpace K,\n ∃ f : X → C(K, ℝ), Isometry f := by sorry\n\nlemma compact_metrizable_implies_embeds\n [TopologicalSpace K] [CompactSpace K] [MetrizableSpace K] :\n ∃ f : K → ℕ → unitInterval, Topology.IsEmbedding f := by sorry"} -{"project_name": "BanachMazur", "name": "exists_linearIsometry_extension", "type": "lemma", "code": "import Mathlib\n\nopen TopologicalSpace Set\n\nopen scoped Topology\n\nuniverse u v\n\nvariable {K : Type u} {X : Type v}\n\nlemma compact_hausdorff_coincide\n {τ τ' : TopologicalSpace K}\n (hτ : @IsCompact K τ Set.univ)\n (hτ' : @T2Space K τ')\n (h : τ ≤ τ') :\n τ = τ' := by sorry\n\nlemma separable_implies_compact_metrizable_weak_star\n [NormedAddCommGroup X] [NormedSpace ℝ X] [SeparableSpace X] :\n let B := WeakDual.toStrongDual ⁻¹' Metric.closedBall (0 : StrongDual ℝ X) 1;\n IsCompact B ∧ IsSeparable B := by sorry\n\nlemma separable_banach_implies_embeds_cont\n [NormedAddCommGroup X] [NormedSpace ℝ X] :\n ∃ (K : Type v), ∃ _ : TopologicalSpace K, ∃ _ : CompactSpace K,\n ∃ f : X → C(K, ℝ), Isometry f := by sorry\n\nlemma compact_metrizable_implies_embeds\n [TopologicalSpace K] [CompactSpace K] [MetrizableSpace K] :\n ∃ f : K → ℕ → unitInterval, Topology.IsEmbedding f := by sorry\nnoncomputable section\n\nopen Classical in\n\nlemma exists_linearIsometry_extension (E : Set ℝ) (hE : IsClosed E) (hE₁ : E ⊆ unitInterval)\n [CompactSpace E] :\n ∃ _Φ : C(E, ℝ) →ₗᵢ[ℝ] C(unitInterval, ℝ), True := by sorry"} -{"project_name": "BanachMazur", "name": "closed_subset_interval_implies_cont_embeds", "type": "lemma", "code": "import Mathlib\n\nopen TopologicalSpace Set\n\nopen scoped Topology\n\nuniverse u v\n\nvariable {K : Type u} {X : Type v}\n\nlemma compact_hausdorff_coincide\n {τ τ' : TopologicalSpace K}\n (hτ : @IsCompact K τ Set.univ)\n (hτ' : @T2Space K τ')\n (h : τ ≤ τ') :\n τ = τ' := by sorry\n\nlemma separable_implies_compact_metrizable_weak_star\n [NormedAddCommGroup X] [NormedSpace ℝ X] [SeparableSpace X] :\n let B := WeakDual.toStrongDual ⁻¹' Metric.closedBall (0 : StrongDual ℝ X) 1;\n IsCompact B ∧ IsSeparable B := by sorry\n\nlemma separable_banach_implies_embeds_cont\n [NormedAddCommGroup X] [NormedSpace ℝ X] :\n ∃ (K : Type v), ∃ _ : TopologicalSpace K, ∃ _ : CompactSpace K,\n ∃ f : X → C(K, ℝ), Isometry f := by sorry\n\nlemma compact_metrizable_implies_embeds\n [TopologicalSpace K] [CompactSpace K] [MetrizableSpace K] :\n ∃ f : K → ℕ → unitInterval, Topology.IsEmbedding f := by sorry\nnoncomputable section\n\nopen Classical in\n\nlemma exists_linearIsometry_extension (E : Set ℝ) (hE : IsClosed E) (hE₁ : E ⊆ unitInterval)\n [CompactSpace E] :\n ∃ _Φ : C(E, ℝ) →ₗᵢ[ℝ] C(unitInterval, ℝ), True := by sorry\n\nlemma closed_subset_interval_implies_cont_embeds\n (E : Set ℝ) (hE : IsClosed E) (hE₁ : E ⊆ unitInterval) :\n ∃ _ : CompactSpace E, ∃ f : C(E, ℝ) → C(unitInterval, ℝ), Isometry f := by sorry"} -{"project_name": "BanachMazur", "name": "isometry_precomp_of_surjective", "type": "lemma", "code": "import Mathlib\n\nopen TopologicalSpace Set\n\nopen scoped Topology\n\nuniverse u v\n\nvariable {K : Type u} {X : Type v}\n\nlemma compact_hausdorff_coincide\n {τ τ' : TopologicalSpace K}\n (hτ : @IsCompact K τ Set.univ)\n (hτ' : @T2Space K τ')\n (h : τ ≤ τ') :\n τ = τ' := by sorry\n\nlemma separable_implies_compact_metrizable_weak_star\n [NormedAddCommGroup X] [NormedSpace ℝ X] [SeparableSpace X] :\n let B := WeakDual.toStrongDual ⁻¹' Metric.closedBall (0 : StrongDual ℝ X) 1;\n IsCompact B ∧ IsSeparable B := by sorry\n\nlemma separable_banach_implies_embeds_cont\n [NormedAddCommGroup X] [NormedSpace ℝ X] :\n ∃ (K : Type v), ∃ _ : TopologicalSpace K, ∃ _ : CompactSpace K,\n ∃ f : X → C(K, ℝ), Isometry f := by sorry\n\nlemma compact_metrizable_implies_embeds\n [TopologicalSpace K] [CompactSpace K] [MetrizableSpace K] :\n ∃ f : K → ℕ → unitInterval, Topology.IsEmbedding f := by sorry\nnoncomputable section\n\nopen Classical in\n\nlemma exists_linearIsometry_extension (E : Set ℝ) (hE : IsClosed E) (hE₁ : E ⊆ unitInterval)\n [CompactSpace E] :\n ∃ _Φ : C(E, ℝ) →ₗᵢ[ℝ] C(unitInterval, ℝ), True := by sorry\n\nlemma closed_subset_interval_implies_cont_embeds\n (E : Set ℝ) (hE : IsClosed E) (hE₁ : E ⊆ unitInterval) :\n ∃ _ : CompactSpace E, ∃ f : C(E, ℝ) → C(unitInterval, ℝ), Isometry f := by sorry\n\nend\n\nlemma isometry_precomp_of_surjective\n {X Y : Type*} [TopologicalSpace X] [CompactSpace X]\n [TopologicalSpace Y] [CompactSpace Y]\n (π : C(X, Y)) (hπ : Function.Surjective π) :\n Isometry (fun (f : C(Y, ℝ)) => f.comp π) := by sorry"} -{"project_name": "BanachMazur", "name": "compact_metrizable_implies_cont_embeds", "type": "lemma", "code": "import Mathlib\n\nopen TopologicalSpace Set\n\nopen scoped Topology\n\nuniverse u v\n\nvariable {K : Type u} {X : Type v}\n\nlemma compact_hausdorff_coincide\n {τ τ' : TopologicalSpace K}\n (hτ : @IsCompact K τ Set.univ)\n (hτ' : @T2Space K τ')\n (h : τ ≤ τ') :\n τ = τ' := by sorry\n\nlemma separable_implies_compact_metrizable_weak_star\n [NormedAddCommGroup X] [NormedSpace ℝ X] [SeparableSpace X] :\n let B := WeakDual.toStrongDual ⁻¹' Metric.closedBall (0 : StrongDual ℝ X) 1;\n IsCompact B ∧ IsSeparable B := by sorry\n\nlemma separable_banach_implies_embeds_cont\n [NormedAddCommGroup X] [NormedSpace ℝ X] :\n ∃ (K : Type v), ∃ _ : TopologicalSpace K, ∃ _ : CompactSpace K,\n ∃ f : X → C(K, ℝ), Isometry f := by sorry\n\nlemma compact_metrizable_implies_embeds\n [TopologicalSpace K] [CompactSpace K] [MetrizableSpace K] :\n ∃ f : K → ℕ → unitInterval, Topology.IsEmbedding f := by sorry\nnoncomputable section\n\nopen Classical in\n\nlemma exists_linearIsometry_extension (E : Set ℝ) (hE : IsClosed E) (hE₁ : E ⊆ unitInterval)\n [CompactSpace E] :\n ∃ _Φ : C(E, ℝ) →ₗᵢ[ℝ] C(unitInterval, ℝ), True := by sorry\n\nlemma closed_subset_interval_implies_cont_embeds\n (E : Set ℝ) (hE : IsClosed E) (hE₁ : E ⊆ unitInterval) :\n ∃ _ : CompactSpace E, ∃ f : C(E, ℝ) → C(unitInterval, ℝ), Isometry f := by sorry\n\nend\n\nlemma isometry_precomp_of_surjective\n {X Y : Type*} [TopologicalSpace X] [CompactSpace X]\n [TopologicalSpace Y] [CompactSpace Y]\n (π : C(X, Y)) (hπ : Function.Surjective π) :\n Isometry (fun (f : C(Y, ℝ)) => f.comp π) := by sorry\n\nlemma compact_metrizable_implies_cont_embeds\n [TopologicalSpace K] [CompactSpace K] [MetrizableSpace K]:\n ∃ f : C(K, ℝ) → C(unitInterval, ℝ), Isometry f := by sorry"} -{"project_name": "BanachMazur", "name": "banach_mazur", "type": "theorem", "code": "import Mathlib\nnoncomputable section\n\nopen TopologicalSpace\n/-- **Banach–Mazur Theorem**: Every separable Banach space over `ℝ` admits a linear isometric\nembedding into `C([0,1], ℝ)`, the space of continuous real-valued functions on the unit interval\nwith the supremum norm.\n**Remark**: The completeness part of the Banach space, i.e., `CompleteSpace E`, is not needed in\nthe proof. That is, every separable normed vector space over `ℝ` admits a linear isometric\nembedding into `C([0,1], ℝ)`.\n-/\n\ntheorem banach_mazur (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E]\n [SeparableSpace E] :\n Nonempty (E →ₗᵢ[ℝ] C(unitInterval, ℝ)) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.BanachMazur.BackgroundLemmas\nopen TopologicalSpace Set\nopen scoped Topology\nuniverse u v\nvariable {K : Type u} {X : Type v}\nlemma compact_hausdorff_coincide\n {τ τ' : TopologicalSpace K}\n (hτ : @IsCompact K τ Set.univ)\n (hτ' : @T2Space K τ')\n (h : τ ≤ τ') :\n τ = τ' := by sorry\nlemma separable_implies_compact_metrizable_weak_star\n [NormedAddCommGroup X] [NormedSpace ℝ X] [SeparableSpace X] :\n let B := WeakDual.toStrongDual ⁻¹' Metric.closedBall (0 : StrongDual ℝ X) 1;\n IsCompact B ∧ IsSeparable B := by sorry\nlemma separable_banach_implies_embeds_cont\n [NormedAddCommGroup X] [NormedSpace ℝ X] :\n ∃ (K : Type v), ∃ _ : TopologicalSpace K, ∃ _ : CompactSpace K,\n ∃ f : X → C(K, ℝ), Isometry f := by sorry\nlemma compact_metrizable_implies_embeds\n [TopologicalSpace K] [CompactSpace K] [MetrizableSpace K] :\n ∃ f : K → ℕ → unitInterval, Topology.IsEmbedding f := by sorry\nnoncomputable section\nopen Classical in\nlemma exists_linearIsometry_extension (E : Set ℝ) (hE : IsClosed E) (hE₁ : E ⊆ unitInterval)\n [CompactSpace E] :\n ∃ _Φ : C(E, ℝ) →ₗᵢ[ℝ] C(unitInterval, ℝ), True := by sorry\nlemma closed_subset_interval_implies_cont_embeds\n (E : Set ℝ) (hE : IsClosed E) (hE₁ : E ⊆ unitInterval) :\n ∃ _ : CompactSpace E, ∃ f : C(E, ℝ) → C(unitInterval, ℝ), Isometry f := by sorry\nend\nlemma isometry_precomp_of_surjective\n {X Y : Type*} [TopologicalSpace X] [CompactSpace X]\n [TopologicalSpace Y] [CompactSpace Y]\n (π : C(X, Y)) (hπ : Function.Surjective π) :\n Isometry (fun (f : C(Y, ℝ)) => f.comp π) := by sorry\nlemma compact_metrizable_implies_cont_embeds\n [TopologicalSpace K] [CompactSpace K] [MetrizableSpace K]:\n ∃ f : C(K, ℝ) → C(unitInterval, ℝ), Isometry f := by sorry"} -{"project_name": "BauerFike", "name": "IsSubordinateMatrixNorm.norm_mul_le", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\n\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\n\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry"} -{"project_name": "BauerFike", "name": "IsSubordinateMatrixNorm.eigenvalue_le_norm", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\n\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\n\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry\n\nlemma IsSubordinateMatrixNorm.eigenvalue_le_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ,\n Module.End.HasEigenvalue (toLin' M) γ → ‖γ‖ ≤ norm M := sorry"} -{"project_name": "BauerFike", "name": "IsSubordinateMatrixNorm.nonneg", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\n\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\n\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry\n\nlemma IsSubordinateMatrixNorm.eigenvalue_le_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ,\n Module.End.HasEigenvalue (toLin' M) γ → ‖γ‖ ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.nonneg\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M := sorry"} -{"project_name": "BauerFike", "name": "IsSubordinateMatrixNorm.diagonal_norm", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\n\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\n\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry\n\nlemma IsSubordinateMatrixNorm.eigenvalue_le_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ,\n Module.End.HasEigenvalue (toLin' M) γ → ‖γ‖ ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.nonneg\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.diagonal_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖ := sorry"} -{"project_name": "BauerFike", "name": "IsSubordinateMatrixNorm.identity_norm", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\n\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\n\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry\n\nlemma IsSubordinateMatrixNorm.eigenvalue_le_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ,\n Module.End.HasEigenvalue (toLin' M) γ → ‖γ‖ ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.nonneg\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.diagonal_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖ := sorry\n\nlemma IsSubordinateMatrixNorm.identity_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1 := sorry"} -{"project_name": "BauerFike", "name": "conditionNumber_def", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\n\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\n\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry\n\nlemma IsSubordinateMatrixNorm.eigenvalue_le_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ,\n Module.End.HasEigenvalue (toLin' M) γ → ‖γ‖ ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.nonneg\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.diagonal_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖ := sorry\n\nlemma IsSubordinateMatrixNorm.identity_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1 := sorry\n/-- The condition number of an invertible matrix V with respect to a matrix norm is\n\ndefined as κ(V) = ‖V‖ ‖V⁻¹‖. -/\nnoncomputable def conditionNumber (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) : ℝ :=\n norm V * norm V⁻¹\n\nlemma conditionNumber_def (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) :\n conditionNumber norm V = norm V * norm V⁻¹ := sorry"} -{"project_name": "BauerFike", "name": "Matrix.isDiag_sub_smul_one", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\n\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\n\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry\n\nlemma IsSubordinateMatrixNorm.eigenvalue_le_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ,\n Module.End.HasEigenvalue (toLin' M) γ → ‖γ‖ ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.nonneg\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.diagonal_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖ := sorry\n\nlemma IsSubordinateMatrixNorm.identity_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1 := sorry\n/-- The condition number of an invertible matrix V with respect to a matrix norm is\n\ndefined as κ(V) = ‖V‖ ‖V⁻¹‖. -/\nnoncomputable def conditionNumber (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) : ℝ :=\n norm V * norm V⁻¹\n\nlemma conditionNumber_def (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) :\n conditionNumber norm V = norm V * norm V⁻¹ := sorry\n\nlemma Matrix.isDiag_sub_smul_one {Λ : Matrix (Fin n) (Fin n) ℂ} (hΛ : Λ.IsDiag) (μ : ℂ) :\n Λ - μ • 1 = Matrix.diagonal (fun i => Λ.diag i - μ) := by sorry"} -{"project_name": "BauerFike", "name": "equivalent_eigenvalue_condition", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\n\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\n\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry\n\nlemma IsSubordinateMatrixNorm.eigenvalue_le_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ,\n Module.End.HasEigenvalue (toLin' M) γ → ‖γ‖ ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.nonneg\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.diagonal_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖ := sorry\n\nlemma IsSubordinateMatrixNorm.identity_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1 := sorry\n/-- The condition number of an invertible matrix V with respect to a matrix norm is\n\ndefined as κ(V) = ‖V‖ ‖V⁻¹‖. -/\nnoncomputable def conditionNumber (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) : ℝ :=\n norm V * norm V⁻¹\n\nlemma conditionNumber_def (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) :\n conditionNumber norm V = norm V * norm V⁻¹ := sorry\n\nlemma Matrix.isDiag_sub_smul_one {Λ : Matrix (Fin n) (Fin n) ℂ} (hΛ : Λ.IsDiag) (μ : ℂ) :\n Λ - μ • 1 = Matrix.diagonal (fun i => Λ.diag i - μ) := by sorry\n/-- Let A be diagonalizable with eigenvector matrix V and eigenvalue matrix Λ.\nLet μ be an eigenvalue of the perturbed matrix A + δA.\nIf μ is not an eigenvalue of A, then -1 is an eigenvalue of (Λ - μI)⁻¹ V⁻¹ δA V. -/\n\nlemma equivalent_eigenvalue_condition\n (A : Matrix (Fin n) (Fin n) ℂ) (V Λ δA : Matrix (Fin n) (Fin n) ℂ)\n (hV : IsUnit (V.det)) (hΛ : Λ.IsDiag) (hA : A = V * Λ * V⁻¹)\n (μ : ℂ) (hμ : Module.End.HasEigenvalue (toLin' (A + δA)) μ)\n (hμ_not_in_Λ : ∀ i : Fin n, Λ i i ≠ μ) :\n Module.End.HasEigenvalue (toLin' ((Λ - μ • 1)⁻¹ * V⁻¹ * δA * V)) (-1) := by sorry"} -{"project_name": "BauerFike", "name": "norm_inverted_diagonal", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\n\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\n\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry\n\nlemma IsSubordinateMatrixNorm.eigenvalue_le_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ,\n Module.End.HasEigenvalue (toLin' M) γ → ‖γ‖ ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.nonneg\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M := sorry\n\nlemma IsSubordinateMatrixNorm.diagonal_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖ := sorry\n\nlemma IsSubordinateMatrixNorm.identity_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1 := sorry\n/-- The condition number of an invertible matrix V with respect to a matrix norm is\n\ndefined as κ(V) = ‖V‖ ‖V⁻¹‖. -/\nnoncomputable def conditionNumber (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) : ℝ :=\n norm V * norm V⁻¹\n\nlemma conditionNumber_def (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) :\n conditionNumber norm V = norm V * norm V⁻¹ := sorry\n\nlemma Matrix.isDiag_sub_smul_one {Λ : Matrix (Fin n) (Fin n) ℂ} (hΛ : Λ.IsDiag) (μ : ℂ) :\n Λ - μ • 1 = Matrix.diagonal (fun i => Λ.diag i - μ) := by sorry\n/-- Let A be diagonalizable with eigenvector matrix V and eigenvalue matrix Λ.\nLet μ be an eigenvalue of the perturbed matrix A + δA.\nIf μ is not an eigenvalue of A, then -1 is an eigenvalue of (Λ - μI)⁻¹ V⁻¹ δA V. -/\n\nlemma equivalent_eigenvalue_condition\n (A : Matrix (Fin n) (Fin n) ℂ) (V Λ δA : Matrix (Fin n) (Fin n) ℂ)\n (hV : IsUnit (V.det)) (hΛ : Λ.IsDiag) (hA : A = V * Λ * V⁻¹)\n (μ : ℂ) (hμ : Module.End.HasEigenvalue (toLin' (A + δA)) μ)\n (hμ_not_in_Λ : ∀ i : Fin n, Λ i i ≠ μ) :\n Module.End.HasEigenvalue (toLin' ((Λ - μ • 1)⁻¹ * V⁻¹ * δA * V)) (-1) := by sorry\n/-- Let Λ be a diagonal matrix with diagonal entries λ₁, ..., λₙ.\nFor any scalar μ such that λᵢ ≠ μ for all i, the norm of (Λ - μI)⁻¹ is\n‖(Λ - μI)⁻¹‖ = 1 / min |λᵢ - μ|. -/\n\nlemma norm_inverted_diagonal (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (Λ : Matrix (Fin n) (Fin n) ℂ) (hΛ : Λ.IsDiag)\n (μ : ℂ) (hμ : ∀ i : Fin n, Λ i i ≠ μ)\n (hnorm : IsSubordinateMatrixNorm norm) :\n norm (Λ - μ • 1)⁻¹ = 1 / (⨅ i : Fin n, ‖Λ i i - μ‖) := by sorry"} -{"project_name": "BauerFike", "name": "bauer_fike", "type": "theorem", "code": "import Mathlib\n\nopen Matrix BigOperators\n\nvariable {n : ℕ}\n/-- Bauer-Fike Theorem: Let A be a diagonalizable matrix with eigenvector matrix V\nand eigenvalue matrix Λ. Let μ be an eigenvalue of the perturbed matrix A + δA.\nThen there exists an eigenvalue λ of A such that:\n|λ - μ| ≤ κ(V) ‖δA‖\nwhere κ(V) is the condition number of V. -/\n\ntheorem bauer_fike\n (A : Matrix (Fin n) (Fin n) ℂ) (V Λ δA : Matrix (Fin n) (Fin n) ℂ)\n (hV : IsUnit (V.det)) (hΛ : Λ.IsDiag) (hA : A = V * Λ * V⁻¹)\n (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (hnorm : IsSubordinateMatrixNorm norm)\n (μ : ℂ) (hμ : Module.End.HasEigenvalue (toLin' (A + δA)) μ) :\n ∃ i : Fin n, ‖Λ i i - μ‖ ≤ conditionNumber norm V * norm δA := by sorry", "imported_file": "-- File: LiveLeanTriathlon.BauerFike.BackgroundLemmas\nopen Matrix\nvariable {n : ℕ}\n/-- We define a property to hold several characteristics of subordinate norms. -/\ndef IsSubordinateMatrixNorm (norm : Matrix (Fin n) (Fin n) ℂ → ℝ) : Prop :=\n (∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ, Module.End.HasEigenvalue (toLin' M) γ →\n ‖γ‖ ≤ norm M) ∧\n (∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M) ∧\n (∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖) ∧\n (norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1)\nlemma IsSubordinateMatrixNorm.norm_mul_le\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M₁ M₂ : Matrix (Fin n) (Fin n) ℂ, norm (M₁ * M₂) ≤ norm M₁ * norm M₂ := sorry\nlemma IsSubordinateMatrixNorm.eigenvalue_le_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, ∀ γ : ℂ,\n Module.End.HasEigenvalue (toLin' M) γ → ‖γ‖ ≤ norm M := sorry\nlemma IsSubordinateMatrixNorm.nonneg\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ M : Matrix (Fin n) (Fin n) ℂ, 0 ≤ norm M := sorry\nlemma IsSubordinateMatrixNorm.diagonal_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n ∀ D : Matrix (Fin n) (Fin n) ℂ, D.IsDiag → norm D = ⨆ i : Fin n, ‖D i i‖ := sorry\nlemma IsSubordinateMatrixNorm.identity_norm\n {norm : Matrix (Fin n) (Fin n) ℂ → ℝ}\n (hnorm : IsSubordinateMatrixNorm norm) :\n norm (1 : Matrix (Fin n) (Fin n) ℂ) = 1 := sorry\n/-- The condition number of an invertible matrix V with respect to a matrix norm is\ndefined as κ(V) = ‖V‖ ‖V⁻¹‖. -/\nnoncomputable def conditionNumber (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) : ℝ :=\n norm V * norm V⁻¹\nlemma conditionNumber_def (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (V : Matrix (Fin n) (Fin n) ℂ) :\n conditionNumber norm V = norm V * norm V⁻¹ := sorry\nlemma Matrix.isDiag_sub_smul_one {Λ : Matrix (Fin n) (Fin n) ℂ} (hΛ : Λ.IsDiag) (μ : ℂ) :\n Λ - μ • 1 = Matrix.diagonal (fun i => Λ.diag i - μ) := by sorry\n/-- Let A be diagonalizable with eigenvector matrix V and eigenvalue matrix Λ.\nLet μ be an eigenvalue of the perturbed matrix A + δA.\nIf μ is not an eigenvalue of A, then -1 is an eigenvalue of (Λ - μI)⁻¹ V⁻¹ δA V. -/\nlemma equivalent_eigenvalue_condition\n (A : Matrix (Fin n) (Fin n) ℂ) (V Λ δA : Matrix (Fin n) (Fin n) ℂ)\n (hV : IsUnit (V.det)) (hΛ : Λ.IsDiag) (hA : A = V * Λ * V⁻¹)\n (μ : ℂ) (hμ : Module.End.HasEigenvalue (toLin' (A + δA)) μ)\n (hμ_not_in_Λ : ∀ i : Fin n, Λ i i ≠ μ) :\n Module.End.HasEigenvalue (toLin' ((Λ - μ • 1)⁻¹ * V⁻¹ * δA * V)) (-1) := by sorry\n/-- Let Λ be a diagonal matrix with diagonal entries λ₁, ..., λₙ.\nFor any scalar μ such that λᵢ ≠ μ for all i, the norm of (Λ - μI)⁻¹ is\n‖(Λ - μI)⁻¹‖ = 1 / min |λᵢ - μ|. -/\nlemma norm_inverted_diagonal (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (Λ : Matrix (Fin n) (Fin n) ℂ) (hΛ : Λ.IsDiag)\n (μ : ℂ) (hμ : ∀ i : Fin n, Λ i i ≠ μ)\n (hnorm : IsSubordinateMatrixNorm norm) :\n norm (Λ - μ • 1)⁻¹ = 1 / (⨅ i : Fin n, ‖Λ i i - μ‖) := by sorry"} -{"project_name": "BeckmanQuarlesTheorem", "name": "beckmann_quarles", "type": "theorem", "code": "import Mathlib\n\ntheorem beckmann_quarles {d : ℕ} {f : EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)}\n (h : ∀ x y : EuclideanSpace ℝ (Fin d), dist x y = 1 → dist (f x) (f y) = 1) :\n Isometry f := by sorry"} -{"project_name": "BergeTheorem", "name": "SimpleGraph.isAlternating_symmDiff_of_isMatching", "type": "lemma", "code": "import Mathlib\n\nopen SimpleGraph SimpleGraph.Subgraph\n\nopen scoped symmDiff\n\nvariable {V : Type*} {G G' : SimpleGraph V}\n/--\nAn **`M`-augmenting path** for a matching `M` in `G` is a path in `G` such that:\n* its starting vertex is not in `M.support` (unmatched by `M`),\n* its ending vertex is not in `M.support` (unmatched by `M`),\n* the endpoints are distinct (so the path is nontrivial), and\n* the edges of the path alternate between edges not in `M` and edges in `M`.\nSince the endpoints are unmatched, the first and last edges are necessarily not in `M`, so an\naugmenting path has odd length and contains exactly one more non-`M`-edge than `M`-edges.\n-/\n\ndef SimpleGraph.Subgraph.IsAugmentingPath (M : G.Subgraph) {u v : V} (p : G.Walk u v) : Prop :=\n p.IsPath ∧\n u ∉ M.support ∧\n v ∉ M.support ∧\n u ≠ v ∧\n p.toSubgraph.spanningCoe.IsAlternating M.spanningCoe\n/--\nThe symmetric difference of two matchings `M` and `M'` (viewed as spanning subgraphs) is\nalternating with respect to `M`. Together with the symmetric version, this implies that\nthe symmetric difference decomposes into paths and cycles whose edges alternate between\nthose in `M` and those in `M'`.\n-/\n\nlemma SimpleGraph.isAlternating_symmDiff_of_isMatching\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching) :\n (M.spanningCoe ∆ M'.spanningCoe).IsAlternating M.spanningCoe := by sorry"} -{"project_name": "BergeTheorem", "name": "symmDiff_augmenting_adj_unique", "type": "lemma", "code": "import Mathlib\n\nopen SimpleGraph SimpleGraph.Subgraph\n\nopen scoped symmDiff\n\nvariable {V : Type*} {G G' : SimpleGraph V}\n/--\nAn **`M`-augmenting path** for a matching `M` in `G` is a path in `G` such that:\n* its starting vertex is not in `M.support` (unmatched by `M`),\n* its ending vertex is not in `M.support` (unmatched by `M`),\n* the endpoints are distinct (so the path is nontrivial), and\n* the edges of the path alternate between edges not in `M` and edges in `M`.\nSince the endpoints are unmatched, the first and last edges are necessarily not in `M`, so an\naugmenting path has odd length and contains exactly one more non-`M`-edge than `M`-edges.\n-/\n\ndef SimpleGraph.Subgraph.IsAugmentingPath (M : G.Subgraph) {u v : V} (p : G.Walk u v) : Prop :=\n p.IsPath ∧\n u ∉ M.support ∧\n v ∉ M.support ∧\n u ≠ v ∧\n p.toSubgraph.spanningCoe.IsAlternating M.spanningCoe\n/--\nThe symmetric difference of two matchings `M` and `M'` (viewed as spanning subgraphs) is\nalternating with respect to `M`. Together with the symmetric version, this implies that\nthe symmetric difference decomposes into paths and cycles whose edges alternate between\nthose in `M` and those in `M'`.\n-/\n\nlemma SimpleGraph.isAlternating_symmDiff_of_isMatching\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching) :\n (M.spanningCoe ∆ M'.spanningCoe).IsAlternating M.spanningCoe := by sorry\n/-- The symmetric difference `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe` for an\n`M`-augmenting path `p` has max degree ≤ 1: any vertex `w` has at most one `D`-neighbor.\n**Proof sketch**: Suppose `D.Adj w x` and `D.Adj w y`.\n- If both come from `M`: `M.IsMatching` gives `x = y`.\n- If one comes from `M` and the other from `p`:\n - If `w` is an endpoint `u` or `v`, then `w ∉ M.support` contradicts having an `M`-neighbor.\n - If `w` is internal: its `M`-neighbor must be a `p`-neighbor (by the alternating property),\n but this contradicts `M.IsMatching` (the `M`-edge goes to a non-`p` vertex).\n- If both come from `p` (non-`M` `p`-edges): the alternating property forces `x = y`. -/\nprivate lemma symmDiff_augmenting_adj_unique\n {M : G.Subgraph} (hM : M.IsMatching) {u v : V} {p : G.Walk u v}\n (hp : M.IsAugmentingPath p) {w x y : V}\n (hx : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x)\n (hy : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w y) : x = y := by sorry"} -{"project_name": "BergeTheorem", "name": "augmentingSymmDiff_edgeSet", "type": "lemma", "code": "import Mathlib\n\nopen SimpleGraph SimpleGraph.Subgraph\n\nopen scoped symmDiff\n\nvariable {V : Type*} {G G' : SimpleGraph V}\n/--\nAn **`M`-augmenting path** for a matching `M` in `G` is a path in `G` such that:\n* its starting vertex is not in `M.support` (unmatched by `M`),\n* its ending vertex is not in `M.support` (unmatched by `M`),\n* the endpoints are distinct (so the path is nontrivial), and\n* the edges of the path alternate between edges not in `M` and edges in `M`.\nSince the endpoints are unmatched, the first and last edges are necessarily not in `M`, so an\naugmenting path has odd length and contains exactly one more non-`M`-edge than `M`-edges.\n-/\n\ndef SimpleGraph.Subgraph.IsAugmentingPath (M : G.Subgraph) {u v : V} (p : G.Walk u v) : Prop :=\n p.IsPath ∧\n u ∉ M.support ∧\n v ∉ M.support ∧\n u ≠ v ∧\n p.toSubgraph.spanningCoe.IsAlternating M.spanningCoe\n/--\nThe symmetric difference of two matchings `M` and `M'` (viewed as spanning subgraphs) is\nalternating with respect to `M`. Together with the symmetric version, this implies that\nthe symmetric difference decomposes into paths and cycles whose edges alternate between\nthose in `M` and those in `M'`.\n-/\n\nlemma SimpleGraph.isAlternating_symmDiff_of_isMatching\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching) :\n (M.spanningCoe ∆ M'.spanningCoe).IsAlternating M.spanningCoe := by sorry\n/-- The symmetric difference `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe` for an\n`M`-augmenting path `p` has max degree ≤ 1: any vertex `w` has at most one `D`-neighbor.\n**Proof sketch**: Suppose `D.Adj w x` and `D.Adj w y`.\n- If both come from `M`: `M.IsMatching` gives `x = y`.\n- If one comes from `M` and the other from `p`:\n - If `w` is an endpoint `u` or `v`, then `w ∉ M.support` contradicts having an `M`-neighbor.\n - If `w` is internal: its `M`-neighbor must be a `p`-neighbor (by the alternating property),\n but this contradicts `M.IsMatching` (the `M`-edge goes to a non-`p` vertex).\n- If both come from `p` (non-`M` `p`-edges): the alternating property forces `x = y`. -/\nprivate lemma symmDiff_augmenting_adj_unique\n {M : G.Subgraph} (hM : M.IsMatching) {u v : V} {p : G.Walk u v}\n (hp : M.IsAugmentingPath p) {w x y : V}\n (hx : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x)\n (hy : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w y) : x = y := by sorry\n/-- The symmetric difference subgraph `M' = M.spanningCoe ∆ p.toSubgraph.spanningCoe`\n(restricted to the support of the symmetric difference graph). -/\nprivate noncomputable def augmentingSymmDiff (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n G.Subgraph where\n verts := {w | ∃ x, (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x}\n Adj := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj\n adj_sub h :=\n symmDiff_le_sup.trans (sup_le (Subgraph.spanningCoe_le M) (p.toSubgraph.spanningCoe_le)) h\n edge_vert h := ⟨_, h⟩\n symm := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).symm\n/-- The edge set of `augmentingSymmDiff M p` equals `M.edgeSet ∆ p.edgeSet`. -/\nprivate lemma augmentingSymmDiff_edgeSet (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n (augmentingSymmDiff M p).edgeSet = M.edgeSet ∆ p.edgeSet := by sorry"} -{"project_name": "BergeTheorem", "name": "SimpleGraph.Subgraph.IsMatching.not_maximal_of_augmentingPath", "type": "theorem", "code": "import Mathlib\n\nopen SimpleGraph SimpleGraph.Subgraph\n\nopen scoped symmDiff\n\nvariable {V : Type*} {G G' : SimpleGraph V}\n/--\nAn **`M`-augmenting path** for a matching `M` in `G` is a path in `G` such that:\n* its starting vertex is not in `M.support` (unmatched by `M`),\n* its ending vertex is not in `M.support` (unmatched by `M`),\n* the endpoints are distinct (so the path is nontrivial), and\n* the edges of the path alternate between edges not in `M` and edges in `M`.\nSince the endpoints are unmatched, the first and last edges are necessarily not in `M`, so an\naugmenting path has odd length and contains exactly one more non-`M`-edge than `M`-edges.\n-/\n\ndef SimpleGraph.Subgraph.IsAugmentingPath (M : G.Subgraph) {u v : V} (p : G.Walk u v) : Prop :=\n p.IsPath ∧\n u ∉ M.support ∧\n v ∉ M.support ∧\n u ≠ v ∧\n p.toSubgraph.spanningCoe.IsAlternating M.spanningCoe\n/--\nThe symmetric difference of two matchings `M` and `M'` (viewed as spanning subgraphs) is\nalternating with respect to `M`. Together with the symmetric version, this implies that\nthe symmetric difference decomposes into paths and cycles whose edges alternate between\nthose in `M` and those in `M'`.\n-/\n\nlemma SimpleGraph.isAlternating_symmDiff_of_isMatching\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching) :\n (M.spanningCoe ∆ M'.spanningCoe).IsAlternating M.spanningCoe := by sorry\n/-- The symmetric difference `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe` for an\n`M`-augmenting path `p` has max degree ≤ 1: any vertex `w` has at most one `D`-neighbor.\n**Proof sketch**: Suppose `D.Adj w x` and `D.Adj w y`.\n- If both come from `M`: `M.IsMatching` gives `x = y`.\n- If one comes from `M` and the other from `p`:\n - If `w` is an endpoint `u` or `v`, then `w ∉ M.support` contradicts having an `M`-neighbor.\n - If `w` is internal: its `M`-neighbor must be a `p`-neighbor (by the alternating property),\n but this contradicts `M.IsMatching` (the `M`-edge goes to a non-`p` vertex).\n- If both come from `p` (non-`M` `p`-edges): the alternating property forces `x = y`. -/\nprivate lemma symmDiff_augmenting_adj_unique\n {M : G.Subgraph} (hM : M.IsMatching) {u v : V} {p : G.Walk u v}\n (hp : M.IsAugmentingPath p) {w x y : V}\n (hx : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x)\n (hy : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w y) : x = y := by sorry\n/-- The symmetric difference subgraph `M' = M.spanningCoe ∆ p.toSubgraph.spanningCoe`\n(restricted to the support of the symmetric difference graph). -/\nprivate noncomputable def augmentingSymmDiff (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n G.Subgraph where\n verts := {w | ∃ x, (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x}\n Adj := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj\n adj_sub h :=\n symmDiff_le_sup.trans (sup_le (Subgraph.spanningCoe_le M) (p.toSubgraph.spanningCoe_le)) h\n edge_vert h := ⟨_, h⟩\n symm := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).symm\n/-- The edge set of `augmentingSymmDiff M p` equals `M.edgeSet ∆ p.edgeSet`. -/\nprivate lemma augmentingSymmDiff_edgeSet (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n (augmentingSymmDiff M p).edgeSet = M.edgeSet ∆ p.edgeSet := by sorry\n/--\n**Berge's theorem (forward direction)**: If there is an `M`-augmenting path in `G`, then `M` is\nnot a matching of maximal cardinality.\n*Proof*: Let `p` be an `M`-augmenting path from `u` to `v`. Define `M'` as the subgraph induced\nby `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe`. Since `p` alternates between non-`M` and\n`M` edges with both endpoints unmatched:\n* `M'` is a matching: `D` has degree ≤ 1 at every vertex (by `symmDiff_augmenting_adj_unique`).\n* `|M'.edgeSet| = |M.edgeSet ∆ p.edgeSet| = |M.edgeSet| + 1`: the augmenting path has one more\n non-`M` edge than `M`-edge (by `augmentingPath_edgeCount`).\n-/\n\ntheorem SimpleGraph.Subgraph.IsMatching.not_maximal_of_augmentingPath\n [Fintype V] [DecidableEq V] {M : G.Subgraph} (hM : M.IsMatching)\n {u v : V} {p : G.Walk u v} (hp : M.IsAugmentingPath p) :\n ∃ M' : G.Subgraph, M'.IsMatching ∧ M.edgeSet.ncard < M'.edgeSet.ncard := by sorry"} -{"project_name": "BergeTheorem", "name": "symmDiff_contains_augmentingPath", "type": "lemma", "code": "import Mathlib\n\nopen SimpleGraph SimpleGraph.Subgraph\n\nopen scoped symmDiff\n\nvariable {V : Type*} {G G' : SimpleGraph V}\n/--\nAn **`M`-augmenting path** for a matching `M` in `G` is a path in `G` such that:\n* its starting vertex is not in `M.support` (unmatched by `M`),\n* its ending vertex is not in `M.support` (unmatched by `M`),\n* the endpoints are distinct (so the path is nontrivial), and\n* the edges of the path alternate between edges not in `M` and edges in `M`.\nSince the endpoints are unmatched, the first and last edges are necessarily not in `M`, so an\naugmenting path has odd length and contains exactly one more non-`M`-edge than `M`-edges.\n-/\n\ndef SimpleGraph.Subgraph.IsAugmentingPath (M : G.Subgraph) {u v : V} (p : G.Walk u v) : Prop :=\n p.IsPath ∧\n u ∉ M.support ∧\n v ∉ M.support ∧\n u ≠ v ∧\n p.toSubgraph.spanningCoe.IsAlternating M.spanningCoe\n/--\nThe symmetric difference of two matchings `M` and `M'` (viewed as spanning subgraphs) is\nalternating with respect to `M`. Together with the symmetric version, this implies that\nthe symmetric difference decomposes into paths and cycles whose edges alternate between\nthose in `M` and those in `M'`.\n-/\n\nlemma SimpleGraph.isAlternating_symmDiff_of_isMatching\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching) :\n (M.spanningCoe ∆ M'.spanningCoe).IsAlternating M.spanningCoe := by sorry\n/-- The symmetric difference `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe` for an\n`M`-augmenting path `p` has max degree ≤ 1: any vertex `w` has at most one `D`-neighbor.\n**Proof sketch**: Suppose `D.Adj w x` and `D.Adj w y`.\n- If both come from `M`: `M.IsMatching` gives `x = y`.\n- If one comes from `M` and the other from `p`:\n - If `w` is an endpoint `u` or `v`, then `w ∉ M.support` contradicts having an `M`-neighbor.\n - If `w` is internal: its `M`-neighbor must be a `p`-neighbor (by the alternating property),\n but this contradicts `M.IsMatching` (the `M`-edge goes to a non-`p` vertex).\n- If both come from `p` (non-`M` `p`-edges): the alternating property forces `x = y`. -/\nprivate lemma symmDiff_augmenting_adj_unique\n {M : G.Subgraph} (hM : M.IsMatching) {u v : V} {p : G.Walk u v}\n (hp : M.IsAugmentingPath p) {w x y : V}\n (hx : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x)\n (hy : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w y) : x = y := by sorry\n/-- The symmetric difference subgraph `M' = M.spanningCoe ∆ p.toSubgraph.spanningCoe`\n(restricted to the support of the symmetric difference graph). -/\nprivate noncomputable def augmentingSymmDiff (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n G.Subgraph where\n verts := {w | ∃ x, (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x}\n Adj := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj\n adj_sub h :=\n symmDiff_le_sup.trans (sup_le (Subgraph.spanningCoe_le M) (p.toSubgraph.spanningCoe_le)) h\n edge_vert h := ⟨_, h⟩\n symm := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).symm\n/-- The edge set of `augmentingSymmDiff M p` equals `M.edgeSet ∆ p.edgeSet`. -/\nprivate lemma augmentingSymmDiff_edgeSet (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n (augmentingSymmDiff M p).edgeSet = M.edgeSet ∆ p.edgeSet := by sorry\n/--\n**Berge's theorem (forward direction)**: If there is an `M`-augmenting path in `G`, then `M` is\nnot a matching of maximal cardinality.\n*Proof*: Let `p` be an `M`-augmenting path from `u` to `v`. Define `M'` as the subgraph induced\nby `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe`. Since `p` alternates between non-`M` and\n`M` edges with both endpoints unmatched:\n* `M'` is a matching: `D` has degree ≤ 1 at every vertex (by `symmDiff_augmenting_adj_unique`).\n* `|M'.edgeSet| = |M.edgeSet ∆ p.edgeSet| = |M.edgeSet| + 1`: the augmenting path has one more\n non-`M` edge than `M`-edge (by `augmentingPath_edgeCount`).\n-/\n\ntheorem SimpleGraph.Subgraph.IsMatching.not_maximal_of_augmentingPath\n [Fintype V] [DecidableEq V] {M : G.Subgraph} (hM : M.IsMatching)\n {u v : V} {p : G.Walk u v} (hp : M.IsAugmentingPath p) :\n ∃ M' : G.Subgraph, M'.IsMatching ∧ M.edgeSet.ncard < M'.edgeSet.ncard := by sorry\n/-- Given matchings `M`, `M'` with `|M'| > |M|`, the symmetric difference\n`D = M.spanningCoe ∆ M'.spanningCoe` contains an `M`-augmenting path.\n*Proof sketch*: `D` is alternating w.r.t. `M` (by `isAlternating_symmDiff_of_isMatching`) and\nhas max degree ≤ 2 (at most one `M`-edge and one `M'`-edge per vertex). So `D` decomposes into\npaths and cycles with alternating edges. In each cycle, `|M-edges| = |M'-edges|`. Since\n`|M'| > |M|`, some path component has more `M'`-edges than `M`-edges. The endpoints of such a\npath have degree 1 in `D` and are `M'`-matched but not `M`-matched, making them `M`-unmatched.\nThis path is an `M`-augmenting path. -/\nprivate lemma symmDiff_contains_augmentingPath [Finite V]\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching)\n (hcard : M.edgeSet.ncard < M'.edgeSet.ncard) :\n ∃ (u v : V) (p : G.Walk u v), M.IsAugmentingPath p := by sorry"} -{"project_name": "BergeTheorem", "name": "SimpleGraph.Subgraph.IsMatching.maximal_of_no_augmentingPath", "type": "theorem", "code": "import Mathlib\n\nopen SimpleGraph SimpleGraph.Subgraph\n\nopen scoped symmDiff\n\nvariable {V : Type*} {G G' : SimpleGraph V}\n/--\nAn **`M`-augmenting path** for a matching `M` in `G` is a path in `G` such that:\n* its starting vertex is not in `M.support` (unmatched by `M`),\n* its ending vertex is not in `M.support` (unmatched by `M`),\n* the endpoints are distinct (so the path is nontrivial), and\n* the edges of the path alternate between edges not in `M` and edges in `M`.\nSince the endpoints are unmatched, the first and last edges are necessarily not in `M`, so an\naugmenting path has odd length and contains exactly one more non-`M`-edge than `M`-edges.\n-/\n\ndef SimpleGraph.Subgraph.IsAugmentingPath (M : G.Subgraph) {u v : V} (p : G.Walk u v) : Prop :=\n p.IsPath ∧\n u ∉ M.support ∧\n v ∉ M.support ∧\n u ≠ v ∧\n p.toSubgraph.spanningCoe.IsAlternating M.spanningCoe\n/--\nThe symmetric difference of two matchings `M` and `M'` (viewed as spanning subgraphs) is\nalternating with respect to `M`. Together with the symmetric version, this implies that\nthe symmetric difference decomposes into paths and cycles whose edges alternate between\nthose in `M` and those in `M'`.\n-/\n\nlemma SimpleGraph.isAlternating_symmDiff_of_isMatching\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching) :\n (M.spanningCoe ∆ M'.spanningCoe).IsAlternating M.spanningCoe := by sorry\n/-- The symmetric difference `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe` for an\n`M`-augmenting path `p` has max degree ≤ 1: any vertex `w` has at most one `D`-neighbor.\n**Proof sketch**: Suppose `D.Adj w x` and `D.Adj w y`.\n- If both come from `M`: `M.IsMatching` gives `x = y`.\n- If one comes from `M` and the other from `p`:\n - If `w` is an endpoint `u` or `v`, then `w ∉ M.support` contradicts having an `M`-neighbor.\n - If `w` is internal: its `M`-neighbor must be a `p`-neighbor (by the alternating property),\n but this contradicts `M.IsMatching` (the `M`-edge goes to a non-`p` vertex).\n- If both come from `p` (non-`M` `p`-edges): the alternating property forces `x = y`. -/\nprivate lemma symmDiff_augmenting_adj_unique\n {M : G.Subgraph} (hM : M.IsMatching) {u v : V} {p : G.Walk u v}\n (hp : M.IsAugmentingPath p) {w x y : V}\n (hx : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x)\n (hy : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w y) : x = y := by sorry\n/-- The symmetric difference subgraph `M' = M.spanningCoe ∆ p.toSubgraph.spanningCoe`\n(restricted to the support of the symmetric difference graph). -/\nprivate noncomputable def augmentingSymmDiff (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n G.Subgraph where\n verts := {w | ∃ x, (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x}\n Adj := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj\n adj_sub h :=\n symmDiff_le_sup.trans (sup_le (Subgraph.spanningCoe_le M) (p.toSubgraph.spanningCoe_le)) h\n edge_vert h := ⟨_, h⟩\n symm := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).symm\n/-- The edge set of `augmentingSymmDiff M p` equals `M.edgeSet ∆ p.edgeSet`. -/\nprivate lemma augmentingSymmDiff_edgeSet (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n (augmentingSymmDiff M p).edgeSet = M.edgeSet ∆ p.edgeSet := by sorry\n/--\n**Berge's theorem (forward direction)**: If there is an `M`-augmenting path in `G`, then `M` is\nnot a matching of maximal cardinality.\n*Proof*: Let `p` be an `M`-augmenting path from `u` to `v`. Define `M'` as the subgraph induced\nby `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe`. Since `p` alternates between non-`M` and\n`M` edges with both endpoints unmatched:\n* `M'` is a matching: `D` has degree ≤ 1 at every vertex (by `symmDiff_augmenting_adj_unique`).\n* `|M'.edgeSet| = |M.edgeSet ∆ p.edgeSet| = |M.edgeSet| + 1`: the augmenting path has one more\n non-`M` edge than `M`-edge (by `augmentingPath_edgeCount`).\n-/\n\ntheorem SimpleGraph.Subgraph.IsMatching.not_maximal_of_augmentingPath\n [Fintype V] [DecidableEq V] {M : G.Subgraph} (hM : M.IsMatching)\n {u v : V} {p : G.Walk u v} (hp : M.IsAugmentingPath p) :\n ∃ M' : G.Subgraph, M'.IsMatching ∧ M.edgeSet.ncard < M'.edgeSet.ncard := by sorry\n/-- Given matchings `M`, `M'` with `|M'| > |M|`, the symmetric difference\n`D = M.spanningCoe ∆ M'.spanningCoe` contains an `M`-augmenting path.\n*Proof sketch*: `D` is alternating w.r.t. `M` (by `isAlternating_symmDiff_of_isMatching`) and\nhas max degree ≤ 2 (at most one `M`-edge and one `M'`-edge per vertex). So `D` decomposes into\npaths and cycles with alternating edges. In each cycle, `|M-edges| = |M'-edges|`. Since\n`|M'| > |M|`, some path component has more `M'`-edges than `M`-edges. The endpoints of such a\npath have degree 1 in `D` and are `M'`-matched but not `M`-matched, making them `M`-unmatched.\nThis path is an `M`-augmenting path. -/\nprivate lemma symmDiff_contains_augmentingPath [Finite V]\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching)\n (hcard : M.edgeSet.ncard < M'.edgeSet.ncard) :\n ∃ (u v : V) (p : G.Walk u v), M.IsAugmentingPath p := by sorry\n/--\n**Berge's theorem (backward direction)**: If there is no `M`-augmenting path in `G`, then `M` is\na matching of maximal cardinality.\n*Proof*: Suppose for contradiction that there exists a matching `M'` with `|M'| > |M|`. By\n`symmDiff_contains_augmentingPath`, `M ∆ M'` contains an `M`-augmenting path, contradicting\nthe hypothesis.\n-/\n\ntheorem SimpleGraph.Subgraph.IsMatching.maximal_of_no_augmentingPath\n [Finite V] {M : G.Subgraph} (hM : M.IsMatching)\n (hno : ∀ {u v : V} (p : G.Walk u v), ¬M.IsAugmentingPath p) :\n ∀ M' : G.Subgraph, M'.IsMatching → M'.edgeSet.ncard ≤ M.edgeSet.ncard := by sorry"} -{"project_name": "BergeTheorem", "name": "SimpleGraph.Subgraph.IsMatching.berge", "type": "theorem", "code": "import Mathlib\n\nopen SimpleGraph SimpleGraph.Subgraph\n\nopen scoped symmDiff\n\nvariable {V : Type*} {G G' : SimpleGraph V}\n/--\nAn **`M`-augmenting path** for a matching `M` in `G` is a path in `G` such that:\n* its starting vertex is not in `M.support` (unmatched by `M`),\n* its ending vertex is not in `M.support` (unmatched by `M`),\n* the endpoints are distinct (so the path is nontrivial), and\n* the edges of the path alternate between edges not in `M` and edges in `M`.\nSince the endpoints are unmatched, the first and last edges are necessarily not in `M`, so an\naugmenting path has odd length and contains exactly one more non-`M`-edge than `M`-edges.\n-/\n\ndef SimpleGraph.Subgraph.IsAugmentingPath (M : G.Subgraph) {u v : V} (p : G.Walk u v) : Prop :=\n p.IsPath ∧\n u ∉ M.support ∧\n v ∉ M.support ∧\n u ≠ v ∧\n p.toSubgraph.spanningCoe.IsAlternating M.spanningCoe\n/--\nThe symmetric difference of two matchings `M` and `M'` (viewed as spanning subgraphs) is\nalternating with respect to `M`. Together with the symmetric version, this implies that\nthe symmetric difference decomposes into paths and cycles whose edges alternate between\nthose in `M` and those in `M'`.\n-/\n\nlemma SimpleGraph.isAlternating_symmDiff_of_isMatching\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching) :\n (M.spanningCoe ∆ M'.spanningCoe).IsAlternating M.spanningCoe := by sorry\n/-- The symmetric difference `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe` for an\n`M`-augmenting path `p` has max degree ≤ 1: any vertex `w` has at most one `D`-neighbor.\n**Proof sketch**: Suppose `D.Adj w x` and `D.Adj w y`.\n- If both come from `M`: `M.IsMatching` gives `x = y`.\n- If one comes from `M` and the other from `p`:\n - If `w` is an endpoint `u` or `v`, then `w ∉ M.support` contradicts having an `M`-neighbor.\n - If `w` is internal: its `M`-neighbor must be a `p`-neighbor (by the alternating property),\n but this contradicts `M.IsMatching` (the `M`-edge goes to a non-`p` vertex).\n- If both come from `p` (non-`M` `p`-edges): the alternating property forces `x = y`. -/\nprivate lemma symmDiff_augmenting_adj_unique\n {M : G.Subgraph} (hM : M.IsMatching) {u v : V} {p : G.Walk u v}\n (hp : M.IsAugmentingPath p) {w x y : V}\n (hx : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x)\n (hy : (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w y) : x = y := by sorry\n/-- The symmetric difference subgraph `M' = M.spanningCoe ∆ p.toSubgraph.spanningCoe`\n(restricted to the support of the symmetric difference graph). -/\nprivate noncomputable def augmentingSymmDiff (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n G.Subgraph where\n verts := {w | ∃ x, (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj w x}\n Adj := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).Adj\n adj_sub h :=\n symmDiff_le_sup.trans (sup_le (Subgraph.spanningCoe_le M) (p.toSubgraph.spanningCoe_le)) h\n edge_vert h := ⟨_, h⟩\n symm := (M.spanningCoe ∆ p.toSubgraph.spanningCoe).symm\n/-- The edge set of `augmentingSymmDiff M p` equals `M.edgeSet ∆ p.edgeSet`. -/\nprivate lemma augmentingSymmDiff_edgeSet (M : G.Subgraph) {u v : V} (p : G.Walk u v) :\n (augmentingSymmDiff M p).edgeSet = M.edgeSet ∆ p.edgeSet := by sorry\n/--\n**Berge's theorem (forward direction)**: If there is an `M`-augmenting path in `G`, then `M` is\nnot a matching of maximal cardinality.\n*Proof*: Let `p` be an `M`-augmenting path from `u` to `v`. Define `M'` as the subgraph induced\nby `D = M.spanningCoe ∆ p.toSubgraph.spanningCoe`. Since `p` alternates between non-`M` and\n`M` edges with both endpoints unmatched:\n* `M'` is a matching: `D` has degree ≤ 1 at every vertex (by `symmDiff_augmenting_adj_unique`).\n* `|M'.edgeSet| = |M.edgeSet ∆ p.edgeSet| = |M.edgeSet| + 1`: the augmenting path has one more\n non-`M` edge than `M`-edge (by `augmentingPath_edgeCount`).\n-/\n\ntheorem SimpleGraph.Subgraph.IsMatching.not_maximal_of_augmentingPath\n [Fintype V] [DecidableEq V] {M : G.Subgraph} (hM : M.IsMatching)\n {u v : V} {p : G.Walk u v} (hp : M.IsAugmentingPath p) :\n ∃ M' : G.Subgraph, M'.IsMatching ∧ M.edgeSet.ncard < M'.edgeSet.ncard := by sorry\n/-- Given matchings `M`, `M'` with `|M'| > |M|`, the symmetric difference\n`D = M.spanningCoe ∆ M'.spanningCoe` contains an `M`-augmenting path.\n*Proof sketch*: `D` is alternating w.r.t. `M` (by `isAlternating_symmDiff_of_isMatching`) and\nhas max degree ≤ 2 (at most one `M`-edge and one `M'`-edge per vertex). So `D` decomposes into\npaths and cycles with alternating edges. In each cycle, `|M-edges| = |M'-edges|`. Since\n`|M'| > |M|`, some path component has more `M'`-edges than `M`-edges. The endpoints of such a\npath have degree 1 in `D` and are `M'`-matched but not `M`-matched, making them `M`-unmatched.\nThis path is an `M`-augmenting path. -/\nprivate lemma symmDiff_contains_augmentingPath [Finite V]\n {M : G.Subgraph} {M' : G'.Subgraph} (hM : M.IsMatching) (hM' : M'.IsMatching)\n (hcard : M.edgeSet.ncard < M'.edgeSet.ncard) :\n ∃ (u v : V) (p : G.Walk u v), M.IsAugmentingPath p := by sorry\n/--\n**Berge's theorem (backward direction)**: If there is no `M`-augmenting path in `G`, then `M` is\na matching of maximal cardinality.\n*Proof*: Suppose for contradiction that there exists a matching `M'` with `|M'| > |M|`. By\n`symmDiff_contains_augmentingPath`, `M ∆ M'` contains an `M`-augmenting path, contradicting\nthe hypothesis.\n-/\n\ntheorem SimpleGraph.Subgraph.IsMatching.maximal_of_no_augmentingPath\n [Finite V] {M : G.Subgraph} (hM : M.IsMatching)\n (hno : ∀ {u v : V} (p : G.Walk u v), ¬M.IsAugmentingPath p) :\n ∀ M' : G.Subgraph, M'.IsMatching → M'.edgeSet.ncard ≤ M.edgeSet.ncard := by sorry\n/--\n**Berge's theorem**: A matching `M` in a finite graph `G` is of maximal cardinality if and only if\nthere is no `M`-augmenting path in `G`.\n-/\n\ntheorem SimpleGraph.Subgraph.IsMatching.berge\n [Fintype V] [DecidableEq V] {M : G.Subgraph} (hM : M.IsMatching) :\n (∀ M' : G.Subgraph, M'.IsMatching → M'.edgeSet.ncard ≤ M.edgeSet.ncard) ↔\n ∀ {u v : V} (p : G.Walk u v), ¬M.IsAugmentingPath p := by sorry"} -{"project_name": "BondyTheorem", "name": "hypercube_cycle_has_parallel_edges", "type": "lemma", "code": "import Mathlib\n\nopen Set Finset\n/-- The hypercube graph $Q_n$ has vertex set the subsets of $\\{0,\\ldots,n-1\\}$,\nwith two vertices adjacent iff their symmetric difference has size 1. -/\n\ndef hypercubeGraph (n : ℕ) : SimpleGraph (Finset (Fin n)) where\n Adj A B := (symmDiff A B).card = 1\n symm A B h := by\n simp only at *\n rw [symmDiff_comm]\n exact h\n loopless := ⟨ by simp ⟩\n/-- Any cycle in $Q_n$ contains two distinct edges that are parallel,\ni.e., connecting sets that differ in the same coordinate. -/\n\nlemma hypercube_cycle_has_parallel_edges {n : ℕ} {v : Finset (Fin n)}\n (w : (hypercubeGraph n).Walk v v) (hw : w.IsCycle) :\n ∃ (A B C D : Finset (Fin n))\n (_ : (hypercubeGraph n).Adj A B)\n (_ : (hypercubeGraph n).Adj C D),\n s(A, B) ≠ s(C, D) ∧\n s(A, B) ∈ w.edges ∧ s(C, D) ∈ w.edges ∧\n symmDiff A B = symmDiff C D := by sorry"} -{"project_name": "BondyTheorem", "name": "acyclic_card_eq_edges_add_components", "type": "lemma", "code": "import Mathlib\n\nopen Set Finset\n/-- The hypercube graph $Q_n$ has vertex set the subsets of $\\{0,\\ldots,n-1\\}$,\nwith two vertices adjacent iff their symmetric difference has size 1. -/\n\ndef hypercubeGraph (n : ℕ) : SimpleGraph (Finset (Fin n)) where\n Adj A B := (symmDiff A B).card = 1\n symm A B h := by\n simp only at *\n rw [symmDiff_comm]\n exact h\n loopless := ⟨ by simp ⟩\n/-- Any cycle in $Q_n$ contains two distinct edges that are parallel,\ni.e., connecting sets that differ in the same coordinate. -/\n\nlemma hypercube_cycle_has_parallel_edges {n : ℕ} {v : Finset (Fin n)}\n (w : (hypercubeGraph n).Walk v v) (hw : w.IsCycle) :\n ∃ (A B C D : Finset (Fin n))\n (_ : (hypercubeGraph n).Adj A B)\n (_ : (hypercubeGraph n).Adj C D),\n s(A, B) ≠ s(C, D) ∧\n s(A, B) ∈ w.edges ∧ s(C, D) ∈ w.edges ∧\n symmDiff A B = symmDiff C D := by sorry\n/-- An acyclic graph has a number of vertices equal to the number of edges\nplus the number of connected components. -/\n\nlemma acyclic_card_eq_edges_add_components {V : Type*} [Fintype V] [DecidableEq V]\n (G : SimpleGraph V) [DecidableRel G.Adj]\n (hG : G.IsAcyclic) :\n Fintype.card V = G.edgeFinset.card + Fintype.card G.ConnectedComponent := by sorry"} -{"project_name": "BondyTheorem", "name": "bondy", "type": "theorem", "code": "import Mathlib\n\nopen Set Finset\n/-- The hypercube graph $Q_n$ has vertex set the subsets of $\\{0,\\ldots,n-1\\}$,\nwith two vertices adjacent iff their symmetric difference has size 1. -/\n\ndef hypercubeGraph (n : ℕ) : SimpleGraph (Finset (Fin n)) where\n Adj A B := (symmDiff A B).card = 1\n symm A B h := by\n simp only at *\n rw [symmDiff_comm]\n exact h\n loopless := ⟨ by simp ⟩\n/-- Any cycle in $Q_n$ contains two distinct edges that are parallel,\ni.e., connecting sets that differ in the same coordinate. -/\n\nlemma hypercube_cycle_has_parallel_edges {n : ℕ} {v : Finset (Fin n)}\n (w : (hypercubeGraph n).Walk v v) (hw : w.IsCycle) :\n ∃ (A B C D : Finset (Fin n))\n (_ : (hypercubeGraph n).Adj A B)\n (_ : (hypercubeGraph n).Adj C D),\n s(A, B) ≠ s(C, D) ∧\n s(A, B) ∈ w.edges ∧ s(C, D) ∈ w.edges ∧\n symmDiff A B = symmDiff C D := by sorry\n/-- An acyclic graph has a number of vertices equal to the number of edges\nplus the number of connected components. -/\n\nlemma acyclic_card_eq_edges_add_components {V : Type*} [Fintype V] [DecidableEq V]\n (G : SimpleGraph V) [DecidableRel G.Adj]\n (hG : G.IsAcyclic) :\n Fintype.card V = G.edgeFinset.card + Fintype.card G.ConnectedComponent := by sorry\n/-- **Bondy's theorem**: given $n$ distinct subsets $A_0, \\ldots, A_{n-1}$ of $\\{0,\\ldots,n-1\\}$,\nthere exists a set $S \\subseteq \\{0,\\ldots,n-1\\}$ of size $n-1$ such that the intersections\n$A_0 \\cap S, \\ldots, A_{n-1} \\cap S$ are all distinct. -/\n\ntheorem bondy {n : ℕ} (hn : 0 < n) {A : Fin n → Finset (Fin n)}\n (h_disj : ∀ i j : Fin n, i ≠ j → A i ≠ A j) :\n ∃ S : Finset (Fin n),\n S.card + 1 = n ∧\n ∀ i j : Fin n, i ≠ j → (S) ∩ A i ≠ (S) ∩ A j := by sorry"} -{"project_name": "BorsukUlamTheorem", "name": "borsuk_ulam", "type": "theorem", "code": "import Mathlib\n\nopen Metric\n/--\nThe type of the n-dimensional sphere,\n\ndefined as the set of points in ℝⁿ⁺¹ at distance 1 from the origin.\n-/\n\nabbrev UnitNDimensionalSphere (n : ℕ) := sphere (0 : (Fin (n + 1) → ℝ)) 1\n\ntheorem borsuk_ulam (n : ℕ) {g : UnitNDimensionalSphere n → Fin n → ℝ}\n (hg : ∀ x : UnitNDimensionalSphere n, g (-x) = g x) (cont : Continuous g):\n ∃ x : UnitNDimensionalSphere n, g x = 0 := by sorry"} -{"project_name": "BrascampLieb", "name": "inner_lin_apply_apply", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry"} -{"project_name": "BrascampLieb", "name": "inner_lin_apply_ne", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry"} -{"project_name": "BrascampLieb", "name": "EssentialRank_eq", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry"} -{"project_name": "BrascampLieb", "name": "mem_EssRankAux", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry"} -{"project_name": "BrascampLieb", "name": "mem_EssRankAux'", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry"} -{"project_name": "BrascampLieb", "name": "mem_EssRank_pos", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry"} -{"project_name": "BrascampLieb", "name": "mem_EssRankAux_apply_ne_zero", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry"} -{"project_name": "BrascampLieb", "name": "EssRankAux_apply_lindep", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry"} -{"project_name": "BrascampLieb", "name": "loc_c_PosDef", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry"} -{"project_name": "BrascampLieb", "name": "choleski_det_bound₁", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry"} -{"project_name": "BrascampLieb", "name": "choleski_det_bound", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry"} -{"project_name": "BrascampLieb", "name": "EssRank_eq_geometric", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry"} -{"project_name": "BrascampLieb", "name": "EssRankRestrict_eq_geometric", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry"} -{"project_name": "BrascampLieb", "name": "EssRankRestrict_eq_geometric'", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry"} -{"project_name": "BrascampLieb", "name": "EssRankRestrict_top", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry"} -{"project_name": "BrascampLieb", "name": "EssentialRank_comp_Isometry", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry"} -{"project_name": "BrascampLieb", "name": "EssentialRankRestrict_comp_Isometry", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry"} -{"project_name": "BrascampLieb", "name": "Fin.greedyIndexSet", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry"} -{"project_name": "BrascampLieb", "name": "NNReal.mul_inv_rev", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry"} -{"project_name": "BrascampLieb", "name": "mainlem2", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry"} -{"project_name": "BrascampLieb", "name": "NNReal.rpow_sum", "type": "theorem", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\n\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry"} -{"project_name": "BrascampLieb", "name": "greedy_index_set_exists", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\n\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\n\nnamespace BrascampLieb\n\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\n\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\n\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry"} -{"project_name": "BrascampLieb", "name": "essRank_le_ncard_inter_greedy", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\n\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\n\nnamespace BrascampLieb\n\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\n\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\n\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry\nomit [FiniteDimensional ℝ F] in\n/-- A greedy choice of index set for the essential rank decomposition,\nchosen via `greedy_index_set_exists`. -/\nnoncomputable def greedy_index_set {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : Finset (Fin d) :=\n greedy_index_set_exists hα ℓ|>.choose\nattribute [local instance] Fintype.ofFinite in\n\nlemma essRank_le_ncard_inter_greedy {d n : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) (i)\n (hn1 : Module.finrank ℝ ↥(Submodule.span ℝ\n (basisFun (Fin d) ℝ '' (SetLike.coe (Finset.Ici i)))) = n) :\n ℓ.EssentialRankRestrict α (Submodule.span ℝ (basisFun (Fin d) ℝ '' Finset.Ici i)) hn1 ≤\n Finset.card (greedy_index_set hα ℓ ∩ Finset.Ici i) := by sorry"} -{"project_name": "BrascampLieb", "name": "greedy_index_set_volume_bound", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\n\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\n\nnamespace BrascampLieb\n\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\n\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\n\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry\nomit [FiniteDimensional ℝ F] in\n/-- A greedy choice of index set for the essential rank decomposition,\nchosen via `greedy_index_set_exists`. -/\nnoncomputable def greedy_index_set {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : Finset (Fin d) :=\n greedy_index_set_exists hα ℓ|>.choose\nattribute [local instance] Fintype.ofFinite in\n\nlemma essRank_le_ncard_inter_greedy {d n : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) (i)\n (hn1 : Module.finrank ℝ ↥(Submodule.span ℝ\n (basisFun (Fin d) ℝ '' (SetLike.coe (Finset.Ici i)))) = n) :\n ℓ.EssentialRankRestrict α (Submodule.span ℝ (basisFun (Fin d) ℝ '' Finset.Ici i)) hn1 ≤\n Finset.card (greedy_index_set hα ℓ ∩ Finset.Ici i) := by sorry\n\nlemma greedy_index_set_volume_bound {d : ℕ} (hα : 0 < α) (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) :\n ((α : ℝ) / Real.sqrt d) ^ (2 * (greedy_index_set hα ℓ).card) ≤ (@Matrix.gram _\n (greedy_index_set hα ℓ) ℝ _ (ℓ ∘ basisFun (Fin d) ℝ ∘ Subtype.val)).det := by sorry"} -{"project_name": "BrascampLieb", "name": "card_greedy_eq_of_essRank_eq", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\n\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\n\nnamespace BrascampLieb\n\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\n\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\n\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry\nomit [FiniteDimensional ℝ F] in\n/-- A greedy choice of index set for the essential rank decomposition,\nchosen via `greedy_index_set_exists`. -/\nnoncomputable def greedy_index_set {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : Finset (Fin d) :=\n greedy_index_set_exists hα ℓ|>.choose\nattribute [local instance] Fintype.ofFinite in\n\nlemma essRank_le_ncard_inter_greedy {d n : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) (i)\n (hn1 : Module.finrank ℝ ↥(Submodule.span ℝ\n (basisFun (Fin d) ℝ '' (SetLike.coe (Finset.Ici i)))) = n) :\n ℓ.EssentialRankRestrict α (Submodule.span ℝ (basisFun (Fin d) ℝ '' Finset.Ici i)) hn1 ≤\n Finset.card (greedy_index_set hα ℓ ∩ Finset.Ici i) := by sorry\n\nlemma greedy_index_set_volume_bound {d : ℕ} (hα : 0 < α) (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) :\n ((α : ℝ) / Real.sqrt d) ^ (2 * (greedy_index_set hα ℓ).card) ≤ (@Matrix.gram _\n (greedy_index_set hα ℓ) ℝ _ (ℓ ∘ basisFun (Fin d) ℝ ∘ Subtype.val)).det := by sorry\n\nopen LinearMap\n\nset_option maxHeartbeats 400000 in\n/-- Cardinality of greedy_index_set is equal to the dimension of the image -/\n\nlemma card_greedy_eq_of_essRank_eq {d : ℕ} (hm : Module.finrank ℝ F = m) (hα : 0 < α)\n {ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F} (hℓ : ℓ.EssentialRank finrank_euclideanSpace_fin α = m) :\n Finset.card (greedy_index_set hα ℓ) = Module.finrank ℝ F := by sorry"} -{"project_name": "BrascampLieb", "name": "det_greedy_control", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\n\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\n\nnamespace BrascampLieb\n\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\n\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\n\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry\nomit [FiniteDimensional ℝ F] in\n/-- A greedy choice of index set for the essential rank decomposition,\nchosen via `greedy_index_set_exists`. -/\nnoncomputable def greedy_index_set {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : Finset (Fin d) :=\n greedy_index_set_exists hα ℓ|>.choose\nattribute [local instance] Fintype.ofFinite in\n\nlemma essRank_le_ncard_inter_greedy {d n : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) (i)\n (hn1 : Module.finrank ℝ ↥(Submodule.span ℝ\n (basisFun (Fin d) ℝ '' (SetLike.coe (Finset.Ici i)))) = n) :\n ℓ.EssentialRankRestrict α (Submodule.span ℝ (basisFun (Fin d) ℝ '' Finset.Ici i)) hn1 ≤\n Finset.card (greedy_index_set hα ℓ ∩ Finset.Ici i) := by sorry\n\nlemma greedy_index_set_volume_bound {d : ℕ} (hα : 0 < α) (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) :\n ((α : ℝ) / Real.sqrt d) ^ (2 * (greedy_index_set hα ℓ).card) ≤ (@Matrix.gram _\n (greedy_index_set hα ℓ) ℝ _ (ℓ ∘ basisFun (Fin d) ℝ ∘ Subtype.val)).det := by sorry\n\nopen LinearMap\n\nset_option maxHeartbeats 400000 in\n/-- Cardinality of greedy_index_set is equal to the dimension of the image -/\n\nlemma card_greedy_eq_of_essRank_eq {d : ℕ} (hm : Module.finrank ℝ F = m) (hα : 0 < α)\n {ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F} (hℓ : ℓ.EssentialRank finrank_euclideanSpace_fin α = m) :\n Finset.card (greedy_index_set hα ℓ) = Module.finrank ℝ F := by sorry\n\nset_option maxHeartbeats 400000 in\ninclude hn hm in\n\nlemma det_greedy_control (b : OrthonormalBasis (Fin n) ℝ E) (hα : 0 < α) {ℓ : E →ₗ[ℝ] F}\n (hℓ : ℓ.EssentialRank hn α = m) {Q : F →ₗ[ℝ] F} (hQ : Q.IsPositive) :\n Q.det * (α ^ 2 / n) ^ m ≤ ∏ i ∈ (greedy_index_set hα (ℓ ∘ₗ b.repr.symm.toLinearMap)),\n inner ℝ (Q (ℓ (b i))) (ℓ (b i)) := by sorry"} -{"project_name": "BrascampLieb", "name": "prod_rpow_eq_first_times_ratio_prod'", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\n\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\n\nnamespace BrascampLieb\n\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\n\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\n\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry\nomit [FiniteDimensional ℝ F] in\n/-- A greedy choice of index set for the essential rank decomposition,\nchosen via `greedy_index_set_exists`. -/\nnoncomputable def greedy_index_set {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : Finset (Fin d) :=\n greedy_index_set_exists hα ℓ|>.choose\nattribute [local instance] Fintype.ofFinite in\n\nlemma essRank_le_ncard_inter_greedy {d n : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) (i)\n (hn1 : Module.finrank ℝ ↥(Submodule.span ℝ\n (basisFun (Fin d) ℝ '' (SetLike.coe (Finset.Ici i)))) = n) :\n ℓ.EssentialRankRestrict α (Submodule.span ℝ (basisFun (Fin d) ℝ '' Finset.Ici i)) hn1 ≤\n Finset.card (greedy_index_set hα ℓ ∩ Finset.Ici i) := by sorry\n\nlemma greedy_index_set_volume_bound {d : ℕ} (hα : 0 < α) (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) :\n ((α : ℝ) / Real.sqrt d) ^ (2 * (greedy_index_set hα ℓ).card) ≤ (@Matrix.gram _\n (greedy_index_set hα ℓ) ℝ _ (ℓ ∘ basisFun (Fin d) ℝ ∘ Subtype.val)).det := by sorry\n\nopen LinearMap\n\nset_option maxHeartbeats 400000 in\n/-- Cardinality of greedy_index_set is equal to the dimension of the image -/\n\nlemma card_greedy_eq_of_essRank_eq {d : ℕ} (hm : Module.finrank ℝ F = m) (hα : 0 < α)\n {ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F} (hℓ : ℓ.EssentialRank finrank_euclideanSpace_fin α = m) :\n Finset.card (greedy_index_set hα ℓ) = Module.finrank ℝ F := by sorry\n\nset_option maxHeartbeats 400000 in\ninclude hn hm in\n\nlemma det_greedy_control (b : OrthonormalBasis (Fin n) ℝ E) (hα : 0 < α) {ℓ : E →ₗ[ℝ] F}\n (hℓ : ℓ.EssentialRank hn α = m) {Q : F →ₗ[ℝ] F} (hQ : Q.IsPositive) :\n Q.det * (α ^ 2 / n) ^ m ≤ ∏ i ∈ (greedy_index_set hα (ℓ ∘ₗ b.repr.symm.toLinearMap)),\n inner ℝ (Q (ℓ (b i))) (ℓ (b i)) := by sorry\nattribute [local grind! .] Real.rpow_pos_of_pos in\n\nlemma prod_rpow_eq_first_times_ratio_prod' {d : ℕ} (l : Fin (d + 1) → ℝ)\n (hl1 : ∀ i, 0 < l i) (c : Fin (d + 1) → ℝ) : ∏ i : Fin (d + 1), l i ^ c i =\n l 0 ^ (∑ i, c i) * ∏ k : Fin d, (l k.succ / l k.castSucc) ^ (∑ i ∈ Finset.univ.filter\n (fun i : Fin (d + 1) => k.castSucc < i), c i) := by sorry"} -{"project_name": "BrascampLieb", "name": "telescoping_product_bound'", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\n\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\n\nnamespace BrascampLieb\n\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\n\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\n\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry\nomit [FiniteDimensional ℝ F] in\n/-- A greedy choice of index set for the essential rank decomposition,\nchosen via `greedy_index_set_exists`. -/\nnoncomputable def greedy_index_set {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : Finset (Fin d) :=\n greedy_index_set_exists hα ℓ|>.choose\nattribute [local instance] Fintype.ofFinite in\n\nlemma essRank_le_ncard_inter_greedy {d n : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) (i)\n (hn1 : Module.finrank ℝ ↥(Submodule.span ℝ\n (basisFun (Fin d) ℝ '' (SetLike.coe (Finset.Ici i)))) = n) :\n ℓ.EssentialRankRestrict α (Submodule.span ℝ (basisFun (Fin d) ℝ '' Finset.Ici i)) hn1 ≤\n Finset.card (greedy_index_set hα ℓ ∩ Finset.Ici i) := by sorry\n\nlemma greedy_index_set_volume_bound {d : ℕ} (hα : 0 < α) (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) :\n ((α : ℝ) / Real.sqrt d) ^ (2 * (greedy_index_set hα ℓ).card) ≤ (@Matrix.gram _\n (greedy_index_set hα ℓ) ℝ _ (ℓ ∘ basisFun (Fin d) ℝ ∘ Subtype.val)).det := by sorry\n\nopen LinearMap\n\nset_option maxHeartbeats 400000 in\n/-- Cardinality of greedy_index_set is equal to the dimension of the image -/\n\nlemma card_greedy_eq_of_essRank_eq {d : ℕ} (hm : Module.finrank ℝ F = m) (hα : 0 < α)\n {ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F} (hℓ : ℓ.EssentialRank finrank_euclideanSpace_fin α = m) :\n Finset.card (greedy_index_set hα ℓ) = Module.finrank ℝ F := by sorry\n\nset_option maxHeartbeats 400000 in\ninclude hn hm in\n\nlemma det_greedy_control (b : OrthonormalBasis (Fin n) ℝ E) (hα : 0 < α) {ℓ : E →ₗ[ℝ] F}\n (hℓ : ℓ.EssentialRank hn α = m) {Q : F →ₗ[ℝ] F} (hQ : Q.IsPositive) :\n Q.det * (α ^ 2 / n) ^ m ≤ ∏ i ∈ (greedy_index_set hα (ℓ ∘ₗ b.repr.symm.toLinearMap)),\n inner ℝ (Q (ℓ (b i))) (ℓ (b i)) := by sorry\nattribute [local grind! .] Real.rpow_pos_of_pos in\n\nlemma prod_rpow_eq_first_times_ratio_prod' {d : ℕ} (l : Fin (d + 1) → ℝ)\n (hl1 : ∀ i, 0 < l i) (c : Fin (d + 1) → ℝ) : ∏ i : Fin (d + 1), l i ^ c i =\n l 0 ^ (∑ i, c i) * ∏ k : Fin d, (l k.succ / l k.castSucc) ^ (∑ i ∈ Finset.univ.filter\n (fun i : Fin (d + 1) => k.castSucc < i), c i) := by sorry\n\nlemma telescoping_product_bound' {d : ℕ} (l : Fin (d + 1) → ℝ)\n (hl1 : ∀ i j : Fin (d + 1), i ≤ j → l j ≤ l i) (hl2 : ∀ i, 0 < l i)\n (c : Fin (d + 1) → ℝ) (S β : ℝ) (h_sum : ∑ i, c i = S)\n (ht : ∀ k (_ : k.1 < d), ∑ i ∈ Finset.univ.filter (fun i : Fin (d + 1) => k < i), c i ≥ -β) :\n ∏ i : Fin (d + 1), l i ^ c i ≤ l 0 ^ (S + β) * l (Fin.last d) ^ (-β) := by sorry"} -{"project_name": "BrascampLieb", "name": "eigenvalue_telescoping'", "type": "lemma", "code": "import Mathlib\n\nnamespace LinearMap\n\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\n\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\n\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\n\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\n\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\n\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\n\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\n\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\n\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\n\nend LinearMap\n\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\n\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\n\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\n\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\n\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\n\nend BrascampLieb\n\nnamespace LinearMap\n\nopen Matrix\n\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\n\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\n\nopen Module\n\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\n\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\n\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\n\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\n\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\n\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\n\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\n\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\n\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\n\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\n\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\n\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\n\nnamespace BrascampLieb\n\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\n\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\n\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry\nomit [FiniteDimensional ℝ F] in\n/-- A greedy choice of index set for the essential rank decomposition,\nchosen via `greedy_index_set_exists`. -/\nnoncomputable def greedy_index_set {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : Finset (Fin d) :=\n greedy_index_set_exists hα ℓ|>.choose\nattribute [local instance] Fintype.ofFinite in\n\nlemma essRank_le_ncard_inter_greedy {d n : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) (i)\n (hn1 : Module.finrank ℝ ↥(Submodule.span ℝ\n (basisFun (Fin d) ℝ '' (SetLike.coe (Finset.Ici i)))) = n) :\n ℓ.EssentialRankRestrict α (Submodule.span ℝ (basisFun (Fin d) ℝ '' Finset.Ici i)) hn1 ≤\n Finset.card (greedy_index_set hα ℓ ∩ Finset.Ici i) := by sorry\n\nlemma greedy_index_set_volume_bound {d : ℕ} (hα : 0 < α) (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) :\n ((α : ℝ) / Real.sqrt d) ^ (2 * (greedy_index_set hα ℓ).card) ≤ (@Matrix.gram _\n (greedy_index_set hα ℓ) ℝ _ (ℓ ∘ basisFun (Fin d) ℝ ∘ Subtype.val)).det := by sorry\n\nopen LinearMap\n\nset_option maxHeartbeats 400000 in\n/-- Cardinality of greedy_index_set is equal to the dimension of the image -/\n\nlemma card_greedy_eq_of_essRank_eq {d : ℕ} (hm : Module.finrank ℝ F = m) (hα : 0 < α)\n {ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F} (hℓ : ℓ.EssentialRank finrank_euclideanSpace_fin α = m) :\n Finset.card (greedy_index_set hα ℓ) = Module.finrank ℝ F := by sorry\n\nset_option maxHeartbeats 400000 in\ninclude hn hm in\n\nlemma det_greedy_control (b : OrthonormalBasis (Fin n) ℝ E) (hα : 0 < α) {ℓ : E →ₗ[ℝ] F}\n (hℓ : ℓ.EssentialRank hn α = m) {Q : F →ₗ[ℝ] F} (hQ : Q.IsPositive) :\n Q.det * (α ^ 2 / n) ^ m ≤ ∏ i ∈ (greedy_index_set hα (ℓ ∘ₗ b.repr.symm.toLinearMap)),\n inner ℝ (Q (ℓ (b i))) (ℓ (b i)) := by sorry\nattribute [local grind! .] Real.rpow_pos_of_pos in\n\nlemma prod_rpow_eq_first_times_ratio_prod' {d : ℕ} (l : Fin (d + 1) → ℝ)\n (hl1 : ∀ i, 0 < l i) (c : Fin (d + 1) → ℝ) : ∏ i : Fin (d + 1), l i ^ c i =\n l 0 ^ (∑ i, c i) * ∏ k : Fin d, (l k.succ / l k.castSucc) ^ (∑ i ∈ Finset.univ.filter\n (fun i : Fin (d + 1) => k.castSucc < i), c i) := by sorry\n\nlemma telescoping_product_bound' {d : ℕ} (l : Fin (d + 1) → ℝ)\n (hl1 : ∀ i j : Fin (d + 1), i ≤ j → l j ≤ l i) (hl2 : ∀ i, 0 < l i)\n (c : Fin (d + 1) → ℝ) (S β : ℝ) (h_sum : ∑ i, c i = S)\n (ht : ∀ k (_ : k.1 < d), ∑ i ∈ Finset.univ.filter (fun i : Fin (d + 1) => k < i), c i ≥ -β) :\n ∏ i : Fin (d + 1), l i ^ c i ≤ l 0 ^ (S + β) * l (Fin.last d) ^ (-β) := by sorry\n\nlemma eigenvalue_telescoping' {d : ℕ} (l : Fin (d + 1) → ℝ) (hl1 : Antitone l) (hl2 : ∀ i, 0 < l i)\n (I : J → Finset (Fin (d + 1))) (q : J → NNReal) (β : NNReal) (Ac : NNReal)\n (h_card : ∑ j, q j * (I j).card = Ac) (h_percep : ∀ i : Fin (d + 1), (∑ j, q j *\n (I j ∩ Finset.Ici i).card) ≥ ((d + 1) - i : ℝ) - β) :\n ∏ j, (∏ i ∈ I j, l i) ^ (q j : ℝ) ≤ l 0 ^ (Ac - (d + 1) + β : ℝ) * (l (Fin.last d)) ^\n (- (β : ℝ)) * ∏ i, l i := by sorry"} -{"project_name": "BrascampLieb", "name": "upperBound_single_term", "type": "lemma", "code": "import Mathlib\n\nnamespace BrascampLieb\n\nopen EuclideanSpace in\n\nlemma upperBound_single_term {J E : Type*} {n} [Fintype J] [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n {m : J → ℕ} (hm : ∀ j, Module.finrank ℝ (F j) = m j) (hE : n ≠ 0)\n (D : locRegDatum E F) (α : J → NNReal) (β : NNReal)\n (hα : ∀ i, 0 < α i) (hP : D.IsMetricPercep α β)\n (hS : ∀ j : J, (D.map j).EssentialRank hn (α j) = m j)\n (A : (j : J) → F j →ₗ[ℝ] F j)\n (hA : ∀ j, (A j).IsPosDef ∧ A j ≤ D.reg j) :\n let M_max := (D.loc + ∑ j, (D.weight j) • (D.map j).adjoint ∘ₗ (D.reg j) ∘ₗ (D.map j))\n loc_constant_g_of D.tolocDatum A (fun j => (hA j).1) ≤\n (n : NNReal) ^ (D.Acuity / 2 : ℝ) *\n (∏ j, (D.weight j)^(- (D.weight j : ℝ) * m j / 2)) *\n (∏ j, (α j)^(- (D.weight j : ℝ) * m j)) *\n ‖M_max.toContinuousLinearMap‖₊^((D.Acuity.toReal - n + β) / 2) *\n ‖(D.loc.equivOfDetNeZero D.pos_loc.2).symm.toContinuousLinearMap‖₊^(β.toReal / 2) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.BrascampLieb.BackgroundLemmas\nnamespace LinearMap\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\nend LinearMap\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\nend BrascampLieb\nnamespace LinearMap\nopen Matrix\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\nopen Module\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\nnamespace BrascampLieb\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry\nomit [FiniteDimensional ℝ F] in\n/-- A greedy choice of index set for the essential rank decomposition,\nchosen via `greedy_index_set_exists`. -/\nnoncomputable def greedy_index_set {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : Finset (Fin d) :=\n greedy_index_set_exists hα ℓ|>.choose\nattribute [local instance] Fintype.ofFinite in\nlemma essRank_le_ncard_inter_greedy {d n : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) (i)\n (hn1 : Module.finrank ℝ ↥(Submodule.span ℝ\n (basisFun (Fin d) ℝ '' (SetLike.coe (Finset.Ici i)))) = n) :\n ℓ.EssentialRankRestrict α (Submodule.span ℝ (basisFun (Fin d) ℝ '' Finset.Ici i)) hn1 ≤\n Finset.card (greedy_index_set hα ℓ ∩ Finset.Ici i) := by sorry\nlemma greedy_index_set_volume_bound {d : ℕ} (hα : 0 < α) (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) :\n ((α : ℝ) / Real.sqrt d) ^ (2 * (greedy_index_set hα ℓ).card) ≤ (@Matrix.gram _\n (greedy_index_set hα ℓ) ℝ _ (ℓ ∘ basisFun (Fin d) ℝ ∘ Subtype.val)).det := by sorry\nopen LinearMap\nset_option maxHeartbeats 400000 in\n/-- Cardinality of greedy_index_set is equal to the dimension of the image -/\nlemma card_greedy_eq_of_essRank_eq {d : ℕ} (hm : Module.finrank ℝ F = m) (hα : 0 < α)\n {ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F} (hℓ : ℓ.EssentialRank finrank_euclideanSpace_fin α = m) :\n Finset.card (greedy_index_set hα ℓ) = Module.finrank ℝ F := by sorry\nset_option maxHeartbeats 400000 in\ninclude hn hm in\nlemma det_greedy_control (b : OrthonormalBasis (Fin n) ℝ E) (hα : 0 < α) {ℓ : E →ₗ[ℝ] F}\n (hℓ : ℓ.EssentialRank hn α = m) {Q : F →ₗ[ℝ] F} (hQ : Q.IsPositive) :\n Q.det * (α ^ 2 / n) ^ m ≤ ∏ i ∈ (greedy_index_set hα (ℓ ∘ₗ b.repr.symm.toLinearMap)),\n inner ℝ (Q (ℓ (b i))) (ℓ (b i)) := by sorry\nattribute [local grind! .] Real.rpow_pos_of_pos in\nlemma prod_rpow_eq_first_times_ratio_prod' {d : ℕ} (l : Fin (d + 1) → ℝ)\n (hl1 : ∀ i, 0 < l i) (c : Fin (d + 1) → ℝ) : ∏ i : Fin (d + 1), l i ^ c i =\n l 0 ^ (∑ i, c i) * ∏ k : Fin d, (l k.succ / l k.castSucc) ^ (∑ i ∈ Finset.univ.filter\n (fun i : Fin (d + 1) => k.castSucc < i), c i) := by sorry\nlemma telescoping_product_bound' {d : ℕ} (l : Fin (d + 1) → ℝ)\n (hl1 : ∀ i j : Fin (d + 1), i ≤ j → l j ≤ l i) (hl2 : ∀ i, 0 < l i)\n (c : Fin (d + 1) → ℝ) (S β : ℝ) (h_sum : ∑ i, c i = S)\n (ht : ∀ k (_ : k.1 < d), ∑ i ∈ Finset.univ.filter (fun i : Fin (d + 1) => k < i), c i ≥ -β) :\n ∏ i : Fin (d + 1), l i ^ c i ≤ l 0 ^ (S + β) * l (Fin.last d) ^ (-β) := by sorry\nlemma eigenvalue_telescoping' {d : ℕ} (l : Fin (d + 1) → ℝ) (hl1 : Antitone l) (hl2 : ∀ i, 0 < l i)\n (I : J → Finset (Fin (d + 1))) (q : J → NNReal) (β : NNReal) (Ac : NNReal)\n (h_card : ∑ j, q j * (I j).card = Ac) (h_percep : ∀ i : Fin (d + 1), (∑ j, q j *\n (I j ∩ Finset.Ici i).card) ≥ ((d + 1) - i : ℝ) - β) :\n ∏ j, (∏ i ∈ I j, l i) ^ (q j : ℝ) ≤ l 0 ^ (Ac - (d + 1) + β : ℝ) * (l (Fin.last d)) ^\n (- (β : ℝ)) * ∏ i, l i := by sorry\nend BrascampLieb"} -{"project_name": "BrascampLieb", "name": "upperBound", "type": "theorem", "code": "import Mathlib\n\nnamespace BrascampLieb\n\nopen EuclideanSpace in\n\nlemma upperBound_single_term {J E : Type*} {n} [Fintype J] [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n {m : J → ℕ} (hm : ∀ j, Module.finrank ℝ (F j) = m j) (hE : n ≠ 0)\n (D : locRegDatum E F) (α : J → NNReal) (β : NNReal)\n (hα : ∀ i, 0 < α i) (hP : D.IsMetricPercep α β)\n (hS : ∀ j : J, (D.map j).EssentialRank hn (α j) = m j)\n (A : (j : J) → F j →ₗ[ℝ] F j)\n (hA : ∀ j, (A j).IsPosDef ∧ A j ≤ D.reg j) :\n let M_max := (D.loc + ∑ j, (D.weight j) • (D.map j).adjoint ∘ₗ (D.reg j) ∘ₗ (D.map j))\n loc_constant_g_of D.tolocDatum A (fun j => (hA j).1) ≤\n (n : NNReal) ^ (D.Acuity / 2 : ℝ) *\n (∏ j, (D.weight j)^(- (D.weight j : ℝ) * m j / 2)) *\n (∏ j, (α j)^(- (D.weight j : ℝ) * m j)) *\n ‖M_max.toContinuousLinearMap‖₊^((D.Acuity.toReal - n + β) / 2) *\n ‖(D.loc.equivOfDetNeZero D.pos_loc.2).symm.toContinuousLinearMap‖₊^(β.toReal / 2) := by sorry\n\ntheorem upperBound {J E : Type*} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n [FiniteDimensional ℝ E] {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (hE : Module.finrank ℝ E ≠ 0)\n (D : locRegDatum E F) (α : J → NNReal) (β : NNReal) (hα : ∀ i, 0 < α i)\n (hP : D.IsMetricPercep α β)\n (hS : ∀ j : J, (D.map j).EssentialRank rfl (α j) = Module.finrank ℝ (F j)) :\n let M_max := (D.loc + ∑ j, (D.weight j) • (D.map j).adjoint ∘ₗ (D.reg j) ∘ₗ (D.map j))\n loc_reg_constant_g D ≤\n (Module.finrank ℝ E : NNReal)^(D.Acuity / 2 : ℝ) *\n (∏ j, (D.weight j)^(- (D.weight j : ℝ) * Module.finrank ℝ (F j) / 2)) *\n (∏ j, (α j)^(- (D.weight j : ℝ) * Module.finrank ℝ (F j))) *\n ‖M_max.toContinuousLinearMap‖₊^((D.Acuity.toReal - Module.finrank ℝ E + β) / 2) *\n ‖(D.loc.equivOfDetNeZero D.pos_loc.2).symm.toContinuousLinearMap‖₊^(β.toReal / 2) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.BrascampLieb.BackgroundLemmas\nnamespace LinearMap\nvariable {𝕜 E F : Type*} [RCLike 𝕜] {n} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (l : E →ₗ[𝕜] F)\nlemma inner_lin_apply_apply (i j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) =\n (l.isPositive_adjoint_comp_self.1.eigenvalues hn j : 𝕜) * inner 𝕜\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i)\n (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j) := by sorry\nlemma inner_lin_apply_ne {i j} (hij : i ≠ j) :\n inner 𝕜 (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i))\n (l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn j)) = 0 := by sorry\n/-- The set of indices where the singular value of `l` exceeds the threshold `α`. -/\nnoncomputable def EssRankAux :=\n Finset.univ.filter (fun i ↦ (α : ℝ) < l.singularValuesFin' hn i)\n/-- The essential rank of `l` at threshold `α`: the number of singular values exceeding `α`. -/\nnoncomputable def EssentialRank : ℕ := Finset.card <| l.EssRankAux hn α\nlemma EssentialRank_eq : l.EssentialRank hn α = (l.EssRankAux hn α).card := sorry\n@[simp]\nlemma mem_EssRankAux {i} : i ∈ l.EssRankAux hn α ↔ (α : ℝ) < l.singularValuesFin' hn i := by sorry\nlemma mem_EssRankAux' {i} (hi : i ∈ l.EssRankAux hn α) :\n (α : ℝ) ^ 2 < (l.isPositive_adjoint_comp_self.1.eigenvalues hn i) := by sorry\nlemma mem_EssRank_pos {i} (hi : i ∈ l.EssRankAux hn α) :\n 0 < l.singularValuesFin' hn i := sorry\nlemma mem_EssRankAux_apply_ne_zero {i} (hi : i ∈ l.EssRankAux hn α) :\n l ((l.isPositive_adjoint_comp_self).1.eigenvectorBasis hn i) ≠ 0 := sorry\nlemma EssRankAux_apply_lindep : LinearIndependent 𝕜 (fun i : l.EssRankAux hn α ↦\n l (l.isPositive_adjoint_comp_self.1.eigenvectorBasis hn i.1)) := sorry\n/-- The essential rank of `l` restricted to the submodule `W` at threshold `α`. -/\nnoncomputable def EssentialRankRestrict {m} (W : Submodule 𝕜 E)\n (hm : Module.finrank 𝕜 W = m) : ℕ :=\n (l.domRestrict W).EssentialRank hm α\nend LinearMap\nnamespace BrascampLieb\n/-- A Brascamp-Lieb datum consisting of linear maps from a common domain to target spaces,\neach with an associated nonnegative weight. -/\nstructure Datum {J : Type*} [Fintype J]\n (E : Type*) [AddCommGroup E] [Module ℝ E]\n (F : J → Type*) [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n where\n /-- The linear map from the common domain to the `j`-th target space. -/\n map : (j : J) → E →ₗ[ℝ] (F j)\n /-- The nonnegative weight associated to each index. -/\n weight : J → NNReal\n/-- The acuity of a datum `D` within a subspace `W` at thresholds `α`:\nthe weighted sum of essential ranks of the restricted maps. -/\nnoncomputable def Datum.AcuityWithin {J : Type*} [Fintype J] {E : Type*} {F : J → Type*} {m}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m) : NNReal :=\n ∑ j, D.weight j * (D.map j).EssentialRankRestrict (α j) W hm\n/-- The total acuity of a datum: the weighted sum of dimensions of the target spaces. -/\nnoncomputable abbrev Datum.Acuity {J : Type*} [Fintype J]\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n {F : J → Type*} [(i : J) → AddCommGroup (F i)] [(i : J) → Module ℝ (F i)]\n (D : Datum E F) : NNReal :=\n ∑ j, D.weight j * Module.finrank ℝ (F j)\n/-- Metric perceptivity condition: for every subspace `W`, its dimension is bounded by\nthe acuity of `D` within `W` plus the slack `β`. -/\nnoncomputable def Datum.IsMetricPercep {J : Type*} [Fintype J] {E : Type*} {F : J → Type*}\n [NormedAddCommGroup E] [(i : J) → NormedAddCommGroup (F i)]\n [InnerProductSpace ℝ E] [(i : J) → InnerProductSpace ℝ (F i)]\n [FiniteDimensional ℝ E] [(i : J) → FiniteDimensional ℝ (F i)]\n (D : Datum E F) (α : J → NNReal) (β : NNReal) :=\n ∀ {m} (W : Submodule ℝ E) (hm : Module.finrank ℝ W = m),\n Module.finrank ℝ W ≤ D.AcuityWithin α W hm + β\n/-- A localized Brascamp-Lieb datum: a `Datum` together with a positive definite\nlocalization operator `loc` on the domain. -/\nstructure locDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → AddCommGroup (F j)] [(j : J) → Module ℝ (F j)]\n extends Datum E F where\n /-- The positive definite localization operator on the domain. -/\n loc : E →ₗ[ℝ] E\n pos_loc : LinearMap.IsPosDef loc\n/-- A localized regularised Brascamp-Lieb datum: a `locDatum` with additional positive definite\nregularization operators on each target space. -/\nstructure locRegDatum {J : Type*} [Fintype J]\n (E : Type*) [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (F : J → Type*) [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n extends locDatum E F where\n /-- The positive definite regularization operator on the `j`-th target space. -/\n reg : (j : J) → F j →ₗ[ℝ] F j\n pos_reg: (j : J) → LinearMap.IsPosDef (reg j)\nlemma loc_c_PosDef {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) :\n (D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j)).IsPosDef := sorry\n/-- the square root of the ratio of weighted determinants of `A` to the localized operator. -/\nnoncomputable abbrev loc_constant_g_of {J : Type*} [Fintype J]\n {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E]\n {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (D : locDatum E F) (A : (j : J) → (F j) →ₗ[ℝ] (F j))\n (hA : (j : J) → LinearMap.IsPosDef (A j)) : NNReal :=\n NNReal.sqrt ((∏ j : J, ⟨(A j).det, by classical exact (hA j).1.det_nonneg⟩ ^ (D.weight j : ℝ)) /\n ⟨LinearMap.det <| D.loc + ∑ j, (D.weight j : ℝ) • ((D.map j).adjoint ∘ₗ A j ∘ₗ D.map j),\n (loc_c_PosDef D A hA).det_pos.le⟩)\n/-- the supremum of `loc_constant_g_of` over all positive definite `A` bounded by the regularizer. -/\nnoncomputable abbrev loc_reg_constant_g {J : Type*} [Fintype J] {E : Type*} [NormedAddCommGroup E]\n [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] {F : J → Type*}\n [(j : J) → NormedAddCommGroup (F j)] [(j : J) → InnerProductSpace ℝ (F j)]\n [(j : J) → FiniteDimensional ℝ (F j)] (D : locRegDatum E F) : ENNReal :=\n iSup <| fun A : {A : (j : J) → F j →ₗ[ℝ] F j // ∀ j,\n LinearMap.IsPosDef (A j) ∧ A j ≤ D.reg j } ↦\n loc_constant_g_of D.tolocDatum A (fun j ↦ (A.prop j).1)\nend BrascampLieb\nnamespace LinearMap\nopen Matrix\nopen InnerProductSpace in\n/--\nCholeski determinant bound (Lemma lem:Choleski in blueprint).\nFor a positive semidefinite symmetric operator Q and a basis (ε₁, ..., εₐ),\ndet(Q) det(Gram Matrix of ε₁, ..., εₐ) ≤ ∏ₖ inner(Q εₖ, εₖ)⟨Q εₖ, εₖ⟩\nThe proof requires:\n1. For orthonormal basis, use Choleski decomposition Q = L* L\n2. For general basis, use Gram-Schmidt to relate to orthonormal case\n3. The wedge product norm captures the volume distortion\n-/\nlemma choleski_det_bound₁ {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (v : Fin n → E) (hv : Orthonormal ℝ v) : Q.det ≤ ∏ i, inner ℝ (Q (v i)) (v i) := sorry\nopen Module\nlemma choleski_det_bound {E : Type*} {n} [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] {Q : E →ₗ[ℝ] E} (hQ : Q.IsPositive)\n (b : Fin n → E) :\n Q.det * (gram ℝ b).det ≤ ∏ i, inner ℝ (Q (b i)) (b i) := by sorry\nopen RCLike in\n/--\nEssential rank geometric characterization (Lemma lem:essential_rank_eq in blueprint).\nThe α-essential rank of ℓ restricted to W equals the minimum dimension of a subspace E\nsuch that the image of the unit ball ℓ(B₁^W) is contained in the α-neighborhood of E.\nThis bridges the SVD-based definition with the geometric covering property needed\nfor the greedy construction.\n-/\nlemma EssRank_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {n}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]\n (hn : Module.finrank 𝕜 E = n) [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) :\n ℓ.EssentialRank hn α = sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x : E, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\nlemma EssRankRestrict_eq_geometric {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : Module.finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm =\n sInf {d | ∃ (S : Submodule 𝕜 F), Module.finrank 𝕜 S = d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := by sorry\nlemma EssRankRestrict_eq_geometric' {𝕜 : Type*} [RCLike 𝕜] {E F : Type*} {m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (α : NNReal) (ℓ : E →ₗ[𝕜] F) (W : Submodule 𝕜 E) (hm : finrank 𝕜 W = m) :\n ℓ.EssentialRankRestrict α W hm = sInf {d | ∃ (S : Submodule 𝕜 F), finrank 𝕜 S ≤ d ∧\n ∀ x ∈ W, ‖x‖ ≤ 1 → ∃ y ∈ S, ‖ℓ x - y‖ ≤ α} := sorry\nlemma EssRankRestrict_top {𝕜 E F : Type*} [RCLike 𝕜] {n : ℕ} [NormedAddCommGroup E]\n [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E] [NormedAddCommGroup F] [InnerProductSpace 𝕜 F]\n [FiniteDimensional 𝕜 F] (hn : Module.finrank 𝕜 E = n) (α : NNReal) (l : E →ₗ[𝕜] F)\n (hn' : Module.finrank 𝕜 (⊤ : Submodule 𝕜 E) = n) :\n l.EssentialRankRestrict α ⊤ hn' = l.EssentialRank hn α := by sorry\nlemma EssentialRank_comp_Isometry {𝕜 E1 E2 F : Type*} {n m} [RCLike 𝕜]\n [NormedAddCommGroup E1] [InnerProductSpace 𝕜 E1] (hn : Module.finrank 𝕜 E1 = n)\n [FiniteDimensional 𝕜 E1] [NormedAddCommGroup E2] [InnerProductSpace 𝕜 E2]\n (hm : Module.finrank 𝕜 E2 = m) [FiniteDimensional 𝕜 E2] [NormedAddCommGroup F]\n [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n (e : E1 ≃ₗᵢ[𝕜] E2) {α : NNReal} (l : E2 →ₗ[𝕜] F) :\n l.EssentialRank hm α = (l ∘ₗ e.toLinearMap).EssentialRank hn α := by sorry\nlemma EssentialRankRestrict_comp_Isometry {𝕜 E F G : Type*} [RCLike 𝕜] {n m}\n [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [FiniteDimensional 𝕜 E]\n [NormedAddCommGroup F] [InnerProductSpace 𝕜 F] [FiniteDimensional 𝕜 F]\n [NormedAddCommGroup G] [InnerProductSpace 𝕜 G] [FiniteDimensional 𝕜 G]\n (l : F →ₗ[𝕜] G) (U : E ≃ₗᵢ[𝕜] F) (α : NNReal) (W : Submodule 𝕜 E)\n (hn : Module.finrank 𝕜 W = n) (hm : Module.finrank 𝕜 (W.map U.toLinearMap) = m) :\n l.EssentialRankRestrict α (W.map U.toLinearMap) hm =\n (l.comp U.toLinearMap).EssentialRankRestrict α W hn := by sorry\nend LinearMap\n/-- Abstraction of the greedy index set construction\n The key is a decreasing induction -/\nlemma Fin.greedyIndexSet {n : ℕ} (p : Fin n → Finset (Fin n) → Prop)\n (hp : ∀ i, ∀ I, i ∈ I → p i I) :\n ∃ I : Finset (Fin n), (∀ i ∈ I, ¬ p i (I ∩ Finset.Ioi i)) ∧\n ∀ i : Fin n, p i (I ∩ Finset.Ici i) := by sorry\nlemma NNReal.mul_inv_rev {a b : NNReal} : (a * b)⁻¹ = b⁻¹ * a⁻¹ := by sorry\nlemma mainlem2 {a b c f g : NNReal} {q s : ℝ} (hq : 0 ≤ q) (hb : 0 < b) (hc : 0 < c) (hf : 0 < f)\n (h : c ^ s * (a * (f ^ 2 / b) ^ s) ≤ g) :\n a ^ q ≤ b ^ (q * s) * c ^ (-(q * s)) * f ^ (-(q * s * 2)) * g ^ q := by sorry\ntheorem NNReal.rpow_sum {x : NNReal} (hx : x ≠ 0)\n {ι : Type*} [Fintype ι] (y : ι → ℝ) : x^(∑ i, y i) = ∏ i, x ^ (y i) := by sorry\nnamespace BrascampLieb\nvariable {J E F : Type*} {n m} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n (hn : Module.finrank ℝ E = n) [FiniteDimensional ℝ E] [NormedAddCommGroup F]\n [InnerProductSpace ℝ F] (hm : Module.finrank ℝ F = m) [FiniteDimensional ℝ F] {α : NNReal}\nopen EuclideanSpace\nomit [FiniteDimensional ℝ F] in\n/--\nGreedy index set construction.\nGiven a basis (e₁,...,eₐ) and threshold ε, construct I_j by processing indices\nfrom d down to 1, including i if dist(ℓ_j eᵢ, span{ℓ_j eₖ : k ∈ I_j, k > i}) ≥ ε.\nAlgorithm:\n1. Start with I = ∅\n2. For i from d down to 1:\n - Let S = {ℓ(e_k) : k ∈ I, k > i}\n - If dist(ℓ(e_i), span(S)) ≥ ε, add i to I\n3. Return I\n-/\nlemma greedy_index_set_exists {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : ∃ I : Finset (Fin d),\n (∀ i ∈ I, Metric.infDist (ℓ (single i 1)) (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ ''\n (I ∩ Finset.Ioi i))) ≥ α / NNReal.sqrt d) ∧ (∀ i, Metric.infDist (ℓ (single i (1 : ℝ)))\n (ℓ '' Submodule.span ℝ (basisFun (Fin d) ℝ '' (I ∩ Finset.Ici i))) < α / NNReal.sqrt d) := by sorry\nomit [FiniteDimensional ℝ F] in\n/-- A greedy choice of index set for the essential rank decomposition,\nchosen via `greedy_index_set_exists`. -/\nnoncomputable def greedy_index_set {d : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) : Finset (Fin d) :=\n greedy_index_set_exists hα ℓ|>.choose\nattribute [local instance] Fintype.ofFinite in\nlemma essRank_le_ncard_inter_greedy {d n : ℕ} (hα : 0 < α)\n (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) (i)\n (hn1 : Module.finrank ℝ ↥(Submodule.span ℝ\n (basisFun (Fin d) ℝ '' (SetLike.coe (Finset.Ici i)))) = n) :\n ℓ.EssentialRankRestrict α (Submodule.span ℝ (basisFun (Fin d) ℝ '' Finset.Ici i)) hn1 ≤\n Finset.card (greedy_index_set hα ℓ ∩ Finset.Ici i) := by sorry\nlemma greedy_index_set_volume_bound {d : ℕ} (hα : 0 < α) (ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F) :\n ((α : ℝ) / Real.sqrt d) ^ (2 * (greedy_index_set hα ℓ).card) ≤ (@Matrix.gram _\n (greedy_index_set hα ℓ) ℝ _ (ℓ ∘ basisFun (Fin d) ℝ ∘ Subtype.val)).det := by sorry\nopen LinearMap\nset_option maxHeartbeats 400000 in\n/-- Cardinality of greedy_index_set is equal to the dimension of the image -/\nlemma card_greedy_eq_of_essRank_eq {d : ℕ} (hm : Module.finrank ℝ F = m) (hα : 0 < α)\n {ℓ : EuclideanSpace ℝ (Fin d) →ₗ[ℝ] F} (hℓ : ℓ.EssentialRank finrank_euclideanSpace_fin α = m) :\n Finset.card (greedy_index_set hα ℓ) = Module.finrank ℝ F := by sorry\nset_option maxHeartbeats 400000 in\ninclude hn hm in\nlemma det_greedy_control (b : OrthonormalBasis (Fin n) ℝ E) (hα : 0 < α) {ℓ : E →ₗ[ℝ] F}\n (hℓ : ℓ.EssentialRank hn α = m) {Q : F →ₗ[ℝ] F} (hQ : Q.IsPositive) :\n Q.det * (α ^ 2 / n) ^ m ≤ ∏ i ∈ (greedy_index_set hα (ℓ ∘ₗ b.repr.symm.toLinearMap)),\n inner ℝ (Q (ℓ (b i))) (ℓ (b i)) := by sorry\nattribute [local grind! .] Real.rpow_pos_of_pos in\nlemma prod_rpow_eq_first_times_ratio_prod' {d : ℕ} (l : Fin (d + 1) → ℝ)\n (hl1 : ∀ i, 0 < l i) (c : Fin (d + 1) → ℝ) : ∏ i : Fin (d + 1), l i ^ c i =\n l 0 ^ (∑ i, c i) * ∏ k : Fin d, (l k.succ / l k.castSucc) ^ (∑ i ∈ Finset.univ.filter\n (fun i : Fin (d + 1) => k.castSucc < i), c i) := by sorry\nlemma telescoping_product_bound' {d : ℕ} (l : Fin (d + 1) → ℝ)\n (hl1 : ∀ i j : Fin (d + 1), i ≤ j → l j ≤ l i) (hl2 : ∀ i, 0 < l i)\n (c : Fin (d + 1) → ℝ) (S β : ℝ) (h_sum : ∑ i, c i = S)\n (ht : ∀ k (_ : k.1 < d), ∑ i ∈ Finset.univ.filter (fun i : Fin (d + 1) => k < i), c i ≥ -β) :\n ∏ i : Fin (d + 1), l i ^ c i ≤ l 0 ^ (S + β) * l (Fin.last d) ^ (-β) := by sorry\nlemma eigenvalue_telescoping' {d : ℕ} (l : Fin (d + 1) → ℝ) (hl1 : Antitone l) (hl2 : ∀ i, 0 < l i)\n (I : J → Finset (Fin (d + 1))) (q : J → NNReal) (β : NNReal) (Ac : NNReal)\n (h_card : ∑ j, q j * (I j).card = Ac) (h_percep : ∀ i : Fin (d + 1), (∑ j, q j *\n (I j ∩ Finset.Ici i).card) ≥ ((d + 1) - i : ℝ) - β) :\n ∏ j, (∏ i ∈ I j, l i) ^ (q j : ℝ) ≤ l 0 ^ (Ac - (d + 1) + β : ℝ) * (l (Fin.last d)) ^\n (- (β : ℝ)) * ∏ i, l i := by sorry\nend BrascampLieb"} -{"project_name": "BrooksTheorem", "name": "brooks_theorem", "type": "theorem", "code": "import Mathlib\n\nopen Finset\n/--\nBrooks' theorem states that for a finite connected graph G,\nthe chromatic number of G is at most the maximum degree of G,\nunless G is a complete graph or an odd cycle.\n-/\n\ntheorem brooks_theorem {V : Type} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj]\n (h_connected : G.Connected) :\n (G.chromaticNumber ≤ G.maxDegree) ∨\n (∃ n : ℕ, Nonempty (G ≃g SimpleGraph.completeGraph (Fin n))) ∨\n (∃ n : ℕ, Nonempty (G ≃g SimpleGraph.cycleGraph (2 * n + 3))) := by sorry"} -{"project_name": "BrunTheorem", "name": "brun", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n/-- The set of twin primes -/\n\ndef TwinPrimes : Set ℕ :=\n {p | p.Prime ∧ (p + 2).Prime}\n\nopen Classical in\n/-- Brun's theorem -/\n\ntheorem brun : Summable (fun n ↦ if n ∈ TwinPrimes then 1 / (n : ℝ) else 0) := by sorry"} -{"project_name": "BrunTitchmarshTheorem", "name": "brunTitchmarsh", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n/-- https://en.wikipedia.org/wiki/Brun%E2%80%93Titchmarsh_theorem (hard) -/\n\ntheorem brunTitchmarsh {x q a : ℕ} (ha : a < q) (hq : q < x) :\n {m ∈ Finset.range (x + 1) | m.Prime ∧ a = m%q}.card\n < 2 * x / (φ q * Real.log (x / (q : ℝ))) := by sorry"} -{"project_name": "BrunnMinkowski", "name": "pos_rpow_of_pos", "type": "lemma", "code": "import Mathlib\n\nopen Set MeasureTheory Pointwise ENNReal Real\n\nlemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) :\n 0 < x ^ r := by sorry"} -{"project_name": "BrunnMinkowski", "name": "prekopa_leindler_dim1_our", "type": "theorem", "code": "import Mathlib\n\nopen Set MeasureTheory Pointwise ENNReal Real\n\nlemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) :\n 0 < x ^ r := by sorry\n\ntheorem prekopa_leindler_dim1_our {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n (hg₁ : 0 ≤ g) (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry"} -{"project_name": "BrunnMinkowski", "name": "prekopa_leindler", "type": "theorem", "code": "import Mathlib\n\nopen Set MeasureTheory Pointwise ENNReal Real\n\nlemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) :\n 0 < x ^ r := by sorry\n\ntheorem prekopa_leindler_dim1_our {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n (hg₁ : 0 ≤ g) (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\n\ntheorem prekopa_leindler {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f : EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n {g : EuclideanSpace ℝ (Fin d) → ℝ} (hg₁ : 0 ≤ g) (hg₂ : Integrable g)\n {h : EuclideanSpace ℝ (Fin d) → ℝ} (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry"} -{"project_name": "BrunnMinkowski", "name": "integral_smul_eq_div", "type": "lemma", "code": "import Mathlib\n\nopen Set MeasureTheory Pointwise ENNReal Real\n\nlemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) :\n 0 < x ^ r := by sorry\n\ntheorem prekopa_leindler_dim1_our {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n (hg₁ : 0 ≤ g) (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\n\ntheorem prekopa_leindler {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f : EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n {g : EuclideanSpace ℝ (Fin d) → ℝ} (hg₁ : 0 ≤ g) (hg₂ : Integrable g)\n {h : EuclideanSpace ℝ (Fin d) → ℝ} (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\n\nlemma integral_smul_eq_div {d : ℕ} {f : EuclideanSpace ℝ (Fin d) → ℝ} (t : ℝ) (ht : 0 < t) :\n ∫ x, f (t • x) = (∫ x, f x) / t ^ d := by sorry"} -{"project_name": "BrunnMinkowski", "name": "prekopa_leindler'", "type": "theorem", "code": "import Mathlib\n\nopen Set MeasureTheory Pointwise ENNReal Real\n\nlemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) :\n 0 < x ^ r := by sorry\n\ntheorem prekopa_leindler_dim1_our {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n (hg₁ : 0 ≤ g) (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\n\ntheorem prekopa_leindler {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f : EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n {g : EuclideanSpace ℝ (Fin d) → ℝ} (hg₁ : 0 ≤ g) (hg₂ : Integrable g)\n {h : EuclideanSpace ℝ (Fin d) → ℝ} (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\n\nlemma integral_smul_eq_div {d : ℕ} {f : EuclideanSpace ℝ (Fin d) → ℝ} (t : ℝ) (ht : 0 < t) :\n ∫ x, f (t • x) = (∫ x, f x) / t ^ d := by sorry\n\ntheorem prekopa_leindler' {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f g h: EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f) (hg₁ : 0 ≤ g)\n (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤\n (1 - t) ^ (d * (1 - t)) * t ^ (d * t) * (∫ z, h z) := by sorry"} -{"project_name": "BrunnMinkowski", "name": "vol_mul_le", "type": "theorem", "code": "import Mathlib\n\nopen Set MeasureTheory Pointwise ENNReal Real\n\nlemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) :\n 0 < x ^ r := by sorry\n\ntheorem prekopa_leindler_dim1_our {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n (hg₁ : 0 ≤ g) (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\n\ntheorem prekopa_leindler {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f : EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n {g : EuclideanSpace ℝ (Fin d) → ℝ} (hg₁ : 0 ≤ g) (hg₂ : Integrable g)\n {h : EuclideanSpace ℝ (Fin d) → ℝ} (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\n\nlemma integral_smul_eq_div {d : ℕ} {f : EuclideanSpace ℝ (Fin d) → ℝ} (t : ℝ) (ht : 0 < t) :\n ∫ x, f (t • x) = (∫ x, f x) / t ^ d := by sorry\n\ntheorem prekopa_leindler' {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f g h: EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f) (hg₁ : 0 ≤ g)\n (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤\n (1 - t) ^ (d * (1 - t)) * t ^ (d * t) * (∫ z, h z) := by sorry\n\ntheorem vol_mul_le {n : ℕ} {A B : Set (EuclideanSpace ℝ (Fin n))} (hA2 : IsCompact A)\n (hA3 : MeasurableSet A) (hB2 : IsCompact B) (hA4 : volume A ≠ ⊤) (hB3 : MeasurableSet B)\n (hB4 : volume B ≠ ⊤) (hAB : volume (A + B) ≠ ⊤)\n (hA5 : 0 < volume A) (hB5 : 0 < volume B) {t : ℝ} (h0t : 0 < t) (ht1 : t < 1) :\n volume A ^ (1 - t) * volume B ^ t ≤ .ofReal ((1 - t)^(1 - t) * t^t) ^ n * volume (A + B) := by sorry"} -{"project_name": "BrunnMinkowski", "name": "EuclideanSpace.volume_pow_add_le", "type": "theorem", "code": "import Mathlib\n\nopen Set MeasureTheory Pointwise ENNReal\n/-- **The Additive Brunn-Minkowski Inequality** -/\n\ntheorem EuclideanSpace.volume_pow_add_le {n : ℕ} (hn : n ≥ 1) {A B : Set (EuclideanSpace ℝ (Fin n))}\n (hA1 : A.Nonempty) (hA2 : IsCompact A) (hA3 : MeasurableSet A)\n (hB1 : B.Nonempty) (hB2 : IsCompact B) (hB3 : MeasurableSet B) :\n (volume A) ^ (1 / n : ℝ) + (volume B) ^ (1 / n : ℝ) ≤ volume (A + B) ^ (1 / n : ℝ) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.BrunnMinkowski.BackgroundLemmas\nopen Set MeasureTheory Pointwise ENNReal Real\nlemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) :\n 0 < x ^ r := by sorry\ntheorem prekopa_leindler_dim1_our {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n (hg₁ : 0 ≤ g) (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\ntheorem prekopa_leindler {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f : EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n {g : EuclideanSpace ℝ (Fin d) → ℝ} (hg₁ : 0 ≤ g) (hg₂ : Integrable g)\n {h : EuclideanSpace ℝ (Fin d) → ℝ} (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\nlemma integral_smul_eq_div {d : ℕ} {f : EuclideanSpace ℝ (Fin d) → ℝ} (t : ℝ) (ht : 0 < t) :\n ∫ x, f (t • x) = (∫ x, f x) / t ^ d := by sorry\ntheorem prekopa_leindler' {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f g h: EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f) (hg₁ : 0 ≤ g)\n (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤\n (1 - t) ^ (d * (1 - t)) * t ^ (d * t) * (∫ z, h z) := by sorry\ntheorem vol_mul_le {n : ℕ} {A B : Set (EuclideanSpace ℝ (Fin n))} (hA2 : IsCompact A)\n (hA3 : MeasurableSet A) (hB2 : IsCompact B) (hA4 : volume A ≠ ⊤) (hB3 : MeasurableSet B)\n (hB4 : volume B ≠ ⊤) (hAB : volume (A + B) ≠ ⊤)\n (hA5 : 0 < volume A) (hB5 : 0 < volume B) {t : ℝ} (h0t : 0 < t) (ht1 : t < 1) :\n volume A ^ (1 - t) * volume B ^ t ≤ .ofReal ((1 - t)^(1 - t) * t^t) ^ n * volume (A + B) := by sorry"} -{"project_name": "BrunnMinkowski", "name": "EuclideanSpace.volume_pow_mul_le", "type": "theorem", "code": "import Mathlib\n\nopen Set MeasureTheory Pointwise ENNReal\n/-- **The Additive Brunn-Minkowski Inequality** -/\n\ntheorem EuclideanSpace.volume_pow_add_le {n : ℕ} (hn : n ≥ 1) {A B : Set (EuclideanSpace ℝ (Fin n))}\n (hA1 : A.Nonempty) (hA2 : IsCompact A) (hA3 : MeasurableSet A)\n (hB1 : B.Nonempty) (hB2 : IsCompact B) (hB3 : MeasurableSet B) :\n (volume A) ^ (1 / n : ℝ) + (volume B) ^ (1 / n : ℝ) ≤ volume (A + B) ^ (1 / n : ℝ) := by sorry\n/-- **The Multiplicative Brunn-Minkowski Inequality** -/\n\ntheorem EuclideanSpace.volume_pow_mul_le {n : ℕ} {a : ℝ} (hn : n ≥ 1) (ha : 0 ≤ a ∧ a ≤ 1)\n {A B : Set (EuclideanSpace ℝ (Fin n))}\n (hA : A.Nonempty ∧ IsCompact A ∧ MeasurableSet A)\n (hB : B.Nonempty ∧ IsCompact B ∧ MeasurableSet B) :\n (volume A) ^ a * (volume B) ^ (1 - a) ≤ volume (a • A + (1 - a) • B) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.BrunnMinkowski.BackgroundLemmas\nopen Set MeasureTheory Pointwise ENNReal Real\nlemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) :\n 0 < x ^ r := by sorry\ntheorem prekopa_leindler_dim1_our {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n (hg₁ : 0 ≤ g) (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\ntheorem prekopa_leindler {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f : EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f)\n {g : EuclideanSpace ℝ (Fin d) → ℝ} (hg₁ : 0 ≤ g) (hg₂ : Integrable g)\n {h : EuclideanSpace ℝ (Fin d) → ℝ} (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h ((1 - t) • x + t • y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (∫ z, h z) := by sorry\nlemma integral_smul_eq_div {d : ℕ} {f : EuclideanSpace ℝ (Fin d) → ℝ} (t : ℝ) (ht : 0 < t) :\n ∫ x, f (t • x) = (∫ x, f x) / t ^ d := by sorry\ntheorem prekopa_leindler' {t : ℝ} (ht₁ : 0 < t) (ht₂ : t < 1) {d : ℕ}\n {f g h: EuclideanSpace ℝ (Fin d) → ℝ} (hf₁ : 0 ≤ f) (hf₂ : Integrable f) (hg₁ : 0 ≤ g)\n (hg₂ : Integrable g) (hh₁ : 0 ≤ h) (hh₂ : Integrable h)\n (h₀ : ∀ x y, (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)) :\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤\n (1 - t) ^ (d * (1 - t)) * t ^ (d * t) * (∫ z, h z) := by sorry\ntheorem vol_mul_le {n : ℕ} {A B : Set (EuclideanSpace ℝ (Fin n))} (hA2 : IsCompact A)\n (hA3 : MeasurableSet A) (hB2 : IsCompact B) (hA4 : volume A ≠ ⊤) (hB3 : MeasurableSet B)\n (hB4 : volume B ≠ ⊤) (hAB : volume (A + B) ≠ ⊤)\n (hA5 : 0 < volume A) (hB5 : 0 < volume B) {t : ℝ} (h0t : 0 < t) (ht1 : t < 1) :\n volume A ^ (1 - t) * volume B ^ t ≤ .ofReal ((1 - t)^(1 - t) * t^t) ^ n * volume (A + B) := by sorry"} -{"project_name": "CameronErdos", "name": "cameron_erdos", "type": "theorem", "code": "import Mathlib\n\nopen Set Filter Asymptotics\n/-- A set s which contains no solutions of a + b = c -/\n\ndef IsSumFree {R : Type*} [Add R] (s : Set R) : Prop :=\n ∀ᵉ (a ∈ s) (b ∈ s) (c ∈ s), a + b ≠ c\n\ntheorem cameron_erdos :\n (fun (n : ℕ) ↦ (↑{s : Set ℕ | s ⊆ Finset.range n ∧ IsSumFree s}.ncard : ℝ))\n =O[atTop] (fun (n : ℕ) ↦ (2 : ℝ) ^ ((↑n : ℝ) / 2)) := by sorry"} -{"project_name": "CaristiFixedPointTheorem", "name": "caristi", "type": "theorem", "code": "import Mathlib\n\nopen Metric NNReal\n\ntheorem caristi {X : Type*} [MetricSpace X] [CompleteSpace X] {T : X → X} {f : X → ℝ≥0}\n (hf : LowerSemicontinuous f) (h : ∀ x : X, dist x (T x) ≤ f x - f (T x)) :\n ∃ x : X, T x = x := by sorry"} -{"project_name": "CarlsonTheorem", "name": "carlson", "type": "theorem", "code": "import Mathlib\n\nopen Real\n\ntheorem carlson {f : ℂ → ℂ} (f_diff : Differentiable ℂ f)\n (f_bound : ∃ C t : ℝ, ∀ x : ℂ, ‖f x‖ ≤ C * rexp (t * ‖x‖))\n (f_bound' : ∃ C c : ℝ, c < π ∧ ∀ x : ℝ, ‖f (.I * x)‖ ≤ C * rexp (c * |x|))\n (f_nat : ∀ n : ℕ, f n = 0): f = 0 := by sorry"} -{"project_name": "Carmichael", "name": "carmichael", "type": "theorem", "code": "import Mathlib\n\nopen Nat Int\n/--\nLucas sequence of the first kind.\n-/\n\ndef U (p q : ℤ) : ℕ → ℤ\n | 0 => 0\n | 1 => 1\n | n + 2 => p * U p q (n + 1) + q * U p q n\n\ntheorem carmichael {p q : ℤ} {n : ℕ}\n (hn : n ∉ ({1, 2, 6} : Set ℕ))\n (hn12 : n ≠ 12 ∨ (p ≠ 1 ∧ p ≠ -1) ∨ q ≠ -1)\n (hpq : IsCoprime p q)\n (hpq_disc : 0 < p ^ 2 - 4 * q)\n (hpq' : p ≠ 0) (hq : q ≠ 0) :\n (∃ r : ℕ, r.Prime ∧ (↑r : ℤ) ∣ U p q n ∧ ∀ m < n, ¬ (↑r : ℤ) ∣ U p q m ) := by sorry"} -{"project_name": "CartanBrauerHuaTheorem", "name": "hua_identity", "type": "lemma", "code": "import Mathlib\n\nvariable (D : Type*) [DivisionRing D]\n\nlemma hua_identity (a b : D) (hab : a * b ≠ b * a) :\n a = (b⁻¹ - (a - 1)⁻¹ * b⁻¹ * (a - 1)) * (a⁻¹ * b⁻¹ * a - (a - 1)⁻¹ * b⁻¹ * (a - 1))⁻¹ := by sorry"} -{"project_name": "CartanBrauerHuaTheorem", "name": "Subfield.mem_center_iff", "type": "lemma", "code": "import Mathlib\n\nvariable (D : Type*) [DivisionRing D]\n\nlemma hua_identity (a b : D) (hab : a * b ≠ b * a) :\n a = (b⁻¹ - (a - 1)⁻¹ * b⁻¹ * (a - 1)) * (a⁻¹ * b⁻¹ * a - (a - 1)⁻¹ * b⁻¹ * (a - 1))⁻¹ := by sorry\n\nsection mathlib\n\nvariable {K : Type*} [DivisionRing K]\n\nvariable (K) in\n/--\nThe center of a `DivisionRing` as a `Subfield`.\n-/\n\ndef Subfield.center : Subfield K where\n __ := Subring.center K\n inv_mem' x hx := by\n classical\n change _ ∈ Subring.center K at hx ⊢\n simp [Subring.mem_center_iff] at hx ⊢\n refine fun y ↦ if hx' : x = 0 then by simp [hx'] else ?_\n simp [mul_inv_eq_iff_eq_mul₀ hx', hx, ← mul_assoc, mul_inv_cancel₀ hx']\n\nlemma Subfield.mem_center_iff {x : K} :\n x ∈ Subfield.center K ↔ ∀ (y : K), y * x = x * y := sorry"} -{"project_name": "CartanBrauerHuaTheorem", "name": "cartan_brauer_hua", "type": "theorem", "code": "import Mathlib\n/-- The Cartan-Brauer-Hua Theorem:\nIf `D` is a division ring and `K` is a sub-division ring of `D` such that `x K x⁻¹ ⊆ K` for\nevery `x` not equal to `0` in `D`, then either `K` is contained in the center of `D` or `K = D`.\n-/\n\ntheorem cartan_brauer_hua {D : Type*} [DivisionRing D] (K : Subfield D)\n (hK1 : ∀ x : D, x ≠ 0 → ∀ k ∈ K, x * k * x⁻¹ ∈ K) (hK2 : K ≠ ⊤) :\n K ≤ Subfield.center D := by sorry", "imported_file": "-- File: LiveLeanTriathlon.CartanBrauerHuaTheorem.BackgroundLemmas\nvariable (D : Type*) [DivisionRing D]\nlemma hua_identity (a b : D) (hab : a * b ≠ b * a) :\n a = (b⁻¹ - (a - 1)⁻¹ * b⁻¹ * (a - 1)) * (a⁻¹ * b⁻¹ * a - (a - 1)⁻¹ * b⁻¹ * (a - 1))⁻¹ := by sorry\nsection mathlib\nvariable {K : Type*} [DivisionRing K]\nvariable (K) in\n/--\nThe center of a `DivisionRing` as a `Subfield`.\n-/\ndef Subfield.center : Subfield K where\n __ := Subring.center K\n inv_mem' x hx := by\n classical\n change _ ∈ Subring.center K at hx ⊢\n simp [Subring.mem_center_iff] at hx ⊢\n refine fun y ↦ if hx' : x = 0 then by simp [hx'] else ?_\n simp [mul_inv_eq_iff_eq_mul₀ hx', hx, ← mul_assoc, mul_inv_cancel₀ hx']\nlemma Subfield.mem_center_iff {x : K} :\n x ∈ Subfield.center K ↔ ∀ (y : K), y * x = x * y := sorry\nend mathlib"} -{"project_name": "CasoratiWeierstrass", "name": "Complex.Dense_iff", "type": "lemma", "code": "import Mathlib\n\nopen Complex Set Metric Filter Topology\n/-- An isolated singularity `z₀` of a holomorphic function `f` is not removable\nif there is a neighborhood `U` of `z₀` such that `f` is holomorphic on `U \\ {z₀}`,\nbut there is no holomorphic extension of `f` to `z₀`. -/\n\ndef IsolatedUnremovableSingularity (f : ℂ → ℂ) (c : ℂ) : Prop :=\n ∃ s ∈ 𝓝 c, DifferentiableOn ℂ f (s \\ {c})\n ∧ (¬∃ g : ℂ → ℂ, EqOn f g (s \\ {c}) ∧ DifferentiableAt ℂ g c)\n/-- An isolated singularity `z₀` of a holomorphic function `f` is called an essential singularity\nif it is neither a removable singularity nor a pole. -/\n\ndef EssentialSingularity (f : ℂ → ℂ) (c : ℂ) : Prop :=\n IsolatedUnremovableSingularity f c ∧ ¬∀ M, ∃ ε > 0, ∀ z, z ≠ c → dist z c < ε → M ≤ ‖f z‖\n\nlemma Complex.Dense_iff (S : Set ℂ) :\n Dense S ↔ (∀ w : ℂ, ∀ ε > 0, ∃ s ∈ S, ‖s - w‖ < ε) := by sorry"} -{"project_name": "CasoratiWeierstrass", "name": "boundedness_from_non_dense_image", "type": "lemma", "code": "import Mathlib\n\nopen Complex Set Metric Filter Topology\n/-- An isolated singularity `z₀` of a holomorphic function `f` is not removable\nif there is a neighborhood `U` of `z₀` such that `f` is holomorphic on `U \\ {z₀}`,\nbut there is no holomorphic extension of `f` to `z₀`. -/\n\ndef IsolatedUnremovableSingularity (f : ℂ → ℂ) (c : ℂ) : Prop :=\n ∃ s ∈ 𝓝 c, DifferentiableOn ℂ f (s \\ {c})\n ∧ (¬∃ g : ℂ → ℂ, EqOn f g (s \\ {c}) ∧ DifferentiableAt ℂ g c)\n/-- An isolated singularity `z₀` of a holomorphic function `f` is called an essential singularity\nif it is neither a removable singularity nor a pole. -/\n\ndef EssentialSingularity (f : ℂ → ℂ) (c : ℂ) : Prop :=\n IsolatedUnremovableSingularity f c ∧ ¬∀ M, ∃ ε > 0, ∀ z, z ≠ c → dist z c < ε → M ≤ ‖f z‖\n\nlemma Complex.Dense_iff (S : Set ℂ) :\n Dense S ↔ (∀ w : ℂ, ∀ ε > 0, ∃ s ∈ S, ‖s - w‖ < ε) := by sorry\n/-- If the image `f(U)` is not dense in `ℂ`, then there exists a complex number `w₀`\nand a real number `ε > 0` such that the function `g(z) = 1/(f(z) - w₀)` is holomorphic\nand bounded on `U`. -/\n\nlemma boundedness_from_non_dense_image {f : ℂ → ℂ} {c : ℂ}\n {s : Set ℂ}\n (hd : DifferentiableOn ℂ f (s \\ {c}))\n (hs : ¬Dense (f '' s)) :\n ∃ w₀ : ℂ, (DifferentiableOn ℂ (fun w => 1 / (f w - w₀)) (s \\ {c})) ∧\n (BddAbove (norm ∘ (fun z ↦ 1 / (f z - w₀)) '' (s \\ {c})))\n ∧ (∃ r, 0 < r ∧ ∀ x ∈ s, r ≤ ‖f x - w₀‖) := by sorry"} -{"project_name": "CasoratiWeierstrass", "name": "not_EssentialSingularity_of", "type": "theorem", "code": "import Mathlib\n\nopen Complex Set Metric Filter Topology\n/-- An isolated singularity `z₀` of a holomorphic function `f` is not removable\nif there is a neighborhood `U` of `z₀` such that `f` is holomorphic on `U \\ {z₀}`,\nbut there is no holomorphic extension of `f` to `z₀`. -/\n\ndef IsolatedUnremovableSingularity (f : ℂ → ℂ) (c : ℂ) : Prop :=\n ∃ s ∈ 𝓝 c, DifferentiableOn ℂ f (s \\ {c})\n ∧ (¬∃ g : ℂ → ℂ, EqOn f g (s \\ {c}) ∧ DifferentiableAt ℂ g c)\n/-- An isolated singularity `z₀` of a holomorphic function `f` is called an essential singularity\nif it is neither a removable singularity nor a pole. -/\n\ndef EssentialSingularity (f : ℂ → ℂ) (c : ℂ) : Prop :=\n IsolatedUnremovableSingularity f c ∧ ¬∀ M, ∃ ε > 0, ∀ z, z ≠ c → dist z c < ε → M ≤ ‖f z‖\n\nlemma Complex.Dense_iff (S : Set ℂ) :\n Dense S ↔ (∀ w : ℂ, ∀ ε > 0, ∃ s ∈ S, ‖s - w‖ < ε) := by sorry\n/-- If the image `f(U)` is not dense in `ℂ`, then there exists a complex number `w₀`\nand a real number `ε > 0` such that the function `g(z) = 1/(f(z) - w₀)` is holomorphic\nand bounded on `U`. -/\n\nlemma boundedness_from_non_dense_image {f : ℂ → ℂ} {c : ℂ}\n {s : Set ℂ}\n (hd : DifferentiableOn ℂ f (s \\ {c}))\n (hs : ¬Dense (f '' s)) :\n ∃ w₀ : ℂ, (DifferentiableOn ℂ (fun w => 1 / (f w - w₀)) (s \\ {c})) ∧\n (BddAbove (norm ∘ (fun z ↦ 1 / (f z - w₀)) '' (s \\ {c})))\n ∧ (∃ r, 0 < r ∧ ∀ x ∈ s, r ≤ ‖f x - w₀‖) := by sorry\n\ntheorem not_EssentialSingularity_of (f : ℂ → ℂ) {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c)\n (w0 : ℂ)\n (r : ℝ) (rh : 0 < r ∧ ∀ x ∈ s, r ≤ ‖f x - w0‖)\n (this :\n DifferentiableOn ℂ (Function.update (fun w ↦ 1 / (f w - w0)) c\n (limUnder (𝓝[≠] c) fun w ↦ 1 / (f w - w0))) s) :\n ¬EssentialSingularity f c := by sorry"} -{"project_name": "CasoratiWeierstrass", "name": "casorati_weierstrass", "type": "theorem", "code": "import Mathlib\n\nopen Complex Set Metric Filter Topology\n/-- An isolated singularity `z₀` of a holomorphic function `f` is not removable\nif there is a neighborhood `U` of `z₀` such that `f` is holomorphic on `U \\ {z₀}`,\nbut there is no holomorphic extension of `f` to `z₀`. -/\n\ndef IsolatedUnremovableSingularity (f : ℂ → ℂ) (c : ℂ) : Prop :=\n ∃ s ∈ 𝓝 c, DifferentiableOn ℂ f (s \\ {c})\n ∧ (¬∃ g : ℂ → ℂ, EqOn f g (s \\ {c}) ∧ DifferentiableAt ℂ g c)\n/-- An isolated singularity `z₀` of a holomorphic function `f` is called an essential singularity\nif it is neither a removable singularity nor a pole. -/\n\ndef EssentialSingularity (f : ℂ → ℂ) (c : ℂ) : Prop :=\n IsolatedUnremovableSingularity f c ∧ ¬∀ M, ∃ ε > 0, ∀ z, z ≠ c → dist z c < ε → M ≤ ‖f z‖\n\nlemma Complex.Dense_iff (S : Set ℂ) :\n Dense S ↔ (∀ w : ℂ, ∀ ε > 0, ∃ s ∈ S, ‖s - w‖ < ε) := by sorry\n/-- If the image `f(U)` is not dense in `ℂ`, then there exists a complex number `w₀`\nand a real number `ε > 0` such that the function `g(z) = 1/(f(z) - w₀)` is holomorphic\nand bounded on `U`. -/\n\nlemma boundedness_from_non_dense_image {f : ℂ → ℂ} {c : ℂ}\n {s : Set ℂ}\n (hd : DifferentiableOn ℂ f (s \\ {c}))\n (hs : ¬Dense (f '' s)) :\n ∃ w₀ : ℂ, (DifferentiableOn ℂ (fun w => 1 / (f w - w₀)) (s \\ {c})) ∧\n (BddAbove (norm ∘ (fun z ↦ 1 / (f z - w₀)) '' (s \\ {c})))\n ∧ (∃ r, 0 < r ∧ ∀ x ∈ s, r ≤ ‖f x - w₀‖) := by sorry\n\ntheorem not_EssentialSingularity_of (f : ℂ → ℂ) {s : Set ℂ} {c : ℂ} (hc : s ∈ 𝓝 c)\n (w0 : ℂ)\n (r : ℝ) (rh : 0 < r ∧ ∀ x ∈ s, r ≤ ‖f x - w0‖)\n (this :\n DifferentiableOn ℂ (Function.update (fun w ↦ 1 / (f w - w0)) c\n (limUnder (𝓝[≠] c) fun w ↦ 1 / (f w - w0))) s) :\n ¬EssentialSingularity f c := by sorry\n/-- Casorati-Weierstrass Theorem: If `f` is a holomorphic function with an essential\nsingularity at `z₀`, then for any punctured open neighborhood `U` of `z₀`,\nthe image `f(U)` is dense in the complex plane `ℂ`. -/\n\ntheorem casorati_weierstrass (f : ℂ → ℂ) {s : Set ℂ} {c : ℂ}\n (hess : EssentialSingularity f c)\n (hc : s ∈ 𝓝 c) (hd : DifferentiableOn ℂ f (s \\ {c})) :\n Dense (f '' s) := by sorry"} -{"project_name": "ChenTheorem", "name": "chen", "type": "theorem", "code": "import Mathlib\n\nopen Filter Nat\n\ntheorem chen : ∀ᶠ n in atTop, ∃ a b : ℕ,\n 2 * n = a + b ∧ a.Prime ∧ 1 < b ∧ b.primeFactorsList.length ≤ 2 := by sorry"} -{"project_name": "ColimitValuationRing", "name": "Ring.DirectLimit.exists_of₂", "type": "lemma", "code": "import Mathlib\n\nopen Ring\n\nuniverse u v\n\nvariable {ι : Type v} [Preorder ι] [IsDirectedOrder ι] [Nonempty ι]\n\nvariable {G : ι → Type u} [∀ i, CommRing (G i)]\n\nvariable (f : ∀ i j, i ≤ j → G i →+* G j)\n\nvariable [DirectedSystem G (fun i j h => f i j h)]\nomit [DirectedSystem G fun i j h ↦ ⇑(f i j h)] in\n/-- Any two elements of a direct limit can be represented at a common index. -/\n\nlemma Ring.DirectLimit.exists_of₂ (a b : Ring.DirectLimit G (fun i j h => f i j h)) :\n ∃ (k : ι) (x : G k) (y : G k),\n Ring.DirectLimit.of G (fun i j h => f i j h) k x = a ∧\n Ring.DirectLimit.of G (fun i j h => f i j h) k y = b := by sorry"} -{"project_name": "ColimitValuationRing", "name": "Ring.DirectLimit.nontrivial_of_nontrivial", "type": "lemma", "code": "import Mathlib\n\nopen Ring\n\nuniverse u v\n\nvariable {ι : Type v} [Preorder ι] [IsDirectedOrder ι] [Nonempty ι]\n\nvariable {G : ι → Type u} [∀ i, CommRing (G i)]\n\nvariable (f : ∀ i j, i ≤ j → G i →+* G j)\n\nvariable [DirectedSystem G (fun i j h => f i j h)]\nomit [DirectedSystem G fun i j h ↦ ⇑(f i j h)] in\n/-- Any two elements of a direct limit can be represented at a common index. -/\n\nlemma Ring.DirectLimit.exists_of₂ (a b : Ring.DirectLimit G (fun i j h => f i j h)) :\n ∃ (k : ι) (x : G k) (y : G k),\n Ring.DirectLimit.of G (fun i j h => f i j h) k x = a ∧\n Ring.DirectLimit.of G (fun i j h => f i j h) k y = b := by sorry\n/-- A direct limit of nontrivial commutative rings is nontrivial. -/\n\nlemma Ring.DirectLimit.nontrivial_of_nontrivial [∀ i, Nontrivial (G i)] :\n Nontrivial (Ring.DirectLimit G (fun i j h => f i j h)) := by sorry"} -{"project_name": "ColimitValuationRing", "name": "Ring.DirectLimit.noZeroDivisors_of_isDomain", "type": "lemma", "code": "import Mathlib\n\nopen Ring\n\nuniverse u v\n\nvariable {ι : Type v} [Preorder ι] [IsDirectedOrder ι] [Nonempty ι]\n\nvariable {G : ι → Type u} [∀ i, CommRing (G i)]\n\nvariable (f : ∀ i j, i ≤ j → G i →+* G j)\n\nvariable [DirectedSystem G (fun i j h => f i j h)]\nomit [DirectedSystem G fun i j h ↦ ⇑(f i j h)] in\n/-- Any two elements of a direct limit can be represented at a common index. -/\n\nlemma Ring.DirectLimit.exists_of₂ (a b : Ring.DirectLimit G (fun i j h => f i j h)) :\n ∃ (k : ι) (x : G k) (y : G k),\n Ring.DirectLimit.of G (fun i j h => f i j h) k x = a ∧\n Ring.DirectLimit.of G (fun i j h => f i j h) k y = b := by sorry\n/-- A direct limit of nontrivial commutative rings is nontrivial. -/\n\nlemma Ring.DirectLimit.nontrivial_of_nontrivial [∀ i, Nontrivial (G i)] :\n Nontrivial (Ring.DirectLimit G (fun i j h => f i j h)) := by sorry\n/-- A direct limit of integral domains has no zero divisors. -/\n\nlemma Ring.DirectLimit.noZeroDivisors_of_isDomain [∀ i, IsDomain (G i)] :\n NoZeroDivisors (Ring.DirectLimit G (fun i j h => f i j h)) := by sorry"} -{"project_name": "ColimitValuationRing", "name": "Ring.DirectLimit.dvd_of_dvd_of", "type": "lemma", "code": "import Mathlib\n\nopen Ring\n\nuniverse u v\n\nvariable {ι : Type v} [Preorder ι] [IsDirectedOrder ι] [Nonempty ι]\n\nvariable {G : ι → Type u} [∀ i, CommRing (G i)]\n\nvariable (f : ∀ i j, i ≤ j → G i →+* G j)\n\nvariable [DirectedSystem G (fun i j h => f i j h)]\nomit [IsDirectedOrder ι] [Nonempty ι] [DirectedSystem G fun i j h ↦ ⇑(f i j h)] in\n/-- Divisibility in a component lifts to the direct limit. -/\n\nlemma Ring.DirectLimit.dvd_of_dvd_of {k : ι} {x y : G k}\n (h : x ∣ y) :\n Ring.DirectLimit.of G (fun i j h => f i j h) k x ∣\n Ring.DirectLimit.of G (fun i j h => f i j h) k y := by sorry", "imported_file": "-- File: LiveLeanTriathlon.ColimitValuationRing.BackgroundLemmas\nopen Ring\nuniverse u v\nvariable {ι : Type v} [Preorder ι] [IsDirectedOrder ι] [Nonempty ι]\nvariable {G : ι → Type u} [∀ i, CommRing (G i)]\nvariable (f : ∀ i j, i ≤ j → G i →+* G j)\nvariable [DirectedSystem G (fun i j h => f i j h)]\nomit [DirectedSystem G fun i j h ↦ ⇑(f i j h)] in\n/-- Any two elements of a direct limit can be represented at a common index. -/\nlemma Ring.DirectLimit.exists_of₂ (a b : Ring.DirectLimit G (fun i j h => f i j h)) :\n ∃ (k : ι) (x : G k) (y : G k),\n Ring.DirectLimit.of G (fun i j h => f i j h) k x = a ∧\n Ring.DirectLimit.of G (fun i j h => f i j h) k y = b := by sorry\n/-- A direct limit of nontrivial commutative rings is nontrivial. -/\nlemma Ring.DirectLimit.nontrivial_of_nontrivial [∀ i, Nontrivial (G i)] :\n Nontrivial (Ring.DirectLimit G (fun i j h => f i j h)) := by sorry\n/-- A direct limit of integral domains has no zero divisors. -/\nlemma Ring.DirectLimit.noZeroDivisors_of_isDomain [∀ i, IsDomain (G i)] :\n NoZeroDivisors (Ring.DirectLimit G (fun i j h => f i j h)) := by sorry\n/-- A direct limit of integral domains is an integral domain. -/\ninstance Ring.DirectLimit.isDomain_of_isDomain [∀ i, IsDomain (G i)] :\n IsDomain (Ring.DirectLimit G (fun i j h => f i j h)) := by\n have := Ring.DirectLimit.nontrivial_of_nontrivial f\n have := Ring.DirectLimit.noZeroDivisors_of_isDomain f\n exact NoZeroDivisors.to_isDomain _"} -{"project_name": "ColimitValuationRing", "name": "Ring.DirectLimit.dvd_total", "type": "lemma", "code": "import Mathlib\n\nopen Ring\n\nuniverse u v\n\nvariable {ι : Type v} [Preorder ι] [IsDirectedOrder ι] [Nonempty ι]\n\nvariable {G : ι → Type u} [∀ i, CommRing (G i)]\n\nvariable (f : ∀ i j, i ≤ j → G i →+* G j)\n\nvariable [DirectedSystem G (fun i j h => f i j h)]\nomit [IsDirectedOrder ι] [Nonempty ι] [DirectedSystem G fun i j h ↦ ⇑(f i j h)] in\n/-- Divisibility in a component lifts to the direct limit. -/\n\nlemma Ring.DirectLimit.dvd_of_dvd_of {k : ι} {x y : G k}\n (h : x ∣ y) :\n Ring.DirectLimit.of G (fun i j h => f i j h) k x ∣\n Ring.DirectLimit.of G (fun i j h => f i j h) k y := by sorry\nomit [DirectedSystem G fun i j h ↦ ⇑(f i j h)] in\n/-- The dvd-totality property of valuation rings transfers to the direct limit. -/\n\nlemma Ring.DirectLimit.dvd_total\n [∀ i, IsDomain (G i)] [∀ i, ValuationRing (G i)]\n (a b : Ring.DirectLimit G (fun i j h => f i j h)) :\n a ∣ b ∨ b ∣ a := by sorry", "imported_file": "-- File: LiveLeanTriathlon.ColimitValuationRing.BackgroundLemmas\nopen Ring\nuniverse u v\nvariable {ι : Type v} [Preorder ι] [IsDirectedOrder ι] [Nonempty ι]\nvariable {G : ι → Type u} [∀ i, CommRing (G i)]\nvariable (f : ∀ i j, i ≤ j → G i →+* G j)\nvariable [DirectedSystem G (fun i j h => f i j h)]\nomit [DirectedSystem G fun i j h ↦ ⇑(f i j h)] in\n/-- Any two elements of a direct limit can be represented at a common index. -/\nlemma Ring.DirectLimit.exists_of₂ (a b : Ring.DirectLimit G (fun i j h => f i j h)) :\n ∃ (k : ι) (x : G k) (y : G k),\n Ring.DirectLimit.of G (fun i j h => f i j h) k x = a ∧\n Ring.DirectLimit.of G (fun i j h => f i j h) k y = b := by sorry\n/-- A direct limit of nontrivial commutative rings is nontrivial. -/\nlemma Ring.DirectLimit.nontrivial_of_nontrivial [∀ i, Nontrivial (G i)] :\n Nontrivial (Ring.DirectLimit G (fun i j h => f i j h)) := by sorry\n/-- A direct limit of integral domains has no zero divisors. -/\nlemma Ring.DirectLimit.noZeroDivisors_of_isDomain [∀ i, IsDomain (G i)] :\n NoZeroDivisors (Ring.DirectLimit G (fun i j h => f i j h)) := by sorry\n/-- A direct limit of integral domains is an integral domain. -/\ninstance Ring.DirectLimit.isDomain_of_isDomain [∀ i, IsDomain (G i)] :\n IsDomain (Ring.DirectLimit G (fun i j h => f i j h)) := by\n have := Ring.DirectLimit.nontrivial_of_nontrivial f\n have := Ring.DirectLimit.noZeroDivisors_of_isDomain f\n exact NoZeroDivisors.to_isDomain _"} -{"project_name": "CondorcetJury", "name": "Finset.sum_ite_zero_eq_filter", "type": "theorem", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry"} -{"project_name": "CondorcetJury", "name": "PMF.binomial_add_binomial", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry"} -{"project_name": "CondorcetJury", "name": "choose_2n1_symm", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry"} -{"project_name": "CondorcetJury", "name": "one_sub_lt_self_of_half_lt", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry"} -{"project_name": "CondorcetJury", "name": "condorcet_extra_pos", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry"} -{"project_name": "CondorcetJury", "name": "key_algebraic_identity_real", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry"} -{"project_name": "CondorcetJury", "name": "one_sub_le_of_half_le", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry"} -{"project_name": "CondorcetJury", "name": "key_identity_nnreal", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry"} -{"project_name": "CondorcetJury", "name": "jury_majority_as_ennreal_sum", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry"} -{"project_name": "CondorcetJury", "name": "B_term_eq_PMF", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry"} -{"project_name": "CondorcetJury", "name": "B_term_succ_eq_PMF", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry"} -{"project_name": "CondorcetJury", "name": "p_sq_B_eq", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry\n\nlemma p_sq_B_eq (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n p^2 * B_term p n = (1 - p)^2 * B_term_succ p n + condorcet_extra p n := by sorry"} -{"project_name": "CondorcetJury", "name": "binomial_2_apply_0", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry\n\nlemma p_sq_B_eq (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n p^2 * B_term p n = (1 - p)^2 * B_term_succ p n + condorcet_extra p n := by sorry\n\nlemma binomial_2_apply_0 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨0, by omega⟩ = ((1 - p : NNReal) : ENNReal)^2 := by sorry"} -{"project_name": "CondorcetJury", "name": "binomial_2_apply_1", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry\n\nlemma p_sq_B_eq (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n p^2 * B_term p n = (1 - p)^2 * B_term_succ p n + condorcet_extra p n := by sorry\n\nlemma binomial_2_apply_0 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨0, by omega⟩ = ((1 - p : NNReal) : ENNReal)^2 := by sorry\n\nlemma binomial_2_apply_1 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨1, by omega⟩ = 2 * (p : ENNReal) * ((1 - p : NNReal) : ENNReal) := by sorry"} -{"project_name": "CondorcetJury", "name": "binomial_2_apply_2", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry\n\nlemma p_sq_B_eq (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n p^2 * B_term p n = (1 - p)^2 * B_term_succ p n + condorcet_extra p n := by sorry\n\nlemma binomial_2_apply_0 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨0, by omega⟩ = ((1 - p : NNReal) : ENNReal)^2 := by sorry\n\nlemma binomial_2_apply_1 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨1, by omega⟩ = 2 * (p : ENNReal) * ((1 - p : NNReal) : ENNReal) := by sorry\n\nlemma binomial_2_apply_2 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨2, by omega⟩ = (p : ENNReal)^2 := by sorry"} -{"project_name": "CondorcetJury", "name": "tail_prob_split", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry\n\nlemma p_sq_B_eq (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n p^2 * B_term p n = (1 - p)^2 * B_term_succ p n + condorcet_extra p n := by sorry\n\nlemma binomial_2_apply_0 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨0, by omega⟩ = ((1 - p : NNReal) : ENNReal)^2 := by sorry\n\nlemma binomial_2_apply_1 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨1, by omega⟩ = 2 * (p : ENNReal) * ((1 - p : NNReal) : ENNReal) := by sorry\n\nlemma binomial_2_apply_2 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨2, by omega⟩ = (p : ENNReal)^2 := by sorry\n\nlemma tail_prob_split (p : NNReal) (hp : p ≤ 1) (m k : ℕ) (hk : k ≤ m) :\n (∑ j : Fin (m + 1), if k ≤ (j : ℕ) then (PMF.binomial p hp m) j else 0) =\n (PMF.binomial p hp m) ⟨k, Nat.lt_succ_of_le hk⟩ +\n (∑ j : Fin (m + 1), if k < (j : ℕ) then (PMF.binomial p hp m) j else 0) := by sorry"} -{"project_name": "CondorcetJury", "name": "convolution_identity", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry\n\nlemma p_sq_B_eq (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n p^2 * B_term p n = (1 - p)^2 * B_term_succ p n + condorcet_extra p n := by sorry\n\nlemma binomial_2_apply_0 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨0, by omega⟩ = ((1 - p : NNReal) : ENNReal)^2 := by sorry\n\nlemma binomial_2_apply_1 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨1, by omega⟩ = 2 * (p : ENNReal) * ((1 - p : NNReal) : ENNReal) := by sorry\n\nlemma binomial_2_apply_2 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨2, by omega⟩ = (p : ENNReal)^2 := by sorry\n\nlemma tail_prob_split (p : NNReal) (hp : p ≤ 1) (m k : ℕ) (hk : k ≤ m) :\n (∑ j : Fin (m + 1), if k ≤ (j : ℕ) then (PMF.binomial p hp m) j else 0) =\n (PMF.binomial p hp m) ⟨k, Nat.lt_succ_of_le hk⟩ +\n (∑ j : Fin (m + 1), if k < (j : ℕ) then (PMF.binomial p hp m) j else 0) := by sorry\n\nlemma convolution_identity (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n jury_majority_decision_probability p hp (n + 1) + (1 - p)^2 * B_term_succ p n =\n jury_majority_decision_probability p hp n + p^2 * B_term p n := by sorry"} -{"project_name": "CondorcetJury", "name": "jury_probability_recurrence", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry\n\nlemma p_sq_B_eq (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n p^2 * B_term p n = (1 - p)^2 * B_term_succ p n + condorcet_extra p n := by sorry\n\nlemma binomial_2_apply_0 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨0, by omega⟩ = ((1 - p : NNReal) : ENNReal)^2 := by sorry\n\nlemma binomial_2_apply_1 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨1, by omega⟩ = 2 * (p : ENNReal) * ((1 - p : NNReal) : ENNReal) := by sorry\n\nlemma binomial_2_apply_2 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨2, by omega⟩ = (p : ENNReal)^2 := by sorry\n\nlemma tail_prob_split (p : NNReal) (hp : p ≤ 1) (m k : ℕ) (hk : k ≤ m) :\n (∑ j : Fin (m + 1), if k ≤ (j : ℕ) then (PMF.binomial p hp m) j else 0) =\n (PMF.binomial p hp m) ⟨k, Nat.lt_succ_of_le hk⟩ +\n (∑ j : Fin (m + 1), if k < (j : ℕ) then (PMF.binomial p hp m) j else 0) := by sorry\n\nlemma convolution_identity (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n jury_majority_decision_probability p hp (n + 1) + (1 - p)^2 * B_term_succ p n =\n jury_majority_decision_probability p hp n + p^2 * B_term p n := by sorry\n\nlemma jury_probability_recurrence (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n jury_majority_decision_probability p hp (n + 1) =\n jury_majority_decision_probability p hp n + condorcet_extra p n := by sorry"} -{"project_name": "CondorcetJury", "name": "jury_majority_decision_probability_succ_lt", "type": "lemma", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry\n\nlemma p_sq_B_eq (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n p^2 * B_term p n = (1 - p)^2 * B_term_succ p n + condorcet_extra p n := by sorry\n\nlemma binomial_2_apply_0 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨0, by omega⟩ = ((1 - p : NNReal) : ENNReal)^2 := by sorry\n\nlemma binomial_2_apply_1 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨1, by omega⟩ = 2 * (p : ENNReal) * ((1 - p : NNReal) : ENNReal) := by sorry\n\nlemma binomial_2_apply_2 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨2, by omega⟩ = (p : ENNReal)^2 := by sorry\n\nlemma tail_prob_split (p : NNReal) (hp : p ≤ 1) (m k : ℕ) (hk : k ≤ m) :\n (∑ j : Fin (m + 1), if k ≤ (j : ℕ) then (PMF.binomial p hp m) j else 0) =\n (PMF.binomial p hp m) ⟨k, Nat.lt_succ_of_le hk⟩ +\n (∑ j : Fin (m + 1), if k < (j : ℕ) then (PMF.binomial p hp m) j else 0) := by sorry\n\nlemma convolution_identity (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n jury_majority_decision_probability p hp (n + 1) + (1 - p)^2 * B_term_succ p n =\n jury_majority_decision_probability p hp n + p^2 * B_term p n := by sorry\n\nlemma jury_probability_recurrence (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n jury_majority_decision_probability p hp (n + 1) =\n jury_majority_decision_probability p hp n + condorcet_extra p n := by sorry\n\nlemma jury_majority_decision_probability_succ_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p)\n (hp_lt : p < 1) (n : ℕ) :\n jury_majority_decision_probability p hp n < jury_majority_decision_probability p hp (n + 1) := by sorry"} -{"project_name": "CondorcetJury", "name": "condorcet_jury_theorem", "type": "theorem", "code": "import Mathlib\n\nopen Real PMF BigOperators ENNReal NNReal Finset\nnoncomputable section\n\nopen scoped Classical\n\nsection Finset\n\nuniverse u v\n\ntheorem Finset.sum_ite_zero_eq_filter\n {ι : Type u} {M : Type v} [AddCommMonoid M] (s : Finset ι) (p : ι → Prop) [DecidablePred p]\n (a : ι → M) :\n (∑ i ∈ s, if p i then a i else 0) = ∑ i ∈ s.filter p, a i := by sorry\n\nend Finset\n\nsection Binomial\n/--\nA function that behaves as applying a PMF, but returns an `NNReal` instead of an `ENNReal`.\n-/\n\ndef PMF.apply_NNReal {α : Type} (p : PMF α) (a : α) : NNReal :=\n ENNReal.toNNReal (p a)\n\nlemma PMF.binomial_add_binomial (p : NNReal) (hp : p ≤ 1) (m₁ m₂ : ℕ) :\n (do\n let k ← PMF.binomial p hp (m₁ + m₂)\n return (k : ℕ))\n =\n (do\n let k ← PMF.binomial p hp m₁\n let l ← PMF.binomial p hp m₂\n return (k + l : ℕ) ) := by sorry\n\nend Binomial\n\nsection Definitions\n/--\nThe probability that a jury of size `2n+1`, where each juror has an independent probability `p`\nof making the correct decision, reaches the correct majority decision.\n-/\n\ndef jury_majority_decision_probability (p : NNReal) (hp : p ≤ 1) (n : ℕ) : NNReal :=\n ((PMF.binomial p hp (2 * n + 1)).map (fun k => if k > n then true else false)).apply_NNReal true\n\nend Definitions\n\nsection MainTheorem\n\nlemma choose_2n1_symm (n : ℕ) : (2 * n + 1).choose n = (2 * n + 1).choose (n + 1) := by sorry\n\nlemma one_sub_lt_self_of_half_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) :\n (1 - p : NNReal) < p := by sorry\n/--\nThe extra term that appears in the key identity for Condorcet's Jury Theorem.\n-/\n\ndef condorcet_extra (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * (p * (1 - p))^(n+1) * (p - (1 - p))\n\nlemma condorcet_extra_pos (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1) (n : ℕ) :\n 0 < condorcet_extra p n := by sorry\n\nlemma key_algebraic_identity_real (p : ℝ) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * (C * p^n * q^(n+1)) = q^2 * (C * p^(n+1) * q^n) + C * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma one_sub_le_of_half_le (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 ≤ p) :\n (1 - p : NNReal) ≤ p := by sorry\n\nlemma key_identity_nnreal (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n let q := 1 - p\n let C : ℕ := (2 * n + 1).choose n\n p^2 * ((C : NNReal) * p^n * q^(n+1)) = q^2 * ((C : NNReal) * p^(n+1) * q^n) + (C : NNReal) * (p*q)^(n+1) * (p - q) := by sorry\n\nlemma jury_majority_as_ennreal_sum (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (jury_majority_decision_probability p hp n : ENNReal) =\n ∑ k : Fin (2*n+1+1), if n < (k : ℕ) then (PMF.binomial p hp (2*n+1)) k else 0 := by sorry\n/--\nA helper definition:\nthe n-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^n * (1 - p)^(n + 1)\n/--\nA helper definition:\nthe (n+1)-th term in the sum for the binomial PMF at (2n+1) with success probability p,\n-/\n\ndef B_term_succ (p : NNReal) (n : ℕ) : NNReal :=\n ((2 * n + 1).choose n : ℕ) * p^(n + 1) * (1 - p)^n\n\nlemma B_term_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n, by omega⟩ := by sorry\n\nlemma B_term_succ_eq_PMF (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n (B_term_succ p n : ENNReal) = (PMF.binomial p hp (2 * n + 1)) ⟨n + 1, by omega⟩ := by sorry\n\nlemma p_sq_B_eq (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n p^2 * B_term p n = (1 - p)^2 * B_term_succ p n + condorcet_extra p n := by sorry\n\nlemma binomial_2_apply_0 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨0, by omega⟩ = ((1 - p : NNReal) : ENNReal)^2 := by sorry\n\nlemma binomial_2_apply_1 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨1, by omega⟩ = 2 * (p : ENNReal) * ((1 - p : NNReal) : ENNReal) := by sorry\n\nlemma binomial_2_apply_2 (p : NNReal) (hp : p ≤ 1) :\n (PMF.binomial p hp 2) ⟨2, by omega⟩ = (p : ENNReal)^2 := by sorry\n\nlemma tail_prob_split (p : NNReal) (hp : p ≤ 1) (m k : ℕ) (hk : k ≤ m) :\n (∑ j : Fin (m + 1), if k ≤ (j : ℕ) then (PMF.binomial p hp m) j else 0) =\n (PMF.binomial p hp m) ⟨k, Nat.lt_succ_of_le hk⟩ +\n (∑ j : Fin (m + 1), if k < (j : ℕ) then (PMF.binomial p hp m) j else 0) := by sorry\n\nlemma convolution_identity (p : NNReal) (hp : p ≤ 1) (n : ℕ) :\n jury_majority_decision_probability p hp (n + 1) + (1 - p)^2 * B_term_succ p n =\n jury_majority_decision_probability p hp n + p^2 * B_term p n := by sorry\n\nlemma jury_probability_recurrence (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (n : ℕ) :\n jury_majority_decision_probability p hp (n + 1) =\n jury_majority_decision_probability p hp n + condorcet_extra p n := by sorry\n\nlemma jury_majority_decision_probability_succ_lt (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p)\n (hp_lt : p < 1) (n : ℕ) :\n jury_majority_decision_probability p hp n < jury_majority_decision_probability p hp (n + 1) := by sorry\n\ntheorem condorcet_jury_theorem (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1)\n (n m : ℕ) (n_lt_m : n < m) :\n jury_majority_decision_probability p hp n < jury_majority_decision_probability p hp m := by sorry"} -{"project_name": "ContinuousMappingAs", "name": "ae_tendsto_comp_of_ae_tendsto_of_forall_continuousAt", "type": "theorem", "code": "import Mathlib\n\nopen MeasureTheory Filter Topology\n\nopen scoped ENNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω}\n\nvariable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {X₀ : Set X}\n\nvariable {g : X → Y}\n/-- The **Continuous Mapping Theorem**, almost sure version. -/\n\ntheorem ae_tendsto_comp_of_ae_tendsto_of_forall_continuousAt {ι : Type*} {F : Filter ι}\n {rvs : ι → Ω → X} {rv : Ω → X} (g_cont : ∀ x ∈ X₀, ContinuousAt g x)\n (rv_supp : ∀ᵐ ω ∂P, rv ω ∈ X₀) (rvs_lim_as : ∀ᵐ ω ∂P, Tendsto (rvs · ω) F (𝓝 (rv ω))) :\n ∀ᵐ ω ∂P, Tendsto (fun i ↦ g (rvs i ω)) F (𝓝 (g (rv ω))) := by sorry"} -{"project_name": "ContinuousMappingLaw", "name": "ProbabilityMeasure.tendsto_of_forall_isClosed_ge_limsup", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology ENNReal NNReal\n\nopen scoped ENNReal\n\nlemma ProbabilityMeasure.tendsto_of_forall_isClosed_ge_limsup\n {Z : Type*} [MeasurableSpace Z] [TopologicalSpace Z] [OpensMeasurableSpace Z]\n {ι : Type*} {μ : ProbabilityMeasure Z}\n {μs : ι → ProbabilityMeasure Z} {L : Filter ι} [L.IsCountablyGenerated]\n (h_closeds : ∀ F, IsClosed F → μ F ≥ L.limsup (fun i ↦ μs i F)) :\n L.Tendsto (fun i ↦ μs i) (𝓝 μ) := by sorry"} -{"project_name": "ContinuousMappingLaw", "name": "inter_closure_preimage_ss_preimage_closure_of_forall_continuousAt", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology ENNReal NNReal\n\nopen scoped ENNReal\n\nlemma ProbabilityMeasure.tendsto_of_forall_isClosed_ge_limsup\n {Z : Type*} [MeasurableSpace Z] [TopologicalSpace Z] [OpensMeasurableSpace Z]\n {ι : Type*} {μ : ProbabilityMeasure Z}\n {μs : ι → ProbabilityMeasure Z} {L : Filter ι} [L.IsCountablyGenerated]\n (h_closeds : ∀ F, IsClosed F → μ F ≥ L.limsup (fun i ↦ μs i F)) :\n L.Tendsto (fun i ↦ μs i) (𝓝 μ) := by sorry\n\nvariable {X Y : Type*} [MetricSpace X] [MetricSpace Y]\n\nvariable {X₀ : Set X}\n\nvariable {g : X → Y}\n\nlemma inter_closure_preimage_ss_preimage_closure_of_forall_continuousAt\n (g_cont : ∀ x ∈ X₀, ContinuousAt g x) (s : Set Y) :\n X₀ ∩ (closure (g ⁻¹' s)) ⊆ g ⁻¹' (closure s) := by sorry"} -{"project_name": "ContinuousMappingLaw", "name": "ProbabilityMeasure.tendsto_map_of_forall_continuousAt", "type": "theorem", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology ENNReal NNReal\n\nopen scoped ENNReal\n\nvariable {X Y : Type*} [MetricSpace X] [MetricSpace Y]\n\nvariable [MeasurableSpace X] [OpensMeasurableSpace X] [MeasurableSpace Y] [OpensMeasurableSpace Y]\n\nvariable {Ps : ℕ → ProbabilityMeasure X} {P : ProbabilityMeasure X}\n\nvariable {X₀ : Set X} {g : X → Y}\n/-- The **Continuous Mapping Theorem**, convergence in distribution version. -/\n\ntheorem ProbabilityMeasure.tendsto_map_of_forall_continuousAt\n (g_cont : ∀ x ∈ X₀, ContinuousAt g x) (g_mble : Measurable g)\n (P_supp : ∀ᵐ x ∂(P.toMeasure), x ∈ X₀) (Ps_lim : Tendsto Ps atTop (𝓝 P)) :\n Tendsto (fun n ↦ (Ps n).map g_mble.aemeasurable) atTop (𝓝 (P.map g_mble.aemeasurable)) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.ContinuousMappingLaw.BackgroundLemmas\nopen MeasureTheory ProbabilityTheory Filter Topology ENNReal NNReal\nopen scoped ENNReal\nlemma ProbabilityMeasure.tendsto_of_forall_isClosed_ge_limsup\n {Z : Type*} [MeasurableSpace Z] [TopologicalSpace Z] [OpensMeasurableSpace Z]\n {ι : Type*} {μ : ProbabilityMeasure Z}\n {μs : ι → ProbabilityMeasure Z} {L : Filter ι} [L.IsCountablyGenerated]\n (h_closeds : ∀ F, IsClosed F → μ F ≥ L.limsup (fun i ↦ μs i F)) :\n L.Tendsto (fun i ↦ μs i) (𝓝 μ) := by sorry\nvariable {X Y : Type*} [MetricSpace X] [MetricSpace Y]\nvariable {X₀ : Set X}\nvariable {g : X → Y}\nlemma inter_closure_preimage_ss_preimage_closure_of_forall_continuousAt\n (g_cont : ∀ x ∈ X₀, ContinuousAt g x) (s : Set Y) :\n X₀ ∩ (closure (g ⁻¹' s)) ⊆ g ⁻¹' (closure s) := by sorry"} -{"project_name": "CriticalLineTheorem", "name": "critical_line", "type": "theorem", "code": "import Mathlib\n\nopen Set\n/-- There are infinitely many zeros on the critical line of the zeta function.\nMentioned in https://en.wikipedia.org/wiki/Riemann_hypothesis#Zeros_on_the_critical_line -/\n\ntheorem critical_line : {s : ℂ | riemannZeta s = 0 ∧ s.re = 1 / 2}.Infinite := by sorry"} -{"project_name": "DeBruijnErdos", "name": "colorings_space_compact", "type": "lemma", "code": "import Mathlib\n\nopen Set Topology\n\nuniverse u\n\nvariable (k : ℕ) {V : Type u} (G : SimpleGraph V)\n/--\nLemma 1: The Space of Colorings is Compact.\nLet G=(V, E) be a simple graph and let C be a finite set of k colors.\nThe space `C^V` of all functions from V to C, endowed with the product topology,\nis a compact topological space.\n-/\n\nlemma colorings_space_compact : IsCompact (Set.univ : Set (V → Fin k)) := by sorry"} -{"project_name": "DeBruijnErdos", "name": "ValidFiniteColorings_def", "type": "lemma", "code": "import Mathlib\n\nopen Set Topology\n\nuniverse u\n\nvariable (k : ℕ) {V : Type u} (G : SimpleGraph V)\n/--\nLemma 1: The Space of Colorings is Compact.\nLet G=(V, E) be a simple graph and let C be a finite set of k colors.\nThe space `C^V` of all functions from V to C, endowed with the product topology,\nis a compact topological space.\n-/\n\nlemma colorings_space_compact : IsCompact (Set.univ : Set (V → Fin k)) := by sorry\n/-- For a given finite subset `F` of the vertex space of `G`,\n`ValidFiniteColorings G F` is the set of functions `V → Fin k`\nthat constitute a valid k-coloring of `F`. -/\n\ndef ValidFiniteColorings (F : Finset V) : Set (V → Fin k) :=\n { f | ∀ u ∈ F, ∀ v ∈ F, G.Adj u v → f u ≠ f v }\n\nlemma ValidFiniteColorings_def (F : Finset V) : ValidFiniteColorings k G F =\n { f | ∀ u ∈ F, ∀ v ∈ F, G.Adj u v → f u ≠ f v } := sorry"} -{"project_name": "DeBruijnErdos", "name": "valid_colorings_is_closed", "type": "lemma", "code": "import Mathlib\n\nopen Set Topology\n\nuniverse u\n\nvariable (k : ℕ) {V : Type u} (G : SimpleGraph V)\n/--\nLemma 1: The Space of Colorings is Compact.\nLet G=(V, E) be a simple graph and let C be a finite set of k colors.\nThe space `C^V` of all functions from V to C, endowed with the product topology,\nis a compact topological space.\n-/\n\nlemma colorings_space_compact : IsCompact (Set.univ : Set (V → Fin k)) := by sorry\n/-- For a given finite subset `F` of the vertex space of `G`,\n`ValidFiniteColorings G F` is the set of functions `V → Fin k`\nthat constitute a valid k-coloring of `F`. -/\n\ndef ValidFiniteColorings (F : Finset V) : Set (V → Fin k) :=\n { f | ∀ u ∈ F, ∀ v ∈ F, G.Adj u v → f u ≠ f v }\n\nlemma ValidFiniteColorings_def (F : Finset V) : ValidFiniteColorings k G F =\n { f | ∀ u ∈ F, ∀ v ∈ F, G.Adj u v → f u ≠ f v } := sorry\n/--\nLemma 2: Subspaces of Valid Colorings are Closed.\nFor any finite subset `F` of the vertex space of `G`,\nthe set of valid k-colorings for F is a closed set in the product topology.\n-/\n\nlemma valid_colorings_is_closed (F : Finset V) :\n IsClosed (ValidFiniteColorings k G F) := sorry"} -{"project_name": "DeBruijnErdos", "name": "finite_intersection_property", "type": "lemma", "code": "import Mathlib\n\nopen Set Topology\n\nuniverse u\n\nvariable (k : ℕ) {V : Type u} (G : SimpleGraph V)\n/--\nLemma 1: The Space of Colorings is Compact.\nLet G=(V, E) be a simple graph and let C be a finite set of k colors.\nThe space `C^V` of all functions from V to C, endowed with the product topology,\nis a compact topological space.\n-/\n\nlemma colorings_space_compact : IsCompact (Set.univ : Set (V → Fin k)) := by sorry\n/-- For a given finite subset `F` of the vertex space of `G`,\n`ValidFiniteColorings G F` is the set of functions `V → Fin k`\nthat constitute a valid k-coloring of `F`. -/\n\ndef ValidFiniteColorings (F : Finset V) : Set (V → Fin k) :=\n { f | ∀ u ∈ F, ∀ v ∈ F, G.Adj u v → f u ≠ f v }\n\nlemma ValidFiniteColorings_def (F : Finset V) : ValidFiniteColorings k G F =\n { f | ∀ u ∈ F, ∀ v ∈ F, G.Adj u v → f u ≠ f v } := sorry\n/--\nLemma 2: Subspaces of Valid Colorings are Closed.\nFor any finite subset `F` of the vertex space of `G`,\nthe set of valid k-colorings for F is a closed set in the product topology.\n-/\n\nlemma valid_colorings_is_closed (F : Finset V) :\n IsClosed (ValidFiniteColorings k G F) := sorry\n\nopen scoped Classical in\n/--\nLemma 3: The Finite Intersection Property.\nThe family of sets of valid colorings for finite subgraphs of G has the\nfinite intersection property.\nThat is, any finite collection of these sets has a non-empty intersection.\n(if every finite subgraph of G is k-colorable.)\n-/\n\nlemma finite_intersection_property (S : Finset (Finset V))\n (hF : ∀ F, (ValidFiniteColorings k G F).Nonempty) :\n (⋂ F ∈ S, ValidFiniteColorings k G F).Nonempty := sorry"} -{"project_name": "DeBruijnErdos", "name": "SimpleGraph.colorable_of_finitely_colorable", "type": "theorem", "code": "import Mathlib\n\nopen Set Topology Finset\n\nuniverse u\n\nvariable (k : ℕ) {V : Type u} (G : SimpleGraph V)\n/--\n**De Bruijn-Erdős Theorem (Graph Coloring)**.\nIf for a graph G, the chromatic number of every finite subgraph is\nat most a finite integer k, then the chromatic number of G is also at most k.\n-/\n\ntheorem SimpleGraph.colorable_of_finitely_colorable\n (hS : ∀ F, (ValidFiniteColorings k G F).Nonempty) :\n G.Colorable k := by sorry", "imported_file": "-- File: LiveLeanTriathlon.DeBruijnErdos.BackgroundLemmas\nopen Set Topology\nuniverse u\nvariable (k : ℕ) {V : Type u} (G : SimpleGraph V)\n/--\nLemma 1: The Space of Colorings is Compact.\nLet G=(V, E) be a simple graph and let C be a finite set of k colors.\nThe space `C^V` of all functions from V to C, endowed with the product topology,\nis a compact topological space.\n-/\nlemma colorings_space_compact : IsCompact (Set.univ : Set (V → Fin k)) := by sorry\n/-- For a given finite subset `F` of the vertex space of `G`,\n`ValidFiniteColorings G F` is the set of functions `V → Fin k`\nthat constitute a valid k-coloring of `F`. -/\ndef ValidFiniteColorings (F : Finset V) : Set (V → Fin k) :=\n { f | ∀ u ∈ F, ∀ v ∈ F, G.Adj u v → f u ≠ f v }\nlemma ValidFiniteColorings_def (F : Finset V) : ValidFiniteColorings k G F =\n { f | ∀ u ∈ F, ∀ v ∈ F, G.Adj u v → f u ≠ f v } := sorry\n/--\nLemma 2: Subspaces of Valid Colorings are Closed.\nFor any finite subset `F` of the vertex space of `G`,\nthe set of valid k-colorings for F is a closed set in the product topology.\n-/\nlemma valid_colorings_is_closed (F : Finset V) :\n IsClosed (ValidFiniteColorings k G F) := sorry\nopen scoped Classical in\n/--\nLemma 3: The Finite Intersection Property.\nThe family of sets of valid colorings for finite subgraphs of G has the\nfinite intersection property.\nThat is, any finite collection of these sets has a non-empty intersection.\n(if every finite subgraph of G is k-colorable.)\n-/\nlemma finite_intersection_property (S : Finset (Finset V))\n (hF : ∀ F, (ValidFiniteColorings k G F).Nonempty) :\n (⋂ F ∈ S, ValidFiniteColorings k G F).Nonempty := sorry"} -{"project_name": "DefinabilityNaturalsInRationals", "name": "nat_definable_in_rat", "type": "theorem", "code": "import Mathlib\n\nopen FirstOrder FirstOrder.Language FirstOrder.Ring\nnoncomputable section\n\ninstance : Language.ring.Structure ℚ := (compatibleRingOfRing ℚ).toStructure\n\ntheorem nat_definable_in_rat :\n (∅ : Set ℚ).Definable₁ Language.ring (Set.range (Nat.cast : ℕ → ℚ)) := by sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "volume_singleton_add", "type": "lemma", "code": "import Mathlib\n\nopen Real Set Pointwise MeasureTheory\n\nsection BackgroundLemmas\n\nlemma volume_singleton_add (a : ℝ) (s : Set ℝ) : volume ({a} + s) = volume s := by sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "volume_preimage_add_left", "type": "lemma", "code": "import Mathlib\n\nopen Real Set Pointwise MeasureTheory\n\nsection BackgroundLemmas\n\nlemma volume_singleton_add (a : ℝ) (s : Set ℝ) : volume ({a} + s) = volume s := by sorry\n\nlemma volume_preimage_add_left (a : ℝ) (s : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s) = volume s := sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "volume_preimage_add_left_inter", "type": "lemma", "code": "import Mathlib\n\nopen Real Set Pointwise MeasureTheory\n\nsection BackgroundLemmas\n\nlemma volume_singleton_add (a : ℝ) (s : Set ℝ) : volume ({a} + s) = volume s := by sorry\n\nlemma volume_preimage_add_left (a : ℝ) (s : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s) = volume s := sorry\n@[simp]\n\nlemma volume_preimage_add_left_inter (a : ℝ) (s t : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s ∩ (fun x ↦ a + x) ⁻¹' t) = volume (s ∩ t) := by sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "open_cover_approx_of_measurable", "type": "lemma", "code": "import Mathlib\n\nopen Real Set Pointwise MeasureTheory\n\nsection BackgroundLemmas\n\nlemma volume_singleton_add (a : ℝ) (s : Set ℝ) : volume ({a} + s) = volume s := by sorry\n\nlemma volume_preimage_add_left (a : ℝ) (s : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s) = volume s := sorry\n@[simp]\n\nlemma volume_preimage_add_left_inter (a : ℝ) (s t : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s ∩ (fun x ↦ a + x) ⁻¹' t) = volume (s ∩ t) := by sorry\n/--\nAny set of reals with positive, finite measure is contained in an open set with finite measure\nwhose measure is arbitrarily close to that of the original set.\n-/\n\nlemma open_cover_approx_of_measurable {A : Set ℝ}\n (A_pos : 0 < volume A) (A_fin : volume A < ⊤) {r : ENNReal} (r_lt_one : r < 1) :\n ∃ U, IsOpen U ∧ A ⊆ U ∧ volume U < ⊤ ∧ r * volume U < volume A := by sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "IsOpen.countable_connectedComponentsIn", "type": "lemma", "code": "import Mathlib\n\nopen Real Set Pointwise MeasureTheory\n\nsection BackgroundLemmas\n\nlemma volume_singleton_add (a : ℝ) (s : Set ℝ) : volume ({a} + s) = volume s := by sorry\n\nlemma volume_preimage_add_left (a : ℝ) (s : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s) = volume s := sorry\n@[simp]\n\nlemma volume_preimage_add_left_inter (a : ℝ) (s t : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s ∩ (fun x ↦ a + x) ⁻¹' t) = volume (s ∩ t) := by sorry\n/--\nAny set of reals with positive, finite measure is contained in an open set with finite measure\nwhose measure is arbitrarily close to that of the original set.\n-/\n\nlemma open_cover_approx_of_measurable {A : Set ℝ}\n (A_pos : 0 < volume A) (A_fin : volume A < ⊤) {r : ENNReal} (r_lt_one : r < 1) :\n ∃ U, IsOpen U ∧ A ⊆ U ∧ volume U < ⊤ ∧ r * volume U < volume A := by sorry\n\nlemma IsOpen.countable_connectedComponentsIn {α : Type*}\n [TopologicalSpace α] [LocallyConnectedSpace α] [TopologicalSpace.SeparableSpace α]\n {s : Set α} (s_open : IsOpen s) :\n Countable (connectedComponentsIn s) := by sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "exists_connected_measure_inter_gt_mul_measure", "type": "lemma", "code": "import Mathlib\n\nopen Real Set Pointwise MeasureTheory\n\nsection BackgroundLemmas\n\nlemma volume_singleton_add (a : ℝ) (s : Set ℝ) : volume ({a} + s) = volume s := by sorry\n\nlemma volume_preimage_add_left (a : ℝ) (s : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s) = volume s := sorry\n@[simp]\n\nlemma volume_preimage_add_left_inter (a : ℝ) (s t : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s ∩ (fun x ↦ a + x) ⁻¹' t) = volume (s ∩ t) := by sorry\n/--\nAny set of reals with positive, finite measure is contained in an open set with finite measure\nwhose measure is arbitrarily close to that of the original set.\n-/\n\nlemma open_cover_approx_of_measurable {A : Set ℝ}\n (A_pos : 0 < volume A) (A_fin : volume A < ⊤) {r : ENNReal} (r_lt_one : r < 1) :\n ∃ U, IsOpen U ∧ A ⊆ U ∧ volume U < ⊤ ∧ r * volume U < volume A := by sorry\n\nlemma IsOpen.countable_connectedComponentsIn {α : Type*}\n [TopologicalSpace α] [LocallyConnectedSpace α] [TopologicalSpace.SeparableSpace α]\n {s : Set α} (s_open : IsOpen s) :\n Countable (connectedComponentsIn s) := by sorry\n\nlemma exists_connected_measure_inter_gt_mul_measure {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior J).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "exists_interval_high_overlap", "type": "lemma", "code": "import Mathlib\n\nopen Real Set Pointwise MeasureTheory\n\nsection BackgroundLemmas\n\nlemma volume_singleton_add (a : ℝ) (s : Set ℝ) : volume ({a} + s) = volume s := by sorry\n\nlemma volume_preimage_add_left (a : ℝ) (s : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s) = volume s := sorry\n@[simp]\n\nlemma volume_preimage_add_left_inter (a : ℝ) (s t : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s ∩ (fun x ↦ a + x) ⁻¹' t) = volume (s ∩ t) := by sorry\n/--\nAny set of reals with positive, finite measure is contained in an open set with finite measure\nwhose measure is arbitrarily close to that of the original set.\n-/\n\nlemma open_cover_approx_of_measurable {A : Set ℝ}\n (A_pos : 0 < volume A) (A_fin : volume A < ⊤) {r : ENNReal} (r_lt_one : r < 1) :\n ∃ U, IsOpen U ∧ A ⊆ U ∧ volume U < ⊤ ∧ r * volume U < volume A := by sorry\n\nlemma IsOpen.countable_connectedComponentsIn {α : Type*}\n [TopologicalSpace α] [LocallyConnectedSpace α] [TopologicalSpace.SeparableSpace α]\n {s : Set α} (s_open : IsOpen s) :\n Countable (connectedComponentsIn s) := by sorry\n\nlemma exists_connected_measure_inter_gt_mul_measure {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior J).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry\n\nend BackgroundLemmas\n\nsection MainTheorem\n/-- Given a measurable set A with positive measure and 0 < r < 1, there exists a measurable subset A'\nwith finite positive measure and real bounds a < b such that Icc a b ∩ A' has measure > r * (b - a). -/\n\nlemma exists_interval_high_overlap {A : Set ℝ} (A_mble : MeasurableSet A) (A_pos : 0 < volume A)\n {r : ENNReal} (hr_pos : 0 < r) (hr : r < 1) :\n ∃ (A' : Set ℝ) (a b : ℝ),\n MeasurableSet A' ∧ A' ⊆ A ∧ 0 < volume A' ∧ volume A' < ⊤ ∧\n a < b ∧ volume (Icc a b ∩ A') > r * ENNReal.ofReal (b - a) := by sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "exists_Ioo_subset_diff_self_of_measure_pos", "type": "theorem", "code": "import Mathlib\n\nopen Real Set Pointwise MeasureTheory\n\nsection BackgroundLemmas\n\nlemma volume_singleton_add (a : ℝ) (s : Set ℝ) : volume ({a} + s) = volume s := by sorry\n\nlemma volume_preimage_add_left (a : ℝ) (s : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s) = volume s := sorry\n@[simp]\n\nlemma volume_preimage_add_left_inter (a : ℝ) (s t : Set ℝ) :\n volume ((fun x ↦ a + x) ⁻¹' s ∩ (fun x ↦ a + x) ⁻¹' t) = volume (s ∩ t) := by sorry\n/--\nAny set of reals with positive, finite measure is contained in an open set with finite measure\nwhose measure is arbitrarily close to that of the original set.\n-/\n\nlemma open_cover_approx_of_measurable {A : Set ℝ}\n (A_pos : 0 < volume A) (A_fin : volume A < ⊤) {r : ENNReal} (r_lt_one : r < 1) :\n ∃ U, IsOpen U ∧ A ⊆ U ∧ volume U < ⊤ ∧ r * volume U < volume A := by sorry\n\nlemma IsOpen.countable_connectedComponentsIn {α : Type*}\n [TopologicalSpace α] [LocallyConnectedSpace α] [TopologicalSpace.SeparableSpace α]\n {s : Set α} (s_open : IsOpen s) :\n Countable (connectedComponentsIn s) := by sorry\n\nlemma exists_connected_measure_inter_gt_mul_measure {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior J).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry\n\nend BackgroundLemmas\n\nsection MainTheorem\n/-- Given a measurable set A with positive measure and 0 < r < 1, there exists a measurable subset A'\nwith finite positive measure and real bounds a < b such that Icc a b ∩ A' has measure > r * (b - a). -/\n\nlemma exists_interval_high_overlap {A : Set ℝ} (A_mble : MeasurableSet A) (A_pos : 0 < volume A)\n {r : ENNReal} (hr_pos : 0 < r) (hr : r < 1) :\n ∃ (A' : Set ℝ) (a b : ℝ),\n MeasurableSet A' ∧ A' ⊆ A ∧ 0 < volume A' ∧ volume A' < ⊤ ∧\n a < b ∧ volume (Icc a b ∩ A') > r * ENNReal.ofReal (b - a) := by sorry\n\ntheorem exists_Ioo_subset_diff_self_of_measure_pos {A : Set ℝ}\n (A_mble : MeasurableSet A) (A_pos : 0 < volume A) :\n ∃ δ > 0, Ioo (-δ) δ ⊆ A - A := by sorry"} -{"project_name": "DillerDressTheorem", "name": "diller_dress", "type": "theorem", "code": "import Mathlib\n\nuniverse u\n/-- A (semi)ring is Pythagorean if every sum of two squares is itself a square. -/\n\nclass Pythagorean (R : Type u) [Semiring R] : Prop where\n sum_sq : ∀ a b : R, IsSquare (a ^ 2 + b ^ 2)\n\ntheorem diller_dress (K L : Type*) [Field K] [Field L] [Algebra K L] [Module.Finite K L]\n [Pythagorean L] : Pythagorean K := by sorry"} -{"project_name": "Dilworth", "name": "set_apply", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry"} -{"project_name": "Dilworth", "name": "card_le_of_disjoint_each_at_most_one", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry"} -{"project_name": "Dilworth", "name": "IsChainPartition_insert", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry"} -{"project_name": "Dilworth", "name": "inter_card", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry"} -{"project_name": "Dilworth", "name": "inter_unique", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry"} -{"project_name": "Dilworth", "name": "inter_unique'", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry"} -{"project_name": "Dilworth", "name": "unique_antichain_element_mem_antichain", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry"} -{"project_name": "Dilworth", "name": "unique_antichain_element_mem_chain", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry"} -{"project_name": "Dilworth", "name": "unique_antichain_element_unique", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry"} -{"project_name": "Dilworth", "name": "subset_of_mem_fullAntichains", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry"} -{"project_name": "Dilworth", "name": "antichain_of_mem_fullAntichains", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry"} -{"project_name": "Dilworth", "name": "card_of_mem_fullAntichains", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\n\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry"} -{"project_name": "Dilworth", "name": "fullWidth_of_fullAntichains", "type": "theorem", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\n\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry\n\nvariable [Fintype P]\n\nopen scoped Classical in\n/--\nGiven a chain partition, the maximal antichain is the set\n(which we will later see is an antichain)\nformed by taking from each chain,\nan element that is maximal among elements of the chain that belong to some k-element antichain in S, where k is the number of chains in the partition.\n-/\n@[simp]\nnoncomputable def fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (h_is_chain_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S)) : Finset P :=\n if\n ne : fullAntichains C S = ∅\n then ∅\n else\n {x | ∃ c, ∃ hcC : c ∈ C, x = Classical.choose\n (p := Maximal (fun y => y ∈ ({x | x ∈ c ∧ ∃ Ai ∈ fullAntichains C S, x ∈ Ai}.toFinset)))\n (by\n apply Finset.exists_maximal\n push Not at ne\n obtain ⟨A, hA⟩ := ne\n use unique_antichain_element h_is_chain_partition rfl A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.2.2 c (hcC)\n simp only [Set.toFinset_setOf, mem_filter, mem_univ, true_and]\n rw [and_comm]\n constructor\n .\n use A, by simp [hA]\n exact\n unique_antichain_element_mem_antichain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC\n .\n exact\n unique_antichain_element_mem_chain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC ) }.toFinset\n\ntheorem fullWidth_of_fullAntichains {P : Type u} [inst : PartialOrder P]\n (C : Finset (Set P)) (S : Finset P) (hC : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (h : (fullAntichains C S).Nonempty) : #C = width S := by sorry"} -{"project_name": "Dilworth", "name": "card_fullChainMaximizers_spec", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\n\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry\n\nvariable [Fintype P]\n\nopen scoped Classical in\n/--\nGiven a chain partition, the maximal antichain is the set\n(which we will later see is an antichain)\nformed by taking from each chain,\nan element that is maximal among elements of the chain that belong to some k-element antichain in S, where k is the number of chains in the partition.\n-/\n@[simp]\nnoncomputable def fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (h_is_chain_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S)) : Finset P :=\n if\n ne : fullAntichains C S = ∅\n then ∅\n else\n {x | ∃ c, ∃ hcC : c ∈ C, x = Classical.choose\n (p := Maximal (fun y => y ∈ ({x | x ∈ c ∧ ∃ Ai ∈ fullAntichains C S, x ∈ Ai}.toFinset)))\n (by\n apply Finset.exists_maximal\n push Not at ne\n obtain ⟨A, hA⟩ := ne\n use unique_antichain_element h_is_chain_partition rfl A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.2.2 c (hcC)\n simp only [Set.toFinset_setOf, mem_filter, mem_univ, true_and]\n rw [and_comm]\n constructor\n .\n use A, by simp [hA]\n exact\n unique_antichain_element_mem_antichain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC\n .\n exact\n unique_antichain_element_mem_chain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC ) }.toFinset\n\ntheorem fullWidth_of_fullAntichains {P : Type u} [inst : PartialOrder P]\n (C : Finset (Set P)) (S : Finset P) (hC : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (h : (fullAntichains C S).Nonempty) : #C = width S := by sorry\n/--\nA member of the fullChainMaximizers is indeed maximal in the sense of the definition.\n-/\n\nlemma card_fullChainMaximizers_spec (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)) (a')\n (ha'_mem : a' ∈ (fullChainMaximizers C S hC_part)) :\n ∃ c ∈ (SetLike.coe C), Maximal {x | x ∈ c ∧ ∃ Ai : Finset P,\n (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry"} -{"project_name": "Dilworth", "name": "isAntichain_fullChainMaximizers", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\n\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry\n\nvariable [Fintype P]\n\nopen scoped Classical in\n/--\nGiven a chain partition, the maximal antichain is the set\n(which we will later see is an antichain)\nformed by taking from each chain,\nan element that is maximal among elements of the chain that belong to some k-element antichain in S, where k is the number of chains in the partition.\n-/\n@[simp]\nnoncomputable def fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (h_is_chain_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S)) : Finset P :=\n if\n ne : fullAntichains C S = ∅\n then ∅\n else\n {x | ∃ c, ∃ hcC : c ∈ C, x = Classical.choose\n (p := Maximal (fun y => y ∈ ({x | x ∈ c ∧ ∃ Ai ∈ fullAntichains C S, x ∈ Ai}.toFinset)))\n (by\n apply Finset.exists_maximal\n push Not at ne\n obtain ⟨A, hA⟩ := ne\n use unique_antichain_element h_is_chain_partition rfl A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.2.2 c (hcC)\n simp only [Set.toFinset_setOf, mem_filter, mem_univ, true_and]\n rw [and_comm]\n constructor\n .\n use A, by simp [hA]\n exact\n unique_antichain_element_mem_antichain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC\n .\n exact\n unique_antichain_element_mem_chain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC ) }.toFinset\n\ntheorem fullWidth_of_fullAntichains {P : Type u} [inst : PartialOrder P]\n (C : Finset (Set P)) (S : Finset P) (hC : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (h : (fullAntichains C S).Nonempty) : #C = width S := by sorry\n/--\nA member of the fullChainMaximizers is indeed maximal in the sense of the definition.\n-/\n\nlemma card_fullChainMaximizers_spec (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)) (a')\n (ha'_mem : a' ∈ (fullChainMaximizers C S hC_part)) :\n ∃ c ∈ (SetLike.coe C), Maximal {x | x ∈ c ∧ ∃ Ai : Finset P,\n (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\n\nlemma isAntichain_fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)):\n IsAntichain (· ≤ ·) (SetLike.coe <| fullChainMaximizers C S hC_part) := by sorry"} -{"project_name": "Dilworth", "name": "fullChainMaximizers_subset", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\n\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry\n\nvariable [Fintype P]\n\nopen scoped Classical in\n/--\nGiven a chain partition, the maximal antichain is the set\n(which we will later see is an antichain)\nformed by taking from each chain,\nan element that is maximal among elements of the chain that belong to some k-element antichain in S, where k is the number of chains in the partition.\n-/\n@[simp]\nnoncomputable def fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (h_is_chain_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S)) : Finset P :=\n if\n ne : fullAntichains C S = ∅\n then ∅\n else\n {x | ∃ c, ∃ hcC : c ∈ C, x = Classical.choose\n (p := Maximal (fun y => y ∈ ({x | x ∈ c ∧ ∃ Ai ∈ fullAntichains C S, x ∈ Ai}.toFinset)))\n (by\n apply Finset.exists_maximal\n push Not at ne\n obtain ⟨A, hA⟩ := ne\n use unique_antichain_element h_is_chain_partition rfl A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.2.2 c (hcC)\n simp only [Set.toFinset_setOf, mem_filter, mem_univ, true_and]\n rw [and_comm]\n constructor\n .\n use A, by simp [hA]\n exact\n unique_antichain_element_mem_antichain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC\n .\n exact\n unique_antichain_element_mem_chain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC ) }.toFinset\n\ntheorem fullWidth_of_fullAntichains {P : Type u} [inst : PartialOrder P]\n (C : Finset (Set P)) (S : Finset P) (hC : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (h : (fullAntichains C S).Nonempty) : #C = width S := by sorry\n/--\nA member of the fullChainMaximizers is indeed maximal in the sense of the definition.\n-/\n\nlemma card_fullChainMaximizers_spec (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)) (a')\n (ha'_mem : a' ∈ (fullChainMaximizers C S hC_part)) :\n ∃ c ∈ (SetLike.coe C), Maximal {x | x ∈ c ∧ ∃ Ai : Finset P,\n (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\n\nlemma isAntichain_fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)):\n IsAntichain (· ≤ ·) (SetLike.coe <| fullChainMaximizers C S hC_part) := by sorry\n\nlemma fullChainMaximizers_subset (C : Finset (Set P)) (S : Finset P)\n (h' : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n (fullChainMaximizers C S h') ⊆ S := sorry"} -{"project_name": "Dilworth", "name": "card_fullChainMaximizers_eq", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\n\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry\n\nvariable [Fintype P]\n\nopen scoped Classical in\n/--\nGiven a chain partition, the maximal antichain is the set\n(which we will later see is an antichain)\nformed by taking from each chain,\nan element that is maximal among elements of the chain that belong to some k-element antichain in S, where k is the number of chains in the partition.\n-/\n@[simp]\nnoncomputable def fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (h_is_chain_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S)) : Finset P :=\n if\n ne : fullAntichains C S = ∅\n then ∅\n else\n {x | ∃ c, ∃ hcC : c ∈ C, x = Classical.choose\n (p := Maximal (fun y => y ∈ ({x | x ∈ c ∧ ∃ Ai ∈ fullAntichains C S, x ∈ Ai}.toFinset)))\n (by\n apply Finset.exists_maximal\n push Not at ne\n obtain ⟨A, hA⟩ := ne\n use unique_antichain_element h_is_chain_partition rfl A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.2.2 c (hcC)\n simp only [Set.toFinset_setOf, mem_filter, mem_univ, true_and]\n rw [and_comm]\n constructor\n .\n use A, by simp [hA]\n exact\n unique_antichain_element_mem_antichain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC\n .\n exact\n unique_antichain_element_mem_chain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC ) }.toFinset\n\ntheorem fullWidth_of_fullAntichains {P : Type u} [inst : PartialOrder P]\n (C : Finset (Set P)) (S : Finset P) (hC : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (h : (fullAntichains C S).Nonempty) : #C = width S := by sorry\n/--\nA member of the fullChainMaximizers is indeed maximal in the sense of the definition.\n-/\n\nlemma card_fullChainMaximizers_spec (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)) (a')\n (ha'_mem : a' ∈ (fullChainMaximizers C S hC_part)) :\n ∃ c ∈ (SetLike.coe C), Maximal {x | x ∈ c ∧ ∃ Ai : Finset P,\n (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\n\nlemma isAntichain_fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)):\n IsAntichain (· ≤ ·) (SetLike.coe <| fullChainMaximizers C S hC_part) := by sorry\n\nlemma fullChainMaximizers_subset (C : Finset (Set P)) (S : Finset P)\n (h' : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n (fullChainMaximizers C S h') ⊆ S := sorry\n\nlemma card_fullChainMaximizers_eq (C : Finset (Set P)) (S : Finset P)\n (h : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (hA : ∃ A : Finset _, IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card) :\n (fullChainMaximizers C S h).card = C.card := by sorry"} -{"project_name": "Dilworth", "name": "card_fullChainMaximizers_spec'", "type": "lemma", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\n\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry\n\nvariable [Fintype P]\n\nopen scoped Classical in\n/--\nGiven a chain partition, the maximal antichain is the set\n(which we will later see is an antichain)\nformed by taking from each chain,\nan element that is maximal among elements of the chain that belong to some k-element antichain in S, where k is the number of chains in the partition.\n-/\n@[simp]\nnoncomputable def fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (h_is_chain_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S)) : Finset P :=\n if\n ne : fullAntichains C S = ∅\n then ∅\n else\n {x | ∃ c, ∃ hcC : c ∈ C, x = Classical.choose\n (p := Maximal (fun y => y ∈ ({x | x ∈ c ∧ ∃ Ai ∈ fullAntichains C S, x ∈ Ai}.toFinset)))\n (by\n apply Finset.exists_maximal\n push Not at ne\n obtain ⟨A, hA⟩ := ne\n use unique_antichain_element h_is_chain_partition rfl A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.2.2 c (hcC)\n simp only [Set.toFinset_setOf, mem_filter, mem_univ, true_and]\n rw [and_comm]\n constructor\n .\n use A, by simp [hA]\n exact\n unique_antichain_element_mem_antichain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC\n .\n exact\n unique_antichain_element_mem_chain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC ) }.toFinset\n\ntheorem fullWidth_of_fullAntichains {P : Type u} [inst : PartialOrder P]\n (C : Finset (Set P)) (S : Finset P) (hC : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (h : (fullAntichains C S).Nonempty) : #C = width S := by sorry\n/--\nA member of the fullChainMaximizers is indeed maximal in the sense of the definition.\n-/\n\nlemma card_fullChainMaximizers_spec (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)) (a')\n (ha'_mem : a' ∈ (fullChainMaximizers C S hC_part)) :\n ∃ c ∈ (SetLike.coe C), Maximal {x | x ∈ c ∧ ∃ Ai : Finset P,\n (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\n\nlemma isAntichain_fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)):\n IsAntichain (· ≤ ·) (SetLike.coe <| fullChainMaximizers C S hC_part) := by sorry\n\nlemma fullChainMaximizers_subset (C : Finset (Set P)) (S : Finset P)\n (h' : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n (fullChainMaximizers C S h') ⊆ S := sorry\n\nlemma card_fullChainMaximizers_eq (C : Finset (Set P)) (S : Finset P)\n (h : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (hA : ∃ A : Finset _, IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card) :\n (fullChainMaximizers C S h).card = C.card := by sorry\n\nlemma card_fullChainMaximizers_spec' (C : Finset (Set P)) (S : Finset P)\n (h : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n ∀ a' ∈ (fullChainMaximizers C S h), ∃ c ∈ (SetLike.coe C),\n IsGreatest {x | x ∈ c ∧ ∃ Ai : Finset P, (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry"} -{"project_name": "Dilworth", "name": "dilworth_induction_equal_width", "type": "theorem", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\n\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry\n\nvariable [Fintype P]\n\nopen scoped Classical in\n/--\nGiven a chain partition, the maximal antichain is the set\n(which we will later see is an antichain)\nformed by taking from each chain,\nan element that is maximal among elements of the chain that belong to some k-element antichain in S, where k is the number of chains in the partition.\n-/\n@[simp]\nnoncomputable def fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (h_is_chain_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S)) : Finset P :=\n if\n ne : fullAntichains C S = ∅\n then ∅\n else\n {x | ∃ c, ∃ hcC : c ∈ C, x = Classical.choose\n (p := Maximal (fun y => y ∈ ({x | x ∈ c ∧ ∃ Ai ∈ fullAntichains C S, x ∈ Ai}.toFinset)))\n (by\n apply Finset.exists_maximal\n push Not at ne\n obtain ⟨A, hA⟩ := ne\n use unique_antichain_element h_is_chain_partition rfl A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.2.2 c (hcC)\n simp only [Set.toFinset_setOf, mem_filter, mem_univ, true_and]\n rw [and_comm]\n constructor\n .\n use A, by simp [hA]\n exact\n unique_antichain_element_mem_antichain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC\n .\n exact\n unique_antichain_element_mem_chain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC ) }.toFinset\n\ntheorem fullWidth_of_fullAntichains {P : Type u} [inst : PartialOrder P]\n (C : Finset (Set P)) (S : Finset P) (hC : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (h : (fullAntichains C S).Nonempty) : #C = width S := by sorry\n/--\nA member of the fullChainMaximizers is indeed maximal in the sense of the definition.\n-/\n\nlemma card_fullChainMaximizers_spec (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)) (a')\n (ha'_mem : a' ∈ (fullChainMaximizers C S hC_part)) :\n ∃ c ∈ (SetLike.coe C), Maximal {x | x ∈ c ∧ ∃ Ai : Finset P,\n (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\n\nlemma isAntichain_fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)):\n IsAntichain (· ≤ ·) (SetLike.coe <| fullChainMaximizers C S hC_part) := by sorry\n\nlemma fullChainMaximizers_subset (C : Finset (Set P)) (S : Finset P)\n (h' : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n (fullChainMaximizers C S h') ⊆ S := sorry\n\nlemma card_fullChainMaximizers_eq (C : Finset (Set P)) (S : Finset P)\n (h : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (hA : ∃ A : Finset _, IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card) :\n (fullChainMaximizers C S h).card = C.card := by sorry\n\nlemma card_fullChainMaximizers_spec' (C : Finset (Set P)) (S : Finset P)\n (h : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n ∀ a' ∈ (fullChainMaximizers C S h), ∃ c ∈ (SetLike.coe C),\n IsGreatest {x | x ∈ c ∧ ∃ Ai : Finset P, (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\n\nopen scoped Classical in\n\ntheorem dilworth_induction_equal_width (S : Finset P)\n (ih : ∀ t ⊂ S, IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe t) ∧\n #C = k} (width t)) (a : P) (ha_in_S : a ∈ S) (ha_max : ∀ ⦃y : P⦄,\n (fun x ↦ x ∈ S) y → a ≤ y → y ≤ a) (ih_a : IsLeast {k | ∃ C : Finset (Set P),\n IsChainPartition C (SetLike.coe <| S.erase a) ∧ #C = k} (width (S.erase a)))\n (h_case1 : width S = width (S.erase a)):\n IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe S) ∧ #C = k} (width S) := by sorry"} -{"project_name": "Dilworth", "name": "dilworth_induction_greater_width", "type": "theorem", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\n\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\n\nnamespace PartialOrder\n\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\n\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\n\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\n\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\n\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\n\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\n\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\n\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\n\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\n\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\n\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\n\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry\n\nvariable [Fintype P]\n\nopen scoped Classical in\n/--\nGiven a chain partition, the maximal antichain is the set\n(which we will later see is an antichain)\nformed by taking from each chain,\nan element that is maximal among elements of the chain that belong to some k-element antichain in S, where k is the number of chains in the partition.\n-/\n@[simp]\nnoncomputable def fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (h_is_chain_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S)) : Finset P :=\n if\n ne : fullAntichains C S = ∅\n then ∅\n else\n {x | ∃ c, ∃ hcC : c ∈ C, x = Classical.choose\n (p := Maximal (fun y => y ∈ ({x | x ∈ c ∧ ∃ Ai ∈ fullAntichains C S, x ∈ Ai}.toFinset)))\n (by\n apply Finset.exists_maximal\n push Not at ne\n obtain ⟨A, hA⟩ := ne\n use unique_antichain_element h_is_chain_partition rfl A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.2.2 c (hcC)\n simp only [Set.toFinset_setOf, mem_filter, mem_univ, true_and]\n rw [and_comm]\n constructor\n .\n use A, by simp [hA]\n exact\n unique_antichain_element_mem_antichain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC\n .\n exact\n unique_antichain_element_mem_chain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC ) }.toFinset\n\ntheorem fullWidth_of_fullAntichains {P : Type u} [inst : PartialOrder P]\n (C : Finset (Set P)) (S : Finset P) (hC : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (h : (fullAntichains C S).Nonempty) : #C = width S := by sorry\n/--\nA member of the fullChainMaximizers is indeed maximal in the sense of the definition.\n-/\n\nlemma card_fullChainMaximizers_spec (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)) (a')\n (ha'_mem : a' ∈ (fullChainMaximizers C S hC_part)) :\n ∃ c ∈ (SetLike.coe C), Maximal {x | x ∈ c ∧ ∃ Ai : Finset P,\n (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\n\nlemma isAntichain_fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)):\n IsAntichain (· ≤ ·) (SetLike.coe <| fullChainMaximizers C S hC_part) := by sorry\n\nlemma fullChainMaximizers_subset (C : Finset (Set P)) (S : Finset P)\n (h' : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n (fullChainMaximizers C S h') ⊆ S := sorry\n\nlemma card_fullChainMaximizers_eq (C : Finset (Set P)) (S : Finset P)\n (h : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (hA : ∃ A : Finset _, IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card) :\n (fullChainMaximizers C S h).card = C.card := by sorry\n\nlemma card_fullChainMaximizers_spec' (C : Finset (Set P)) (S : Finset P)\n (h : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n ∀ a' ∈ (fullChainMaximizers C S h), ∃ c ∈ (SetLike.coe C),\n IsGreatest {x | x ∈ c ∧ ∃ Ai : Finset P, (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\n\nopen scoped Classical in\n\ntheorem dilworth_induction_equal_width (S : Finset P)\n (ih : ∀ t ⊂ S, IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe t) ∧\n #C = k} (width t)) (a : P) (ha_in_S : a ∈ S) (ha_max : ∀ ⦃y : P⦄,\n (fun x ↦ x ∈ S) y → a ≤ y → y ≤ a) (ih_a : IsLeast {k | ∃ C : Finset (Set P),\n IsChainPartition C (SetLike.coe <| S.erase a) ∧ #C = k} (width (S.erase a)))\n (h_case1 : width S = width (S.erase a)):\n IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe S) ∧ #C = k} (width S) := by sorry\n\nopen scoped Classical in\nomit [Fintype P] in\n\ntheorem dilworth_induction_greater_width (S : Finset P) (a : P) (ha_in_S : a ∈ S)\n (ih_a : IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe <| S.erase a)\n ∧ #C = k} (width (S.erase a))) (h_case_2 : width S = width (S.erase a) + 1) :\n IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe S) ∧ #C = k} (width S) := by sorry"} -{"project_name": "Dilworth", "name": "dilworth", "type": "theorem", "code": "import Mathlib\n\nopen Finset Nat\n\nuniverse u\n\nvariable {P : Type u}\n\nnamespace PartialOrder\n\nvariable [PartialOrder P] [Fintype P]\n/--\nDilworth's theorem:\nIn any finite partially ordered set $P$,\nthe minimum number of chains in a chain partition is equal to the maximum size of an antichain.\n-/\n\ntheorem dilworth (S : Finset P) :\n IsLeast {k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧\n C.card = k} (width S) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Dilworth.BackgroundLemmas\nopen Finset Nat\nuniverse u\nvariable {P : Type u}\nlemma set_apply {α : Type*} {p : α → Prop} {x : α} :\n ({a | p a} : Set _) x = p x := by sorry\n/-- If each element of A belongs to exactly one element of C, and each element of C\ncontains at most one element of A, then |A| ≤ |C|. -/\nlemma card_le_of_disjoint_each_at_most_one {α : Type*}\n (A : Finset α) (C : Finset (Set α)) (ha1 : ∀ a ∈ A, ∃! c ∈ C, a ∈ c)\n (hc : ∀ c ∈ C, ∀ a₁ a₂ : α, a₁ ∈ A → a₂ ∈ A → a₁ ∈ c → a₂ ∈ c → a₁ = a₂) :\n A.card ≤ C.card := by sorry\nnamespace PartialOrder\nvariable [PartialOrder P]\n/-- A chain partition of a set `S` is a set of nonempty sets, where each inner\nset is a chain, they are pairwise disjoint, and their union is `S`. -/\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, c ≠ ∅)\n ∧\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nIf a new nonempty set, disjoint from all existing chains, is added to a chain partition, the result is still a chain partition, for the union of the new set with the original set.\n-/\nlemma IsChainPartition_insert (C : Set (Set P)) (c : Set P) (S : Set P) (hCS : IsChainPartition C S)\n (hc_chain : IsChain (· ≤ ·) c) (hc_disjoint : ∀ c' ∈ C, Disjoint c c') (hc_nonempty : c ≠ ∅) :\n IsChainPartition (insert c C) (S ∪ c) := by sorry\nlemma inter_card {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) S')\n {A' : Finset P} (hA'_anti : IsAntichain (fun x1 x2 ↦ x1 ≤ x2) <| SetLike.coe A')\n (c : Set P) (hc : c ∈ C) (a₁ a₂ : P) (h1 : a₁ ∈ A') (h2 : a₂ ∈ A') (h3 : a₁ ∈ c) (h4 : a₂ ∈ c) :\n a₁ = a₂ := by sorry\nlemma inter_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (hC_card : C.card = k) (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := by sorry\nlemma inter_unique' {S' : Finset P} {C : Finset (Set P)} (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S'))\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = C.card ) (c : Set P) (hc : c ∈ C) :\n ∃! a' ∈ A', a' ∈ c := sorry\n/--\nGiven a chain partition and an antichain of the same size, this function returns\nthe unique element of the antichain that belongs to a given chain.\n-/\nnoncomputable def unique_antichain_element {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) : P :=\n (inter_unique hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc).choose\n/--\nThe unique antichain element is indeed in the antichain.\n-/\nlemma unique_antichain_element_mem_antichain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ A' := sorry\n/--\nThe unique antichain element is indeed in the chain.\n-/\nlemma unique_antichain_element_mem_chain {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) :\n unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc ∈ c := sorry\n/--\nThe unique antichain element is indeed unique with the required property.\n-/\nlemma unique_antichain_element_unique {S' : Finset P} {C : Finset (Set P)} {k : ℕ}\n (hC_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S')) (hC_card : C.card = k)\n (A' : Finset P) (hA'_sub : A' ⊆ S') (hA'_anti : IsAntichain (· ≤ ·) (SetLike.coe A'))\n (hA'_card : A'.card = k) (c : Set P) (hc : c ∈ C) (y : P) (hy1 : y ∈ A') (hy2 : y ∈ c) :\n y = unique_antichain_element hC_partition hC_card A' hA'_sub hA'_anti hA'_card c hc := sorry\n/--\nThe set of all antichains of size equal to the number of chains in a given chain partition C, contained in a set S.\n-/\ndef fullAntichains (C : Finset (Set P)) (S : Finset P) : Set (Finset P) :=\n { A | IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card }\nlemma subset_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A ⊆ S := sorry\nlemma antichain_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : IsAntichain (· ≤ ·) (SetLike.coe A) := sorry\nlemma card_of_mem_fullAntichains {C : Finset (Set P)} {S : Finset P} {A : Finset P}\n (hA : A ∈ fullAntichains C S) : A.card = C.card := sorry\nvariable [Fintype P]\nopen scoped Classical in\n/--\nGiven a chain partition, the maximal antichain is the set\n(which we will later see is an antichain)\nformed by taking from each chain,\nan element that is maximal among elements of the chain that belong to some k-element antichain in S, where k is the number of chains in the partition.\n-/\n@[simp]\nnoncomputable def fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (h_is_chain_partition : IsChainPartition (SetLike.coe C) (SetLike.coe S)) : Finset P :=\n if\n ne : fullAntichains C S = ∅\n then ∅\n else\n {x | ∃ c, ∃ hcC : c ∈ C, x = Classical.choose\n (p := Maximal (fun y => y ∈ ({x | x ∈ c ∧ ∃ Ai ∈ fullAntichains C S, x ∈ Ai}.toFinset)))\n (by\n apply Finset.exists_maximal\n push Not at ne\n obtain ⟨A, hA⟩ := ne\n use unique_antichain_element h_is_chain_partition rfl A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.2.2 c (hcC)\n simp only [Set.toFinset_setOf, mem_filter, mem_univ, true_and]\n rw [and_comm]\n constructor\n .\n use A, by simp [hA]\n exact\n unique_antichain_element_mem_antichain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC\n .\n exact\n unique_antichain_element_mem_chain h_is_chain_partition (Eq.refl #C) A\n (subset_of_mem_fullAntichains hA) (antichain_of_mem_fullAntichains hA)\n hA.right.right c hcC ) }.toFinset\ntheorem fullWidth_of_fullAntichains {P : Type u} [inst : PartialOrder P]\n (C : Finset (Set P)) (S : Finset P) (hC : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (h : (fullAntichains C S).Nonempty) : #C = width S := by sorry\n/--\nA member of the fullChainMaximizers is indeed maximal in the sense of the definition.\n-/\nlemma card_fullChainMaximizers_spec (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)) (a')\n (ha'_mem : a' ∈ (fullChainMaximizers C S hC_part)) :\n ∃ c ∈ (SetLike.coe C), Maximal {x | x ∈ c ∧ ∃ Ai : Finset P,\n (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\nlemma isAntichain_fullChainMaximizers (C : Finset (Set P)) (S : Finset P)\n (hC_part : IsChainPartition (SetLike.coe C) (SetLike.coe S)):\n IsAntichain (· ≤ ·) (SetLike.coe <| fullChainMaximizers C S hC_part) := by sorry\nlemma fullChainMaximizers_subset (C : Finset (Set P)) (S : Finset P)\n (h' : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n (fullChainMaximizers C S h') ⊆ S := sorry\nlemma card_fullChainMaximizers_eq (C : Finset (Set P)) (S : Finset P)\n (h : IsChainPartition (SetLike.coe C) (SetLike.coe S))\n (hA : ∃ A : Finset _, IsAntichain (· ≤ ·) (SetLike.coe A) ∧ A ⊆ S ∧ A.card = C.card) :\n (fullChainMaximizers C S h).card = C.card := by sorry\nlemma card_fullChainMaximizers_spec' (C : Finset (Set P)) (S : Finset P)\n (h : IsChainPartition (SetLike.coe C) (SetLike.coe S)) :\n ∀ a' ∈ (fullChainMaximizers C S h), ∃ c ∈ (SetLike.coe C),\n IsGreatest {x | x ∈ c ∧ ∃ Ai : Finset P, (SetLike.coe Ai) ⊆ (SetLike.coe S) ∧ x ∈ Ai ∧\n IsAntichain (fun x1 x2 ↦ x1 ≤ x2) (SetLike.coe Ai) ∧ #Ai = width S}\n a' := by sorry\nopen scoped Classical in\ntheorem dilworth_induction_equal_width (S : Finset P)\n (ih : ∀ t ⊂ S, IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe t) ∧\n #C = k} (width t)) (a : P) (ha_in_S : a ∈ S) (ha_max : ∀ ⦃y : P⦄,\n (fun x ↦ x ∈ S) y → a ≤ y → y ≤ a) (ih_a : IsLeast {k | ∃ C : Finset (Set P),\n IsChainPartition C (SetLike.coe <| S.erase a) ∧ #C = k} (width (S.erase a)))\n (h_case1 : width S = width (S.erase a)):\n IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe S) ∧ #C = k} (width S) := by sorry\nopen scoped Classical in\nomit [Fintype P] in\ntheorem dilworth_induction_greater_width (S : Finset P) (a : P) (ha_in_S : a ∈ S)\n (ih_a : IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe <| S.erase a)\n ∧ #C = k} (width (S.erase a))) (h_case_2 : width S = width (S.erase a) + 1) :\n IsLeast {k | ∃ C : Finset (Set P), IsChainPartition C (SetLike.coe S) ∧ #C = k} (width S) := by sorry"} -{"project_name": "ErdosDushnikMillerTheorem", "name": "erdos_dushnik_miller", "type": "theorem", "code": "import Mathlib\n\nopen Cardinal in\n\ntheorem erdos_dushnik_miller\n {V : Type*} [Infinite V] (G : SimpleGraph V) :\n (∃ s : Set V, G.IsClique s ∧ #s = #V) ∨\n (∃ s : Set V, G.IsIndepSet s ∧ ℵ₀ ≤ #s) := by sorry"} -{"project_name": "ErdosGallaiTheorem", "name": "ErdosGallaiTheorem", "type": "theorem", "code": "import Mathlib\n/--\nThe multiset of degrees of a finite graph.\n-/\n\ndef degreeMultiset {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n Multiset ℕ :=\n (Finset.univ : Finset V).val.map (fun v => G.degree v)\n/--\nThe list of degrees of a finite graph, sorted in non-increasing order.\n-/\n\ndef degreeList {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n List ℕ :=\n (degreeMultiset G).sort (· ≥ ·)\n\ntheorem ErdosGallaiTheorem (d : List ℕ) (hd : d.SortedGE) :\n (∃ V, ∃ fV : Fintype V, ∃ G : SimpleGraph V, ∃ dG : DecidableRel G.Adj, degreeList G = d) ↔\n Even d.sum ∧\n ∀ k ∈ Set.Ioc 0 d.length,\n (d.take k).sum ≤ k * (k - 1) + ((d.drop k).map fun x => min x k).sum := by sorry"} -{"project_name": "ErdosKacTheorem", "name": "erdos_kac", "type": "theorem", "code": "import Mathlib\n\nopen scoped Classical ArithmeticFunction.omega\n/-- The cumulative distribution function of the standard normal distribution\n N(0,1), defined as `cdf(gaussianReal 0 1)`. -/\nnoncomputable def stdNormalCDF (z : ℝ) : ℝ :=\n ProbabilityTheory.cdf (ProbabilityTheory.gaussianReal 0 1) z\n/-- The normalized distinct prime factor count:\n `(ω(n) - log(log(n))) / √(log(log(n)))`. -/\nnoncomputable def normalizedOmega (n : ℕ) : ℝ :=\n let ll := Real.log (Real.log (n : ℝ))\n ((ω n : ℝ) - ll) / Real.sqrt ll\n/-- **Erdos-Kac theorem.** For real numbers `a < b`, the natural density of\n integers `n` whose normalized prime factor count `(ω(n) - log log n) / √(log log n)`\n lies in `[a, b]` converges to `Φ(b) - Φ(a)`, where `Φ` is the standard normal CDF. -/\n\ntheorem erdos_kac (a b : ℝ) (hab : a < b) :\n Filter.Tendsto\n (fun N : ℕ =>\n ((Finset.Icc 1 N |>.filter fun n =>\n a ≤ normalizedOmega n ∧ normalizedOmega n ≤ b).card : ℝ) / (N : ℝ))\n Filter.atTop\n (nhds (stdNormalCDF b - stdNormalCDF a)) := by sorry"} -{"project_name": "FareySequence", "name": "farey_riemann", "type": "theorem", "code": "import Mathlib\n\nopen Rat Set Filter\n/--\nThe kth Farey set is the set of rational numbers between 0 and 1 whose denominators are at most k.\n-/\n\ndef FareySet (k : ℕ) : Finset ℚ :=\n (Finset.range (k + 1)).biUnion\n (fun d => (((Finset.range (d+1)).image fun (n : ℕ) => (n : ℚ) / (d : ℚ))))\n/--\nThe size of the Farey set of order k.\n-/\n\ndef FareyCard (k : ℕ) : ℕ :=\n (FareySet k).card\n/--\nThe Farey sequence of order k is the vector of rational numbers in the Farey set of order k,\nsorted in increasing order.\n-/\n\ndef FareySequence (k : ℕ) (i : Fin (FareyCard k)) : ℚ :=\n ((FareySet k).sort (fun x y => x ≤ y)).getD i 0\n/--\nThe Farey difference is the difference between the zero-indexed ith Farey number of order k\nand the fraction i/(FareyCard k - 1),\n-/\n\ndef FareyDifference (k : ℕ) (i : Fin (FareyCard k)) : ℚ :=\n let m := FareyCard k\n let f := FareySequence k i\n f - (i / (m - 1))\n/-- https://en.wikipedia.org/wiki/Farey_sequence#Riemann_hypothesis -/\n\ntheorem farey_riemann :\n RiemannHypothesis ↔ ∀ r : ℝ,\n -1 < r → (fun n ↦ ∑' i : Fin (FareyCard n), FareyDifference n i ^ 2)\n =O[atTop] (fun n ↦ (↑n : ℝ) ^ r) := by sorry"} -{"project_name": "FareySequence", "name": "farey_riemann_abs", "type": "theorem", "code": "import Mathlib\n\nopen Rat Set Filter\n/--\nThe kth Farey set is the set of rational numbers between 0 and 1 whose denominators are at most k.\n-/\n\ndef FareySet (k : ℕ) : Finset ℚ :=\n (Finset.range (k + 1)).biUnion\n (fun d => (((Finset.range (d+1)).image fun (n : ℕ) => (n : ℚ) / (d : ℚ))))\n/--\nThe size of the Farey set of order k.\n-/\n\ndef FareyCard (k : ℕ) : ℕ :=\n (FareySet k).card\n/--\nThe Farey sequence of order k is the vector of rational numbers in the Farey set of order k,\nsorted in increasing order.\n-/\n\ndef FareySequence (k : ℕ) (i : Fin (FareyCard k)) : ℚ :=\n ((FareySet k).sort (fun x y => x ≤ y)).getD i 0\n/--\nThe Farey difference is the difference between the zero-indexed ith Farey number of order k\nand the fraction i/(FareyCard k - 1),\n-/\n\ndef FareyDifference (k : ℕ) (i : Fin (FareyCard k)) : ℚ :=\n let m := FareyCard k\n let f := FareySequence k i\n f - (i / (m - 1))\n/-- https://en.wikipedia.org/wiki/Farey_sequence#Riemann_hypothesis -/\n\ntheorem farey_riemann :\n RiemannHypothesis ↔ ∀ r : ℝ,\n -1 < r → (fun n ↦ ∑' i : Fin (FareyCard n), FareyDifference n i ^ 2)\n =O[atTop] (fun n ↦ (↑n : ℝ) ^ r) := by sorry\n/-- An equivalent proposition: -/\n\ntheorem farey_riemann_abs :\n RiemannHypothesis ↔ ∀ r : ℝ,\n 1 / 2 < r → (fun n ↦ ∑' i : Fin (FareyCard n), |FareyDifference n i|)\n =O[atTop] (fun n ↦ (↑n : ℝ) ^ r) := by sorry"} -{"project_name": "FeitThompsonTheorem", "name": "feit_thompson", "type": "theorem", "code": "import Mathlib\n\nopen Set Function Nat\n\nuniverse u\n\ntheorem feit_thompson {G : Type u} [Fintype G] [Group G] (h : Odd (Fintype.card G)) :\n IsSolvable G := by sorry"} -{"project_name": "Fifteen", "name": "fifteen_theorem", "type": "theorem", "code": "import Mathlib\nnoncomputable section\n\nopen Matrix\n\nvariable {n : ℕ}\n/-- An integer matrix represents a natural number if there exists an integer vector v\nsuch that v^T M v equals that number. -/\n\ndef Matrix.represents (M : Matrix (Fin n) (Fin n) ℤ) (m : ℕ) : Prop :=\n ∃ v : Fin n → ℤ, v ⬝ᵥ (M *ᵥ v) = m\n/-- A matrix is universal if it represents all positive integers. -/\n\ndef Matrix.Universal (M : Matrix (Fin n) (Fin n) ℤ) : Prop :=\n ∀ m : ℕ, 0 < m → M.represents m\n/--\nThe **15 Theorem** (Conway-Schneeberger, proved by Bhargava): If a positive definite\nquadratic form with integer matrix represents all positive integers up to 15, then it\nrepresents all positive integers.\n-/\n\ntheorem fifteen_theorem (M : Matrix (Fin n) (Fin n) ℤ)\n (hsymm : M.IsSymm)\n (hpos : M.PosDef)\n (hrep : ∀ m : ℕ, 0 < m → m ≤ 15 → M.represents m) :\n M.Universal := by sorry"} -{"project_name": "FinitelyManyPrimesDimOne", "name": "Ideal.exists_mem_not_mem_other_primes", "type": "lemma", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R]\n/-- If `R` has finitely many primes, then so does `R ⧸ I`. -/\n\ninstance PrimeSpectrum.finite_quotient [Finite (PrimeSpectrum R)] (I : Ideal R) :\n Finite (PrimeSpectrum (R ⧸ I)) :=\n Finite.of_injective (PrimeSpectrum.comap (Ideal.Quotient.mk I))\n (PrimeSpectrum.comap_injective_of_surjective _ Ideal.Quotient.mk_surjective)\n/-- **Prime avoidance for maximal ideals**: If `m` is maximal in a ring with\nfinitely many primes, there exists `y ∈ m` with `y ∉ q` for every prime `q ≠ m`. -/\n\nlemma Ideal.exists_mem_not_mem_other_primes [Finite (PrimeSpectrum R)]\n {m : Ideal R} (hm : m.IsMaximal) :\n ∃ y ∈ m, ∀ (q : Ideal R), q.IsPrime → q ≠ m → y ∉ q := by sorry"} -{"project_name": "FinitelyManyPrimesDimOne", "name": "Ideal.IsPrime.isMaximal_of_finite_primeSpectrum", "type": "lemma", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R]\n/-- If `R` has finitely many primes, then so does `R ⧸ I`. -/\n\ninstance PrimeSpectrum.finite_quotient [Finite (PrimeSpectrum R)] (I : Ideal R) :\n Finite (PrimeSpectrum (R ⧸ I)) :=\n Finite.of_injective (PrimeSpectrum.comap (Ideal.Quotient.mk I))\n (PrimeSpectrum.comap_injective_of_surjective _ Ideal.Quotient.mk_surjective)\n/-- **Prime avoidance for maximal ideals**: If `m` is maximal in a ring with\nfinitely many primes, there exists `y ∈ m` with `y ∉ q` for every prime `q ≠ m`. -/\n\nlemma Ideal.exists_mem_not_mem_other_primes [Finite (PrimeSpectrum R)]\n {m : Ideal R} (hm : m.IsMaximal) :\n ∃ y ∈ m, ∀ (q : Ideal R), q.IsPrime → q ≠ m → y ∉ q := by sorry\n/-- In a Noetherian domain with finitely many primes, every nonzero prime is maximal.\nUses Krull's PIT and prime avoidance to derive a contradiction on height. -/\n\nlemma Ideal.IsPrime.isMaximal_of_finite_primeSpectrum\n [IsDomain R] [IsNoetherianRing R] [Finite (PrimeSpectrum R)]\n {p : Ideal R} (hp : p.IsPrime) (hne : p ≠ ⊥) : p.IsMaximal := by sorry"} -{"project_name": "FinitelyManyPrimesDimOne", "name": "Ring.krullDimLE_one_of_isDomain_of_finite_primeSpectrum", "type": "lemma", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R]\n/-- If `R` has finitely many primes, then so does `R ⧸ I`. -/\n\ninstance PrimeSpectrum.finite_quotient [Finite (PrimeSpectrum R)] (I : Ideal R) :\n Finite (PrimeSpectrum (R ⧸ I)) :=\n Finite.of_injective (PrimeSpectrum.comap (Ideal.Quotient.mk I))\n (PrimeSpectrum.comap_injective_of_surjective _ Ideal.Quotient.mk_surjective)\n/-- **Prime avoidance for maximal ideals**: If `m` is maximal in a ring with\nfinitely many primes, there exists `y ∈ m` with `y ∉ q` for every prime `q ≠ m`. -/\n\nlemma Ideal.exists_mem_not_mem_other_primes [Finite (PrimeSpectrum R)]\n {m : Ideal R} (hm : m.IsMaximal) :\n ∃ y ∈ m, ∀ (q : Ideal R), q.IsPrime → q ≠ m → y ∉ q := by sorry\n/-- In a Noetherian domain with finitely many primes, every nonzero prime is maximal.\nUses Krull's PIT and prime avoidance to derive a contradiction on height. -/\n\nlemma Ideal.IsPrime.isMaximal_of_finite_primeSpectrum\n [IsDomain R] [IsNoetherianRing R] [Finite (PrimeSpectrum R)]\n {p : Ideal R} (hp : p.IsPrime) (hne : p ≠ ⊥) : p.IsMaximal := by sorry\n/-- A Noetherian domain with finitely many primes has Krull dimension ≤ 1. -/\n\nlemma Ring.krullDimLE_one_of_isDomain_of_finite_primeSpectrum\n [IsDomain R] [IsNoetherianRing R] [Finite (PrimeSpectrum R)] :\n Ring.KrullDimLE 1 R := sorry"} -{"project_name": "FinitelyManyPrimesDimOne", "name": "Ring.krullDimLE_one_of_finite_primeSpectrum", "type": "theorem", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R]\n/-- **Stacks 0ALV** (Lemma 10.61.2).\nA Noetherian ring with finitely many prime ideals has Krull dimension ≤ 1. -/\n@[stacks 0ALV, AMS 13]\n\ntheorem Ring.krullDimLE_one_of_finite_primeSpectrum\n [IsNoetherianRing R] [Finite (PrimeSpectrum R)] :\n Ring.KrullDimLE 1 R := by sorry", "imported_file": "-- File: LiveLeanTriathlon.FinitelyManyPrimesDimOne.BackgroundLemmas\nopen Ideal\nvariable {R : Type*} [CommRing R]\n/-- If `R` has finitely many primes, then so does `R ⧸ I`. -/\ninstance PrimeSpectrum.finite_quotient [Finite (PrimeSpectrum R)] (I : Ideal R) :\n Finite (PrimeSpectrum (R ⧸ I)) :=\n Finite.of_injective (PrimeSpectrum.comap (Ideal.Quotient.mk I))\n (PrimeSpectrum.comap_injective_of_surjective _ Ideal.Quotient.mk_surjective)\n/-- **Prime avoidance for maximal ideals**: If `m` is maximal in a ring with\nfinitely many primes, there exists `y ∈ m` with `y ∉ q` for every prime `q ≠ m`. -/\nlemma Ideal.exists_mem_not_mem_other_primes [Finite (PrimeSpectrum R)]\n {m : Ideal R} (hm : m.IsMaximal) :\n ∃ y ∈ m, ∀ (q : Ideal R), q.IsPrime → q ≠ m → y ∉ q := by sorry\n/-- In a Noetherian domain with finitely many primes, every nonzero prime is maximal.\nUses Krull's PIT and prime avoidance to derive a contradiction on height. -/\nlemma Ideal.IsPrime.isMaximal_of_finite_primeSpectrum\n [IsDomain R] [IsNoetherianRing R] [Finite (PrimeSpectrum R)]\n {p : Ideal R} (hp : p.IsPrime) (hne : p ≠ ⊥) : p.IsMaximal := by sorry\n/-- A Noetherian domain with finitely many primes has Krull dimension ≤ 1. -/\nlemma Ring.krullDimLE_one_of_isDomain_of_finite_primeSpectrum\n [IsDomain R] [IsNoetherianRing R] [Finite (PrimeSpectrum R)] :\n Ring.KrullDimLE 1 R := sorry"} -{"project_name": "Fitting", "name": "commFin_normal", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\n\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\n\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\n\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry"} -{"project_name": "Fitting", "name": "commFin_le", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\n\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\n\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\n\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\n\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry"} -{"project_name": "Fitting", "name": "commutator_sup_eq", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\n\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\n\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\n\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\n\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "biSup_range_normal", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\n\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\n\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\n\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\n\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry"} -{"project_name": "Fitting", "name": "mul_left_distrib", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\n\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\n\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\n\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\n\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\n\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "map_subtype_top", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "map_subtype_lowerCentralSeries", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "commFin_congr", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry\nprivate lemma commFin_congr {G : Type*} [Group G] {H₁ H₂ : ℕ → Subgroup G} {n : ℕ}\n (h : ∀ i ≤ n, H₁ i = H₂ i) :\n commFin H₁ n = commFin H₂ n := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "commFin_const_eq_bot", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry\nprivate lemma commFin_congr {G : Type*} [Group G] {H₁ H₂ : ℕ → Subgroup G} {n : ℕ}\n (h : ∀ i ≤ n, H₁ i = H₂ i) :\n commFin H₁ n = commFin H₂ n := by sorry\nprivate lemma commFin_const_eq_bot {G : Type*} [Group G] (K : Subgroup G) (c : ℕ)\n [hK : Group.IsNilpotent K] (hc : Group.nilpotencyClass K = c) :\n commFin (fun _ => (K : Subgroup G)) c = ⊥ := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "commFin_le_const", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry\nprivate lemma commFin_congr {G : Type*} [Group G] {H₁ H₂ : ℕ → Subgroup G} {n : ℕ}\n (h : ∀ i ≤ n, H₁ i = H₂ i) :\n commFin H₁ n = commFin H₂ n := by sorry\nprivate lemma commFin_const_eq_bot {G : Type*} [Group G] (K : Subgroup G) (c : ℕ)\n [hK : Group.IsNilpotent K] (hc : Group.nilpotencyClass K = c) :\n commFin (fun _ => (K : Subgroup G)) c = ⊥ := by sorry\nprivate lemma commFin_le_const {G : Type*} [Group G] {H : ℕ → Subgroup G} {n : ℕ}\n (hH : ∀ i ≤ n, (H i).Normal)\n {I : ℕ → ℕ} {k : ℕ} {K : Subgroup G}\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n)\n (hIK : ∀ j ≤ k, H (I j) = K) :\n commFin H n ≤ commFin (fun _ => K) k := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "commutator_iSup_le", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry\nprivate lemma commFin_congr {G : Type*} [Group G] {H₁ H₂ : ℕ → Subgroup G} {n : ℕ}\n (h : ∀ i ≤ n, H₁ i = H₂ i) :\n commFin H₁ n = commFin H₂ n := by sorry\nprivate lemma commFin_const_eq_bot {G : Type*} [Group G] (K : Subgroup G) (c : ℕ)\n [hK : Group.IsNilpotent K] (hc : Group.nilpotencyClass K = c) :\n commFin (fun _ => (K : Subgroup G)) c = ⊥ := by sorry\nprivate lemma commFin_le_const {G : Type*} [Group G] {H : ℕ → Subgroup G} {n : ℕ}\n (hH : ∀ i ≤ n, (H i).Normal)\n {I : ℕ → ℕ} {k : ℕ} {K : Subgroup G}\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n)\n (hIK : ∀ j ≤ k, H (I j) = K) :\n commFin H n ≤ commFin (fun _ => K) k := by sorry\nprivate instance iSup_normal {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G)\n [hN : ∀ i, (H i).Normal] : (⨆ i, H i).Normal := by\n constructor\n intro n hn g\n refine Subgroup.iSup_induction H (C := fun x => ∀ g : G, g * x * g⁻¹ ∈ ⨆ i, H i) hn ?_ ?_ ?_ g\n .\n intro i x hx g\n exact Subgroup.mem_iSup_of_mem i ((hN i).conj_mem x hx g)\n .\n intro g; simp\n .\n intro x y hx hy g\n have : g * (x * y) * g⁻¹ = (g * x * g⁻¹) * (g * y * g⁻¹) := by group\n rw [this]; exact (⨆ i, H i).mul_mem (hx g) (hy g)\nprivate lemma commutator_iSup_le {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G) (L : Subgroup G)\n [hH : ∀ i, (H i).Normal] [hL : L.Normal] :\n ⁅⨆ i, H i, L⁆ ≤ ⨆ i, ⁅H i, L⁆ := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "BoolToSub_normal", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry\nprivate lemma commFin_congr {G : Type*} [Group G] {H₁ H₂ : ℕ → Subgroup G} {n : ℕ}\n (h : ∀ i ≤ n, H₁ i = H₂ i) :\n commFin H₁ n = commFin H₂ n := by sorry\nprivate lemma commFin_const_eq_bot {G : Type*} [Group G] (K : Subgroup G) (c : ℕ)\n [hK : Group.IsNilpotent K] (hc : Group.nilpotencyClass K = c) :\n commFin (fun _ => (K : Subgroup G)) c = ⊥ := by sorry\nprivate lemma commFin_le_const {G : Type*} [Group G] {H : ℕ → Subgroup G} {n : ℕ}\n (hH : ∀ i ≤ n, (H i).Normal)\n {I : ℕ → ℕ} {k : ℕ} {K : Subgroup G}\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n)\n (hIK : ∀ j ≤ k, H (I j) = K) :\n commFin H n ≤ commFin (fun _ => K) k := by sorry\nprivate instance iSup_normal {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G)\n [hN : ∀ i, (H i).Normal] : (⨆ i, H i).Normal := by\n constructor\n intro n hn g\n refine Subgroup.iSup_induction H (C := fun x => ∀ g : G, g * x * g⁻¹ ∈ ⨆ i, H i) hn ?_ ?_ ?_ g\n .\n intro i x hx g\n exact Subgroup.mem_iSup_of_mem i ((hN i).conj_mem x hx g)\n .\n intro g; simp\n .\n intro x y hx hy g\n have : g * (x * y) * g⁻¹ = (g * x * g⁻¹) * (g * y * g⁻¹) := by group\n rw [this]; exact (⨆ i, H i).mul_mem (hx g) (hy g)\nprivate lemma commutator_iSup_le {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G) (L : Subgroup G)\n [hH : ∀ i, (H i).Normal] [hL : L.Normal] :\n ⁅⨆ i, H i, L⁆ ≤ ⨆ i, ⁅H i, L⁆ := by sorry\nprivate abbrev BoolToSub {G : Type*} [Group G] (M N : Subgroup G) (b : Bool) : Subgroup G :=\n if b then M else N\nprivate lemma BoolToSub_normal {G : Type*} [Group G] {M N : Subgroup G}\n (hM : M.Normal) (hN : N.Normal) (b : Bool) : (BoolToSub M N b).Normal := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "expansion", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry\nprivate lemma commFin_congr {G : Type*} [Group G] {H₁ H₂ : ℕ → Subgroup G} {n : ℕ}\n (h : ∀ i ≤ n, H₁ i = H₂ i) :\n commFin H₁ n = commFin H₂ n := by sorry\nprivate lemma commFin_const_eq_bot {G : Type*} [Group G] (K : Subgroup G) (c : ℕ)\n [hK : Group.IsNilpotent K] (hc : Group.nilpotencyClass K = c) :\n commFin (fun _ => (K : Subgroup G)) c = ⊥ := by sorry\nprivate lemma commFin_le_const {G : Type*} [Group G] {H : ℕ → Subgroup G} {n : ℕ}\n (hH : ∀ i ≤ n, (H i).Normal)\n {I : ℕ → ℕ} {k : ℕ} {K : Subgroup G}\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n)\n (hIK : ∀ j ≤ k, H (I j) = K) :\n commFin H n ≤ commFin (fun _ => K) k := by sorry\nprivate instance iSup_normal {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G)\n [hN : ∀ i, (H i).Normal] : (⨆ i, H i).Normal := by\n constructor\n intro n hn g\n refine Subgroup.iSup_induction H (C := fun x => ∀ g : G, g * x * g⁻¹ ∈ ⨆ i, H i) hn ?_ ?_ ?_ g\n .\n intro i x hx g\n exact Subgroup.mem_iSup_of_mem i ((hN i).conj_mem x hx g)\n .\n intro g; simp\n .\n intro x y hx hy g\n have : g * (x * y) * g⁻¹ = (g * x * g⁻¹) * (g * y * g⁻¹) := by group\n rw [this]; exact (⨆ i, H i).mul_mem (hx g) (hy g)\nprivate lemma commutator_iSup_le {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G) (L : Subgroup G)\n [hH : ∀ i, (H i).Normal] [hL : L.Normal] :\n ⁅⨆ i, H i, L⁆ ≤ ⨆ i, ⁅H i, L⁆ := by sorry\nprivate abbrev BoolToSub {G : Type*} [Group G] (M N : Subgroup G) (b : Bool) : Subgroup G :=\n if b then M else N\nprivate lemma BoolToSub_normal {G : Type*} [Group G] {M N : Subgroup G}\n (hM : M.Normal) (hN : N.Normal) (b : Bool) : (BoolToSub M N b).Normal := by sorry\nprivate abbrev CF {G : Type*} [Group G] (M N : Subgroup G) (σ : ℕ → Bool) (k : ℕ) : Subgroup G :=\n commFin (fun i => BoolToSub M N (σ i)) k\n\nset_option maxHeartbeats 1600000 in\nprivate lemma expansion {G : Type*} [Group G] (M N : Subgroup G) [hM : M.Normal] [hN : N.Normal]\n (k : ℕ) :\n commFin (fun _ => (M ⊔ N : Subgroup G)) k ≤ ⨆ (σ : ℕ → Bool), CF M N σ k := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "pigeonhole_bool", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry\nprivate lemma commFin_congr {G : Type*} [Group G] {H₁ H₂ : ℕ → Subgroup G} {n : ℕ}\n (h : ∀ i ≤ n, H₁ i = H₂ i) :\n commFin H₁ n = commFin H₂ n := by sorry\nprivate lemma commFin_const_eq_bot {G : Type*} [Group G] (K : Subgroup G) (c : ℕ)\n [hK : Group.IsNilpotent K] (hc : Group.nilpotencyClass K = c) :\n commFin (fun _ => (K : Subgroup G)) c = ⊥ := by sorry\nprivate lemma commFin_le_const {G : Type*} [Group G] {H : ℕ → Subgroup G} {n : ℕ}\n (hH : ∀ i ≤ n, (H i).Normal)\n {I : ℕ → ℕ} {k : ℕ} {K : Subgroup G}\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n)\n (hIK : ∀ j ≤ k, H (I j) = K) :\n commFin H n ≤ commFin (fun _ => K) k := by sorry\nprivate instance iSup_normal {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G)\n [hN : ∀ i, (H i).Normal] : (⨆ i, H i).Normal := by\n constructor\n intro n hn g\n refine Subgroup.iSup_induction H (C := fun x => ∀ g : G, g * x * g⁻¹ ∈ ⨆ i, H i) hn ?_ ?_ ?_ g\n .\n intro i x hx g\n exact Subgroup.mem_iSup_of_mem i ((hN i).conj_mem x hx g)\n .\n intro g; simp\n .\n intro x y hx hy g\n have : g * (x * y) * g⁻¹ = (g * x * g⁻¹) * (g * y * g⁻¹) := by group\n rw [this]; exact (⨆ i, H i).mul_mem (hx g) (hy g)\nprivate lemma commutator_iSup_le {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G) (L : Subgroup G)\n [hH : ∀ i, (H i).Normal] [hL : L.Normal] :\n ⁅⨆ i, H i, L⁆ ≤ ⨆ i, ⁅H i, L⁆ := by sorry\nprivate abbrev BoolToSub {G : Type*} [Group G] (M N : Subgroup G) (b : Bool) : Subgroup G :=\n if b then M else N\nprivate lemma BoolToSub_normal {G : Type*} [Group G] {M N : Subgroup G}\n (hM : M.Normal) (hN : N.Normal) (b : Bool) : (BoolToSub M N b).Normal := by sorry\nprivate abbrev CF {G : Type*} [Group G] (M N : Subgroup G) (σ : ℕ → Bool) (k : ℕ) : Subgroup G :=\n commFin (fun i => BoolToSub M N (σ i)) k\n\nset_option maxHeartbeats 1600000 in\nprivate lemma expansion {G : Type*} [Group G] (M N : Subgroup G) [hM : M.Normal] [hN : N.Normal]\n (k : ℕ) :\n commFin (fun _ => (M ⊔ N : Subgroup G)) k ≤ ⨆ (σ : ℕ → Bool), CF M N σ k := by sorry\nprivate lemma pigeonhole_bool (m n : ℕ) (σ : ℕ → Bool) :\n (Finset.univ.filter (fun i : Fin (m + n + 1) => σ i = true)).card ≥ m + 1 ∨\n (Finset.univ.filter (fun i : Fin (m + n + 1) => σ i = false)).card ≥ n + 1 := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "extract_strictMono_indices", "type": "lemma", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry\nprivate lemma commFin_congr {G : Type*} [Group G] {H₁ H₂ : ℕ → Subgroup G} {n : ℕ}\n (h : ∀ i ≤ n, H₁ i = H₂ i) :\n commFin H₁ n = commFin H₂ n := by sorry\nprivate lemma commFin_const_eq_bot {G : Type*} [Group G] (K : Subgroup G) (c : ℕ)\n [hK : Group.IsNilpotent K] (hc : Group.nilpotencyClass K = c) :\n commFin (fun _ => (K : Subgroup G)) c = ⊥ := by sorry\nprivate lemma commFin_le_const {G : Type*} [Group G] {H : ℕ → Subgroup G} {n : ℕ}\n (hH : ∀ i ≤ n, (H i).Normal)\n {I : ℕ → ℕ} {k : ℕ} {K : Subgroup G}\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n)\n (hIK : ∀ j ≤ k, H (I j) = K) :\n commFin H n ≤ commFin (fun _ => K) k := by sorry\nprivate instance iSup_normal {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G)\n [hN : ∀ i, (H i).Normal] : (⨆ i, H i).Normal := by\n constructor\n intro n hn g\n refine Subgroup.iSup_induction H (C := fun x => ∀ g : G, g * x * g⁻¹ ∈ ⨆ i, H i) hn ?_ ?_ ?_ g\n .\n intro i x hx g\n exact Subgroup.mem_iSup_of_mem i ((hN i).conj_mem x hx g)\n .\n intro g; simp\n .\n intro x y hx hy g\n have : g * (x * y) * g⁻¹ = (g * x * g⁻¹) * (g * y * g⁻¹) := by group\n rw [this]; exact (⨆ i, H i).mul_mem (hx g) (hy g)\nprivate lemma commutator_iSup_le {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G) (L : Subgroup G)\n [hH : ∀ i, (H i).Normal] [hL : L.Normal] :\n ⁅⨆ i, H i, L⁆ ≤ ⨆ i, ⁅H i, L⁆ := by sorry\nprivate abbrev BoolToSub {G : Type*} [Group G] (M N : Subgroup G) (b : Bool) : Subgroup G :=\n if b then M else N\nprivate lemma BoolToSub_normal {G : Type*} [Group G] {M N : Subgroup G}\n (hM : M.Normal) (hN : N.Normal) (b : Bool) : (BoolToSub M N b).Normal := by sorry\nprivate abbrev CF {G : Type*} [Group G] (M N : Subgroup G) (σ : ℕ → Bool) (k : ℕ) : Subgroup G :=\n commFin (fun i => BoolToSub M N (σ i)) k\n\nset_option maxHeartbeats 1600000 in\nprivate lemma expansion {G : Type*} [Group G] (M N : Subgroup G) [hM : M.Normal] [hN : N.Normal]\n (k : ℕ) :\n commFin (fun _ => (M ⊔ N : Subgroup G)) k ≤ ⨆ (σ : ℕ → Bool), CF M N σ k := by sorry\nprivate lemma pigeonhole_bool (m n : ℕ) (σ : ℕ → Bool) :\n (Finset.univ.filter (fun i : Fin (m + n + 1) => σ i = true)).card ≥ m + 1 ∨\n (Finset.univ.filter (fun i : Fin (m + n + 1) => σ i = false)).card ≥ n + 1 := by sorry\nprivate lemma extract_strictMono_indices {m n : ℕ} {k : ℕ}\n (s : Finset (Fin (m + n + 1))) (hs : s.card ≥ k + 1) :\n ∃ (I : ℕ → ℕ), StrictMonoOn I (Set.Iic k) ∧ I k ≤ m + n ∧\n ∀ j ≤ k, ∃ (h : I j < m + n + 1), (⟨I j, h⟩ : Fin (m + n + 1)) ∈ s := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "Fitting", "name": "fitting", "type": "theorem", "code": "import Mathlib\n\nopen scoped commutatorElement\nprivate lemma map_subtype_top {G : Type*} [Group G] (K : Subgroup G) :\n (⊤ : Subgroup K).map K.subtype = K := by sorry\n\nopen Subgroup in\nprivate lemma map_subtype_lowerCentralSeries {G : Type*} [Group G] (K : Subgroup G) (k : ℕ) :\n (lowerCentralSeries K k).map K.subtype = commFin (fun _ => (K : Subgroup G)) k := by sorry\nprivate lemma commFin_congr {G : Type*} [Group G] {H₁ H₂ : ℕ → Subgroup G} {n : ℕ}\n (h : ∀ i ≤ n, H₁ i = H₂ i) :\n commFin H₁ n = commFin H₂ n := by sorry\nprivate lemma commFin_const_eq_bot {G : Type*} [Group G] (K : Subgroup G) (c : ℕ)\n [hK : Group.IsNilpotent K] (hc : Group.nilpotencyClass K = c) :\n commFin (fun _ => (K : Subgroup G)) c = ⊥ := by sorry\nprivate lemma commFin_le_const {G : Type*} [Group G] {H : ℕ → Subgroup G} {n : ℕ}\n (hH : ∀ i ≤ n, (H i).Normal)\n {I : ℕ → ℕ} {k : ℕ} {K : Subgroup G}\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n)\n (hIK : ∀ j ≤ k, H (I j) = K) :\n commFin H n ≤ commFin (fun _ => K) k := by sorry\nprivate instance iSup_normal {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G)\n [hN : ∀ i, (H i).Normal] : (⨆ i, H i).Normal := by\n constructor\n intro n hn g\n refine Subgroup.iSup_induction H (C := fun x => ∀ g : G, g * x * g⁻¹ ∈ ⨆ i, H i) hn ?_ ?_ ?_ g\n .\n intro i x hx g\n exact Subgroup.mem_iSup_of_mem i ((hN i).conj_mem x hx g)\n .\n intro g; simp\n .\n intro x y hx hy g\n have : g * (x * y) * g⁻¹ = (g * x * g⁻¹) * (g * y * g⁻¹) := by group\n rw [this]; exact (⨆ i, H i).mul_mem (hx g) (hy g)\nprivate lemma commutator_iSup_le {G : Type*} [Group G] {ι : Type*} (H : ι → Subgroup G) (L : Subgroup G)\n [hH : ∀ i, (H i).Normal] [hL : L.Normal] :\n ⁅⨆ i, H i, L⁆ ≤ ⨆ i, ⁅H i, L⁆ := by sorry\nprivate abbrev BoolToSub {G : Type*} [Group G] (M N : Subgroup G) (b : Bool) : Subgroup G :=\n if b then M else N\nprivate lemma BoolToSub_normal {G : Type*} [Group G] {M N : Subgroup G}\n (hM : M.Normal) (hN : N.Normal) (b : Bool) : (BoolToSub M N b).Normal := by sorry\nprivate abbrev CF {G : Type*} [Group G] (M N : Subgroup G) (σ : ℕ → Bool) (k : ℕ) : Subgroup G :=\n commFin (fun i => BoolToSub M N (σ i)) k\n\nset_option maxHeartbeats 1600000 in\nprivate lemma expansion {G : Type*} [Group G] (M N : Subgroup G) [hM : M.Normal] [hN : N.Normal]\n (k : ℕ) :\n commFin (fun _ => (M ⊔ N : Subgroup G)) k ≤ ⨆ (σ : ℕ → Bool), CF M N σ k := by sorry\nprivate lemma pigeonhole_bool (m n : ℕ) (σ : ℕ → Bool) :\n (Finset.univ.filter (fun i : Fin (m + n + 1) => σ i = true)).card ≥ m + 1 ∨\n (Finset.univ.filter (fun i : Fin (m + n + 1) => σ i = false)).card ≥ n + 1 := by sorry\nprivate lemma extract_strictMono_indices {m n : ℕ} {k : ℕ}\n (s : Finset (Fin (m + n + 1))) (hs : s.card ≥ k + 1) :\n ∃ (I : ℕ → ℕ), StrictMonoOn I (Set.Iic k) ∧ I k ≤ m + n ∧\n ∀ j ≤ k, ∃ (h : I j < m + n + 1), (⟨I j, h⟩ : Fin (m + n + 1)) ∈ s := by sorry\n\nset_option maxHeartbeats 800000 in\n\ntheorem fitting {G : Type*} [Group G] (M N : Subgroup G) (hM₁ : M.Normal) (hN₁ : N.Normal)\n (m n : ℕ)\n (hM₂ : Group.IsNilpotent M) (hM₃ : Group.nilpotencyClass M = m)\n (hN₂ : Group.IsNilpotent N) (hN₃ : Group.nilpotencyClass N = n) :\n ∃ _ : Group.IsNilpotent ↥(M ⊔ N), Group.nilpotencyClass ↥(M ⊔ N) ≤ m + n := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Fitting.BackgroundLemmas\nopen scoped commutatorElement\nvariable {G : Type*} [Group G]\n/-- The commutator subgroup of `H 0, ..., H n` -/\ndef commFin (H : ℕ → Subgroup G) (n : ℕ) : Subgroup G :=\n match n with\n | 0 => H 0\n | n + 1 => ⁅commFin H n, H (n + 1)⁆\nlemma commFin_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n commFin H n |>.Normal := by sorry\nlemma commFin_le (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) (I : ℕ → ℕ)\n (k : ℕ)\n (hI₁ : StrictMonoOn I (Set.Iic k))\n (hI₂ : I k ≤ n) :\n commFin H n ≤ commFin (H ∘ I) k := by sorry\nprivate lemma commutator_sup_eq (A B L : Subgroup G)\n [hA : A.Normal] [hB : B.Normal] [hL : L.Normal] :\n ⁅A ⊔ B, L⁆ = ⁅A, L⁆ ⊔ ⁅B, L⁆ := by sorry\nprivate lemma biSup_range_normal (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal) :\n (⨆ i ∈ Finset.range n, H i).Normal := by sorry\nlemma mul_left_distrib (H : ℕ → Subgroup G) (n : ℕ) (hH : ∀ i ≤ n, (H i).Normal)\n(L : Subgroup G) (hL : L.Normal) :\n ⁅(⨆ i ∈ Finset.range n, H i), L⁆ = ⨆ i ∈ Finset.range n, ⁅H i, L⁆ := by sorry"} -{"project_name": "FrankWolfe", "name": "frank_wolfe_convergence_rate", "type": "theorem", "code": "import Mathlib\n\nopen Set\n\nvariable {d : ℕ}\n/-- The Frank-Wolfe iterate sequence with step sizes `γ_k = 2/(k+2)`.\nand linear minimization oracle `lmo`.\n-/\nnoncomputable def frankWolfeSeq\n (lmo : EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d))\n (x₀ : EuclideanSpace ℝ (Fin d)) : ℕ → EuclideanSpace ℝ (Fin d)\n | 0 => x₀\n | k + 1 =>\n let xk := frankWolfeSeq lmo x₀ k\n xk + (2 / ((k : ℝ) + 2)) • (lmo xk - xk)\n/-- **Frank-Wolfe Convergence Rate Theorem**\nThe Frank-Wolfe (Conditional Gradient) algorithm with step sizes `γ_k = 2/(k+2)`\nachieves a worst-case convergence rate of `O(1/k)` for minimizing a smooth convex\nfunction over a compact convex set.\nMore precisely, if `f : EuclideanSpace ℝ (Fin d) → ℝ` is convex and has Lipschitz\ncontinuous Fréchet derivative on a compact convex set `D`, then there exists a\nconstant `C > 0` such that for all `k` and any minimizer `x_star` of `f` over `D`:\n `f(x_k) - f(x_star) ≤ C / (k + 2)` -/\n\ntheorem frank_wolfe_convergence_rate\n {D : Set (EuclideanSpace ℝ (Fin d))} {f : EuclideanSpace ℝ (Fin d) → ℝ} {L : NNReal}\n {lmo : EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)}\n {x₀ x_star : EuclideanSpace ℝ (Fin d)}\n (hD_compact : IsCompact D)\n (hD_convex : Convex ℝ D)\n (hf_convex : ConvexOn ℝ D f)\n (hf_diff : Differentiable ℝ f)\n (hf_smooth : LipschitzOnWith L (fderiv ℝ f) D)\n (hx₀_mem : x₀ ∈ D)\n (hx_star_mem : x_star ∈ D)\n (hx_star_min : IsMinOn f D x_star)\n (hlmo_mem : ∀ x ∈ D, lmo x ∈ D)\n (hlmo_min : ∀ x ∈ D, IsMinOn (fun s => fderiv ℝ f x s) D (lmo x))\n : ∃ C : ℝ, 0 < C ∧ ∀ k : ℕ,\n f (frankWolfeSeq lmo x₀ k) - f x_star ≤ C / ((k : ℝ) + 2) := by sorry"} -{"project_name": "FreimanTheorem", "name": "Freiman", "type": "theorem", "code": "import Mathlib\n\nopen Nat Finset Set Pointwise\n/-- Generalized finite arithmetic progression\nhttps://en.wikipedia.org/wiki/Generalized_arithmetic_progression -/\n\nstructure GFLP where\n /-- The dimension of the Generalized progression: the number of differences -/\n dim : Nat\n /--\n The initial value of the progression, i.e.\n the component appearing with coefficient 1 in the formula for each element of the progression\n -/\n x0 : ℤ\n /-- The values of the differences in the progression -/\n x : Fin dim → ℤ\n /-- The lengths of the progression in each direction -/\n L : Fin dim → ℕ\n/-- The set associated with a Generalized finite arithmetic progression -/\n\ndef setOfGFLP (A : GFLP) : Set ℤ :=\n {e | ∃ f : Fin A.dim → ℕ, (∀ i : Fin A.dim, f i < A.L i)\n ∧ e = A.x0 + ∑ i : Fin A.dim, f i * A.x i}\n/-- |A + A| / |A| -/\nnoncomputable\n\ndef QuotSum (A : Finset ℤ) : ℝ :=\n (A + A).card / (A.card : ℝ)\n/-- Slightly simplified version of Freiman's theorem.\nUnlike https://en.wikipedia.org/wiki/Freiman%27s_theorem, we merge f and d\n-/\n\ntheorem Freiman (K : ℝ) : ∃ dim size : ℕ,\n ∀ A : Finset ℤ, QuotSum A ≤ K →\n ∃ L : GFLP,\n ↑A ⊆ setOfGFLP L\n ∧ L.dim ≤ dim\n ∧ (setOfGFLP L).ncard ≤ size * A.card := by sorry"} -{"project_name": "FriedlanderIwaniecTheorem", "name": "friedlander_iwaniec", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n/-- Friedlander–Iwaniec theorem\nhttps://en.wikipedia.org/wiki/Friedlander%E2%80%93Iwaniec_theorem -/\n\ntheorem friedlander_iwaniec : {p : ℕ | p.Prime ∧ ∃ a b, p = a ^ 2 + b ^ 4}.Infinite := by sorry"} -{"project_name": "Froda", "name": "jump_discontinuities_of_monotone", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Set Filter Topology\n\nlemma jump_discontinuities_of_monotone {f : ℝ → ℝ} (h_mono : Monotone f) :\n ∀ x, ¬ ContinuousAt f x →\n (sSup (f '' Iio x)) < (sInf (f '' Ioi x)) := by sorry"} -{"project_name": "Froda", "name": "Monotone.sInf_Ioi_le_sSup_Iio", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Set Filter Topology\n\nlemma jump_discontinuities_of_monotone {f : ℝ → ℝ} (h_mono : Monotone f) :\n ∀ x, ¬ ContinuousAt f x →\n (sSup (f '' Iio x)) < (sInf (f '' Ioi x)) := by sorry\n\nlemma Monotone.sInf_Ioi_le_sSup_Iio {f : ℝ → ℝ} (h_mono : Monotone f) (x y : ℝ) (hxy : x < y) :\n sInf (f '' Ioi x) ≤ sSup (f '' Iio y) := by sorry"} -{"project_name": "Froda", "name": "Real.countable_not_continuousAt", "type": "theorem", "code": "import Mathlib\n\nuniverse u\n\nopen Set Filter Topology\n\ntheorem Real.countable_not_continuousAt (f : ℝ → ℝ) (h_mono : Monotone f) :\n {x | ¬ ContinuousAt f x}.Countable := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Froda.BackgroundLemmas\nuniverse u\nopen Set Filter Topology\nlemma jump_discontinuities_of_monotone {f : ℝ → ℝ} (h_mono : Monotone f) :\n ∀ x, ¬ ContinuousAt f x →\n (sSup (f '' Iio x)) < (sInf (f '' Ioi x)) := by sorry\nlemma Monotone.sInf_Ioi_le_sSup_Iio {f : ℝ → ℝ} (h_mono : Monotone f) (x y : ℝ) (hxy : x < y) :\n sInf (f '' Ioi x) ≤ sSup (f '' Iio y) := by sorry"} -{"project_name": "GaussLucas", "name": "logDeriv_Polynomial", "type": "lemma", "code": "import Mathlib\n\nopen Polynomial ComplexConjugate\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\n-/\n\nlemma logDeriv_Polynomial (p : ℂ[X]) {z : ℂ} (hz_not_mem : z ∉ p.roots) :\n logDeriv p.eval z = (p.roots.map fun a => (z - a)⁻¹).sum := by sorry"} -{"project_name": "GaussLucas", "name": "sum_inv_sub_roots_eq_zero", "type": "lemma", "code": "import Mathlib\n\nopen Polynomial ComplexConjugate\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\n-/\n\nlemma logDeriv_Polynomial (p : ℂ[X]) {z : ℂ} (hz_not_mem : z ∉ p.roots) :\n logDeriv p.eval z = (p.roots.map fun a => (z - a)⁻¹).sum := by sorry\n/--\nIf z is a root of the derivative of a polynomial p, but not a root of p itself,\nthen the sum of the inverses of the differences between z and each root of p is zero.\n-/\n\nlemma sum_inv_sub_roots_eq_zero {p : ℂ[X]} {z : ℂ}\n (hz_mem_derivative : z ∈ p.derivative.roots) (hz_not_mem : z ∉ p.roots) :\n Multiset.sum (p.roots.map fun a => (z - a)⁻¹) = 0 := by sorry"} -{"project_name": "GaussLucas", "name": "sum_norm_sq_sub_inv_nonzero", "type": "lemma", "code": "import Mathlib\n\nopen Polynomial ComplexConjugate\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\n-/\n\nlemma logDeriv_Polynomial (p : ℂ[X]) {z : ℂ} (hz_not_mem : z ∉ p.roots) :\n logDeriv p.eval z = (p.roots.map fun a => (z - a)⁻¹).sum := by sorry\n/--\nIf z is a root of the derivative of a polynomial p, but not a root of p itself,\nthen the sum of the inverses of the differences between z and each root of p is zero.\n-/\n\nlemma sum_inv_sub_roots_eq_zero {p : ℂ[X]} {z : ℂ}\n (hz_mem_derivative : z ∈ p.derivative.roots) (hz_not_mem : z ∉ p.roots) :\n Multiset.sum (p.roots.map fun a => (z - a)⁻¹) = 0 := by sorry\n/--\nThe weighting which assigns to each root `a` of a polynomial `p` the value\n`(1 / ‖z - a‖^2)` has a non-zero total weight.\n-/\n\nlemma sum_norm_sq_sub_inv_nonzero {p : ℂ[X]} {z : ℂ}\n (hz_mem_derivative : z ∈ (derivative p).roots) (hz_not_mem : z ∉ p.roots):\n ∑ i : p.roots.ToType, (‖z - i.fst‖ ^ 2)⁻¹ ≠ 0 := sorry"} -{"project_name": "GaussLucas", "name": "deriv_root_as_weighted_average_of_roots", "type": "lemma", "code": "import Mathlib\n\nopen Polynomial ComplexConjugate\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\n-/\n\nlemma logDeriv_Polynomial (p : ℂ[X]) {z : ℂ} (hz_not_mem : z ∉ p.roots) :\n logDeriv p.eval z = (p.roots.map fun a => (z - a)⁻¹).sum := by sorry\n/--\nIf z is a root of the derivative of a polynomial p, but not a root of p itself,\nthen the sum of the inverses of the differences between z and each root of p is zero.\n-/\n\nlemma sum_inv_sub_roots_eq_zero {p : ℂ[X]} {z : ℂ}\n (hz_mem_derivative : z ∈ p.derivative.roots) (hz_not_mem : z ∉ p.roots) :\n Multiset.sum (p.roots.map fun a => (z - a)⁻¹) = 0 := by sorry\n/--\nThe weighting which assigns to each root `a` of a polynomial `p` the value\n`(1 / ‖z - a‖^2)` has a non-zero total weight.\n-/\n\nlemma sum_norm_sq_sub_inv_nonzero {p : ℂ[X]} {z : ℂ}\n (hz_mem_derivative : z ∈ (derivative p).roots) (hz_not_mem : z ∉ p.roots):\n ∑ i : p.roots.ToType, (‖z - i.fst‖ ^ 2)⁻¹ ≠ 0 := sorry\n/--\nIf z is a root of the derivative of a polynomial p, but not a root of p itself,\nthen it can be expressed as a weighted average of the roots of p.\n-/\n\nlemma deriv_root_as_weighted_average_of_roots {p : ℂ[X]} {z : ℂ}\n (hz_mem_derivative : z ∈ p.derivative.roots) (hz_not_mem : z ∉ p.roots) :\n z = Multiset.sum (p.roots.map fun a => ((1 / ‖z - a‖^2) / Multiset.sum\n (p.roots.map fun a => 1 / ‖z - a‖^2)) • a) := by sorry"} -{"project_name": "GaussLucas", "name": "Complex.mem_convexHull_roots_of_mem_derivative_roots", "type": "theorem", "code": "import Mathlib\n\nopen Polynomial\n\ntheorem Complex.mem_convexHull_roots_of_mem_derivative_roots (p : ℂ[X]) (z : ℂ)\n (z_mem_roots_p_derivative : z ∈ p.derivative.roots) :\n z ∈ convexHull ℝ (p.roots.toFinset : Set ℂ) := sorry", "imported_file": "-- File: LiveLeanTriathlon.GaussLucas.BackgroundLemmas\nopen Polynomial ComplexConjugate\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\n-/\nlemma logDeriv_Polynomial (p : ℂ[X]) {z : ℂ} (hz_not_mem : z ∉ p.roots) :\n logDeriv p.eval z = (p.roots.map fun a => (z - a)⁻¹).sum := by sorry\n/--\nIf z is a root of the derivative of a polynomial p, but not a root of p itself,\nthen the sum of the inverses of the differences between z and each root of p is zero.\n-/\nlemma sum_inv_sub_roots_eq_zero {p : ℂ[X]} {z : ℂ}\n (hz_mem_derivative : z ∈ p.derivative.roots) (hz_not_mem : z ∉ p.roots) :\n Multiset.sum (p.roots.map fun a => (z - a)⁻¹) = 0 := by sorry\n/--\nThe weighting which assigns to each root `a` of a polynomial `p` the value\n`(1 / ‖z - a‖^2)` has a non-zero total weight.\n-/\nlemma sum_norm_sq_sub_inv_nonzero {p : ℂ[X]} {z : ℂ}\n (hz_mem_derivative : z ∈ (derivative p).roots) (hz_not_mem : z ∉ p.roots):\n ∑ i : p.roots.ToType, (‖z - i.fst‖ ^ 2)⁻¹ ≠ 0 := sorry\n/--\nIf z is a root of the derivative of a polynomial p, but not a root of p itself,\nthen it can be expressed as a weighted average of the roots of p.\n-/\nlemma deriv_root_as_weighted_average_of_roots {p : ℂ[X]} {z : ℂ}\n (hz_mem_derivative : z ∈ p.derivative.roots) (hz_not_mem : z ∉ p.roots) :\n z = Multiset.sum (p.roots.map fun a => ((1 / ‖z - a‖^2) / Multiset.sum\n (p.roots.map fun a => 1 / ‖z - a‖^2)) • a) := by sorry"} -{"project_name": "GelfondSchneiderTheorem", "name": "gelfond_scheider", "type": "theorem", "code": "import Mathlib\n\nopen Set Function\n\nuniverse u\n\ntheorem gelfond_scheider (a b : ℝ) (ha_neq : a ≠ 0 ∧ a ≠ 1)\n (ha_alg : IsAlgebraic ℚ a) (hb_alg : IsAlgebraic ℚ b) (hb : Irrational b) :\n Transcendental ℚ b := by sorry"} -{"project_name": "GreenTaoTheorem", "name": "Nat.Prime.greenTao", "type": "theorem", "code": "import Mathlib\n/-- **Green–Tao Theorem**: The prime numbers contain arbitrarily long arithmetic progressions.\nFor every `k`, there exist natural numbers `a` and `d` with `d > 0` such that\n`a`, `a + d`, `a + 2d`, …, `a + (k-1)d` are all prime. -/\n\ntheorem Nat.Prime.greenTao (k : ℕ) :\n ∃ a d : ℕ, 0 < d ∧ ∀ i < k, (a + i * d).Prime := by sorry"} -{"project_name": "GrushkoTheorem", "name": "grushko", "type": "theorem", "code": "import Mathlib\n\nopen Group Monoid.Coprod\n\ninstance grushko' {G H : Type*} [Group G] [Group H] [FG G] [FG H] : FG (G ∗ H) := sorry\n\ntheorem grushko {G H : Type*} [Group G] [Group H] [FG G] [FG H] :\n rank (G ∗ H) = rank G + rank H := by sorry"} -{"project_name": "HardyLittlewoodTauberian", "name": "tauberian", "type": "theorem", "code": "import Mathlib\n\nopen Filter Topology Asymptotics Real\n\ntheorem tauberian {a : ℕ → ℝ} (ha : 0 ≤ a)\n (h : (fun (y : ℝ) ↦ ∑' k : ℕ, a k * rexp (-k * y)) ~[𝓝[>] 0] (fun (y : ℝ) ↦ 1 / y)) :\n (fun n ↦ ∑ k ∈ Finset.range n, a k) ~[atTop] (fun n ↦ ↑n) := sorry"} -{"project_name": "HasseTheoremOnEllipticCurves", "name": "HasseBound", "type": "theorem", "code": "import Mathlib\n\ntheorem HasseBound (F : Type*) [Finite F] [Field F] (E : WeierstrassCurve.Affine F) :\n abs ((Nat.card <| E.Point : ℝ) - (Nat.card F + 1)) ≤ 2 * Real.sqrt (Nat.card F) := sorry"} -{"project_name": "HeightOnePrimesUfd", "name": "Ideal.eq_bot_of_primeHeight_eq_zero", "type": "lemma", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R] [IsDomain R] [IsNoetherianRing R]\nomit [IsNoetherianRing R] in\n/-- In a domain, height-0 primes are `⊥`. -/\n\nlemma Ideal.eq_bot_of_primeHeight_eq_zero {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 0) : p = ⊥ := by sorry"} -{"project_name": "HeightOnePrimesUfd", "name": "Ideal.ne_bot_of_primeHeight_eq_one", "type": "lemma", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R] [IsDomain R] [IsNoetherianRing R]\nomit [IsNoetherianRing R] in\n/-- In a domain, height-0 primes are `⊥`. -/\n\nlemma Ideal.eq_bot_of_primeHeight_eq_zero {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 0) : p = ⊥ := by sorry\nomit [IsNoetherianRing R] in\n/-- In a domain, height-1 primes are nonzero. -/\n\nlemma Ideal.ne_bot_of_primeHeight_eq_one {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 1) : p ≠ ⊥ := by sorry"} -{"project_name": "HeightOnePrimesUfd", "name": "Ideal.eq_of_isPrime_of_le_of_primeHeight_eq_one", "type": "lemma", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R] [IsDomain R] [IsNoetherianRing R]\nomit [IsNoetherianRing R] in\n/-- In a domain, height-0 primes are `⊥`. -/\n\nlemma Ideal.eq_bot_of_primeHeight_eq_zero {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 0) : p = ⊥ := by sorry\nomit [IsNoetherianRing R] in\n/-- In a domain, height-1 primes are nonzero. -/\n\nlemma Ideal.ne_bot_of_primeHeight_eq_one {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 1) : p ≠ ⊥ := by sorry\nomit [IsNoetherianRing R] in\n/-- In a domain, a nonzero prime contained in a height-1 prime must equal it. -/\n\nlemma Ideal.eq_of_isPrime_of_le_of_primeHeight_eq_one {p q : Ideal R}\n [hp : p.IsPrime] [hq : q.IsPrime] (hpne : p ≠ ⊥) (hle : p ≤ q)\n (hht : q.primeHeight = 1) : p = q := by sorry"} -{"project_name": "HeightOnePrimesUfd", "name": "Ideal.isPrincipal_of_primeHeight_eq_one_of_ufd", "type": "lemma", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R] [IsDomain R] [IsNoetherianRing R]\nomit [IsNoetherianRing R] in\n/-- In a domain, height-0 primes are `⊥`. -/\n\nlemma Ideal.eq_bot_of_primeHeight_eq_zero {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 0) : p = ⊥ := by sorry\nomit [IsNoetherianRing R] in\n/-- In a domain, height-1 primes are nonzero. -/\n\nlemma Ideal.ne_bot_of_primeHeight_eq_one {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 1) : p ≠ ⊥ := by sorry\nomit [IsNoetherianRing R] in\n/-- In a domain, a nonzero prime contained in a height-1 prime must equal it. -/\n\nlemma Ideal.eq_of_isPrime_of_le_of_primeHeight_eq_one {p q : Ideal R}\n [hp : p.IsPrime] [hq : q.IsPrime] (hpne : p ≠ ⊥) (hle : p ≤ q)\n (hht : q.primeHeight = 1) : p = q := by sorry\nomit [IsNoetherianRing R] in\n/-- In a UFD, every height-1 prime ideal is principal. -/\n\nlemma Ideal.isPrincipal_of_primeHeight_eq_one_of_ufd [UniqueFactorizationMonoid R]\n {p : Ideal R} [p.IsPrime] (hp : p.primeHeight = 1) : p.IsPrincipal := by sorry"} -{"project_name": "HeightOnePrimesUfd", "name": "Prime.of_irreducible_of_height_one_principal", "type": "lemma", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R] [IsDomain R] [IsNoetherianRing R]\nomit [IsNoetherianRing R] in\n/-- In a domain, height-0 primes are `⊥`. -/\n\nlemma Ideal.eq_bot_of_primeHeight_eq_zero {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 0) : p = ⊥ := by sorry\nomit [IsNoetherianRing R] in\n/-- In a domain, height-1 primes are nonzero. -/\n\nlemma Ideal.ne_bot_of_primeHeight_eq_one {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 1) : p ≠ ⊥ := by sorry\nomit [IsNoetherianRing R] in\n/-- In a domain, a nonzero prime contained in a height-1 prime must equal it. -/\n\nlemma Ideal.eq_of_isPrime_of_le_of_primeHeight_eq_one {p q : Ideal R}\n [hp : p.IsPrime] [hq : q.IsPrime] (hpne : p ≠ ⊥) (hle : p ≤ q)\n (hht : q.primeHeight = 1) : p = q := by sorry\nomit [IsNoetherianRing R] in\n/-- In a UFD, every height-1 prime ideal is principal. -/\n\nlemma Ideal.isPrincipal_of_primeHeight_eq_one_of_ufd [UniqueFactorizationMonoid R]\n {p : Ideal R} [p.IsPrime] (hp : p.primeHeight = 1) : p.IsPrincipal := by sorry\n/-- If every height-1 prime in a Noetherian domain is principal, then every\nirreducible element is prime. -/\n\nlemma Prime.of_irreducible_of_height_one_principal\n (hall : ∀ (I : Ideal R) [I.IsPrime], I.primeHeight = 1 → I.IsPrincipal)\n {x : R} (hx : Irreducible x) : Prime x := by sorry"} -{"project_name": "HeightOnePrimesUfd", "name": "Ideal.ufd_iff_height_one_primes_principal", "type": "theorem", "code": "import Mathlib\n\nopen Ideal\n\nvariable {R : Type*} [CommRing R] [IsDomain R] [IsNoetherianRing R]\n/-- **Stacks 0AFT** (Lemma 10.120.6).\nA Noetherian domain is a UFD iff every height-1 prime ideal is principal. -/\n\ntheorem Ideal.ufd_iff_height_one_primes_principal :\n UniqueFactorizationMonoid R ↔\n ∀ (p : Ideal R) [p.IsPrime], p.primeHeight = 1 → p.IsPrincipal := by sorry", "imported_file": "-- File: LiveLeanTriathlon.HeightOnePrimesUfd.BackgroundLemmas\nopen Ideal\nvariable {R : Type*} [CommRing R] [IsDomain R] [IsNoetherianRing R]\nomit [IsNoetherianRing R] in\n/-- In a domain, height-0 primes are `⊥`. -/\nlemma Ideal.eq_bot_of_primeHeight_eq_zero {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 0) : p = ⊥ := by sorry\nomit [IsNoetherianRing R] in\n/-- In a domain, height-1 primes are nonzero. -/\nlemma Ideal.ne_bot_of_primeHeight_eq_one {p : Ideal R} [p.IsPrime]\n (hp : p.primeHeight = 1) : p ≠ ⊥ := by sorry\nomit [IsNoetherianRing R] in\n/-- In a domain, a nonzero prime contained in a height-1 prime must equal it. -/\nlemma Ideal.eq_of_isPrime_of_le_of_primeHeight_eq_one {p q : Ideal R}\n [hp : p.IsPrime] [hq : q.IsPrime] (hpne : p ≠ ⊥) (hle : p ≤ q)\n (hht : q.primeHeight = 1) : p = q := by sorry\nomit [IsNoetherianRing R] in\n/-- In a UFD, every height-1 prime ideal is principal. -/\nlemma Ideal.isPrincipal_of_primeHeight_eq_one_of_ufd [UniqueFactorizationMonoid R]\n {p : Ideal R} [p.IsPrime] (hp : p.primeHeight = 1) : p.IsPrincipal := by sorry\n/-- If every height-1 prime in a Noetherian domain is principal, then every\nirreducible element is prime. -/\nlemma Prime.of_irreducible_of_height_one_principal\n (hall : ∀ (I : Ideal R) [I.IsPrime], I.primeHeight = 1 → I.IsPrincipal)\n {x : R} (hx : Irreducible x) : Prime x := by sorry"} -{"project_name": "Hinge", "name": "hinge_forward", "type": "theorem", "code": "import Mathlib\n\nopen Real EuclideanGeometry\n/-- Hinge Theorem (SAS Inequality):\n If two sides of one triangle are congruent to two sides of another triangle,\n and the included angle of the first is larger than the included angle of the second,\n then the third side of the first triangle is longer than the third side of the second triangle. -/\n\ntheorem hinge_forward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hangle : C₁ > C₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n c₁ > c₂ := by sorry"} -{"project_name": "Hinge", "name": "hinge_backward", "type": "theorem", "code": "import Mathlib\n\nopen Real EuclideanGeometry\n/-- Hinge Theorem (SAS Inequality):\n If two sides of one triangle are congruent to two sides of another triangle,\n and the included angle of the first is larger than the included angle of the second,\n then the third side of the first triangle is longer than the third side of the second triangle. -/\n\ntheorem hinge_forward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hangle : C₁ > C₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n c₁ > c₂ := by sorry\n/-- Converse of the Hinge Theorem (SSS Inequality):\n If two sides of one triangle are congruent to two sides of another triangle,\n and the third side of the first is longer than the third side of the second,\n then the included angle of the first triangle is larger than the included angle of the second triangle. -/\n\ntheorem hinge_backward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hside : c₁ > c₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n C₁ > C₂ := by sorry"} -{"project_name": "Hinge", "name": "hinge_iff", "type": "theorem", "code": "import Mathlib\n\nopen Real EuclideanGeometry\n/-- Hinge Theorem (SAS Inequality):\n If two sides of one triangle are congruent to two sides of another triangle,\n and the included angle of the first is larger than the included angle of the second,\n then the third side of the first triangle is longer than the third side of the second triangle. -/\n\ntheorem hinge_forward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hangle : C₁ > C₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n c₁ > c₂ := by sorry\n/-- Converse of the Hinge Theorem (SSS Inequality):\n If two sides of one triangle are congruent to two sides of another triangle,\n and the third side of the first is longer than the third side of the second,\n then the included angle of the first triangle is larger than the included angle of the second triangle. -/\n\ntheorem hinge_backward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hside : c₁ > c₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n C₁ > C₂ := by sorry\n/-- Hinge Theorem (if and only if):\n Given two triangles with two sides of equal length (a and b),\n the included angle of the first triangle is larger than the included angle of the second\n if and only if the third side of the first triangle is longer than the third side of the second. -/\n\ntheorem hinge_iff {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n C₁ > C₂ ↔ c₁ > c₂ := by sorry"} -{"project_name": "Hinge", "name": "hinge_iff_geometric", "type": "theorem", "code": "import Mathlib\n\nopen Real EuclideanGeometry\n/-- Hinge Theorem (SAS Inequality):\n If two sides of one triangle are congruent to two sides of another triangle,\n and the included angle of the first is larger than the included angle of the second,\n then the third side of the first triangle is longer than the third side of the second triangle. -/\n\ntheorem hinge_forward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hangle : C₁ > C₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n c₁ > c₂ := by sorry\n/-- Converse of the Hinge Theorem (SSS Inequality):\n If two sides of one triangle are congruent to two sides of another triangle,\n and the third side of the first is longer than the third side of the second,\n then the included angle of the first triangle is larger than the included angle of the second triangle. -/\n\ntheorem hinge_backward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hside : c₁ > c₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n C₁ > C₂ := by sorry\n/-- Hinge Theorem (if and only if):\n Given two triangles with two sides of equal length (a and b),\n the included angle of the first triangle is larger than the included angle of the second\n if and only if the third side of the first triangle is longer than the third side of the second. -/\n\ntheorem hinge_iff {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n C₁ > C₂ ↔ c₁ > c₂ := by sorry\n\nvariable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]\n [NormedAddTorsor V P]\n/-- Geometric Hinge Theorem (if and only if):\n Given two triangles with a common vertex and two pairs of sides of equal length,\n the angle at the common vertex in the first triangle is larger than the angle in the second\n if and only if the opposite side in the first triangle is longer than the opposite side\n in the second. -/\n\ntheorem hinge_iff_geometric (A B₁ B₂ C₁ C₂ : P)\n (hab₁ : dist A B₁ = dist A B₂)\n (hac₁ : dist A C₁ = dist A C₂)\n (hb₁c₁ : B₁ ≠ C₁) (hb₂c₂ : B₂ ≠ C₂)\n (hab₁_ne : A ≠ B₁) (hac₁_ne : A ≠ C₁) :\n angle B₁ A C₁ > angle B₂ A C₂ ↔ dist B₁ C₁ > dist B₂ C₂ := by sorry"} -{"project_name": "HurwitzApproximation", "name": "cf_irrational_not_terminatedAt", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry"} -{"project_name": "HurwitzApproximation", "name": "cf_den_pos", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry"} -{"project_name": "HurwitzApproximation", "name": "cf_den_recurrence_ineq", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "cf_den_lt_skip", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "cf_contsAux_int", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry"} -{"project_name": "HurwitzApproximation", "name": "cf_num_is_int", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "cf_den_is_int", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "convergent_den_eq_cf_den", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry"} -{"project_name": "HurwitzApproximation", "name": "consecutive_convs_bracket", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry"} -{"project_name": "HurwitzApproximation", "name": "consecutive_convs_diff", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "triangle_identity", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "quadratic_le_golden", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry"} -{"project_name": "HurwitzApproximation", "name": "ratio_squeeze", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry"} -{"project_name": "HurwitzApproximation", "name": "golden_ratio_not_int_ratio", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry"} -{"project_name": "HurwitzApproximation", "name": "ratio_bound_of_not_hurwitz", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry"} -{"project_name": "HurwitzApproximation", "name": "ratio_le_golden_of_not_hurwitz", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry\n/-- Auxiliary: from `ratio_bound_of_not_hurwitz`, the ratio `B_{n+1}/B_n ≤ φ`. -/\n\nlemma ratio_le_golden_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio := by sorry"} -{"project_name": "HurwitzApproximation", "name": "ratio_ge_golden_of_recurrence", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry\n/-- Auxiliary: from `ratio_bound_of_not_hurwitz`, the ratio `B_{n+1}/B_n ≤ φ`. -/\n\nlemma ratio_le_golden_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio := by sorry\n/-- Auxiliary: from the recurrence and golden ratio bound, we get\n `B_{n+2}/B_{n+1} ≥ φ`. -/\n\nlemma ratio_ge_golden_of_recurrence (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (hr : (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio) :\n Real.goldenRatio ≤\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "ratio_le_golden_of_not_hurwitz'", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry\n/-- Auxiliary: from `ratio_bound_of_not_hurwitz`, the ratio `B_{n+1}/B_n ≤ φ`. -/\n\nlemma ratio_le_golden_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio := by sorry\n/-- Auxiliary: from the recurrence and golden ratio bound, we get\n `B_{n+2}/B_{n+1} ≥ φ`. -/\n\nlemma ratio_ge_golden_of_recurrence (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (hr : (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio) :\n Real.goldenRatio ≤\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) := by sorry\n/-- Auxiliary: similarly `B_{n+2}/B_{n+1} ≤ φ` from the Hurwitz-bound hypothesis\n on the `(n+1, n+2)` pair. -/\n\nlemma ratio_le_golden_of_not_hurwitz' (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2))\n (h_n2 : ¬|ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) ≤\n Real.goldenRatio := by sorry"} -{"project_name": "HurwitzApproximation", "name": "three_consecutive_one_hurwitz", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry\n/-- Auxiliary: from `ratio_bound_of_not_hurwitz`, the ratio `B_{n+1}/B_n ≤ φ`. -/\n\nlemma ratio_le_golden_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio := by sorry\n/-- Auxiliary: from the recurrence and golden ratio bound, we get\n `B_{n+2}/B_{n+1} ≥ φ`. -/\n\nlemma ratio_ge_golden_of_recurrence (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (hr : (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio) :\n Real.goldenRatio ≤\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) := by sorry\n/-- Auxiliary: similarly `B_{n+2}/B_{n+1} ≤ φ` from the Hurwitz-bound hypothesis\n on the `(n+1, n+2)` pair. -/\n\nlemma ratio_le_golden_of_not_hurwitz' (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2))\n (h_n2 : ¬|ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) ≤\n Real.goldenRatio := by sorry\n/-- The key lemma: among any three consecutive convergents, at least one\n satisfies the Hurwitz bound `|ξ - q| < 1/(√5 * q.den²)`. -/\n\nlemma three_consecutive_one_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "convergents_injective", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry\n/-- Auxiliary: from `ratio_bound_of_not_hurwitz`, the ratio `B_{n+1}/B_n ≤ φ`. -/\n\nlemma ratio_le_golden_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio := by sorry\n/-- Auxiliary: from the recurrence and golden ratio bound, we get\n `B_{n+2}/B_{n+1} ≥ φ`. -/\n\nlemma ratio_ge_golden_of_recurrence (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (hr : (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio) :\n Real.goldenRatio ≤\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) := by sorry\n/-- Auxiliary: similarly `B_{n+2}/B_{n+1} ≤ φ` from the Hurwitz-bound hypothesis\n on the `(n+1, n+2)` pair. -/\n\nlemma ratio_le_golden_of_not_hurwitz' (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2))\n (h_n2 : ¬|ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) ≤\n Real.goldenRatio := by sorry\n/-- The key lemma: among any three consecutive convergents, at least one\n satisfies the Hurwitz bound `|ξ - q| < 1/(√5 * q.den²)`. -/\n\nlemma three_consecutive_one_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2) := by sorry\n/-- Convergents of an irrational are injective (distinct indices give distinct rationals). -/\n\nlemma convergents_injective (ξ : ℝ) (hξ : Irrational ξ) :\n Function.Injective (ξ.convergent) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "hurwitz_candidate", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry\n/-- Auxiliary: from `ratio_bound_of_not_hurwitz`, the ratio `B_{n+1}/B_n ≤ φ`. -/\n\nlemma ratio_le_golden_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio := by sorry\n/-- Auxiliary: from the recurrence and golden ratio bound, we get\n `B_{n+2}/B_{n+1} ≥ φ`. -/\n\nlemma ratio_ge_golden_of_recurrence (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (hr : (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio) :\n Real.goldenRatio ≤\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) := by sorry\n/-- Auxiliary: similarly `B_{n+2}/B_{n+1} ≤ φ` from the Hurwitz-bound hypothesis\n on the `(n+1, n+2)` pair. -/\n\nlemma ratio_le_golden_of_not_hurwitz' (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2))\n (h_n2 : ¬|ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) ≤\n Real.goldenRatio := by sorry\n/-- The key lemma: among any three consecutive convergents, at least one\n satisfies the Hurwitz bound `|ξ - q| < 1/(√5 * q.den²)`. -/\n\nlemma three_consecutive_one_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2) := by sorry\n/-- Convergents of an irrational are injective (distinct indices give distinct rationals). -/\n\nlemma convergents_injective (ξ : ℝ) (hξ : Irrational ξ) :\n Function.Injective (ξ.convergent) := by sorry\n/-- For each `n`, at least one of `convergent(3n)`, `convergent(3n+1)`, or `convergent(3n+2)`\n is in the Hurwitz set. This gives a function from `ℕ` into the Hurwitz set. -/\n\nlemma hurwitz_candidate (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ∃ k, k ∈ ({3 * n, 3 * n + 1, 3 * n + 2} : Set ℕ) ∧\n |ξ - ↑(ξ.convergent k)| < 1 / (√5 * ((ξ.convergent k).den : ℝ) ^ 2) := by sorry"} -{"project_name": "HurwitzApproximation", "name": "hurwitz_indices_infinite", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry\n/-- Auxiliary: from `ratio_bound_of_not_hurwitz`, the ratio `B_{n+1}/B_n ≤ φ`. -/\n\nlemma ratio_le_golden_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio := by sorry\n/-- Auxiliary: from the recurrence and golden ratio bound, we get\n `B_{n+2}/B_{n+1} ≥ φ`. -/\n\nlemma ratio_ge_golden_of_recurrence (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (hr : (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio) :\n Real.goldenRatio ≤\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) := by sorry\n/-- Auxiliary: similarly `B_{n+2}/B_{n+1} ≤ φ` from the Hurwitz-bound hypothesis\n on the `(n+1, n+2)` pair. -/\n\nlemma ratio_le_golden_of_not_hurwitz' (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2))\n (h_n2 : ¬|ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) ≤\n Real.goldenRatio := by sorry\n/-- The key lemma: among any three consecutive convergents, at least one\n satisfies the Hurwitz bound `|ξ - q| < 1/(√5 * q.den²)`. -/\n\nlemma three_consecutive_one_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2) := by sorry\n/-- Convergents of an irrational are injective (distinct indices give distinct rationals). -/\n\nlemma convergents_injective (ξ : ℝ) (hξ : Irrational ξ) :\n Function.Injective (ξ.convergent) := by sorry\n/-- For each `n`, at least one of `convergent(3n)`, `convergent(3n+1)`, or `convergent(3n+2)`\n is in the Hurwitz set. This gives a function from `ℕ` into the Hurwitz set. -/\n\nlemma hurwitz_candidate (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ∃ k, k ∈ ({3 * n, 3 * n + 1, 3 * n + 2} : Set ℕ) ∧\n |ξ - ↑(ξ.convergent k)| < 1 / (√5 * ((ξ.convergent k).den : ℝ) ^ 2) := by sorry\n/-- The set of convergent indices whose convergent satisfies the Hurwitz bound is infinite. -/\n\nlemma hurwitz_indices_infinite (ξ : ℝ) (hξ : Irrational ξ) :\n {n : ℕ | |ξ - ↑(ξ.convergent n)| <\n 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2)}.Infinite := by sorry"} -{"project_name": "HurwitzApproximation", "name": "hurwitz_set_infinite", "type": "lemma", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry\n/-- Auxiliary: from `ratio_bound_of_not_hurwitz`, the ratio `B_{n+1}/B_n ≤ φ`. -/\n\nlemma ratio_le_golden_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio := by sorry\n/-- Auxiliary: from the recurrence and golden ratio bound, we get\n `B_{n+2}/B_{n+1} ≥ φ`. -/\n\nlemma ratio_ge_golden_of_recurrence (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (hr : (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio) :\n Real.goldenRatio ≤\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) := by sorry\n/-- Auxiliary: similarly `B_{n+2}/B_{n+1} ≤ φ` from the Hurwitz-bound hypothesis\n on the `(n+1, n+2)` pair. -/\n\nlemma ratio_le_golden_of_not_hurwitz' (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2))\n (h_n2 : ¬|ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) ≤\n Real.goldenRatio := by sorry\n/-- The key lemma: among any three consecutive convergents, at least one\n satisfies the Hurwitz bound `|ξ - q| < 1/(√5 * q.den²)`. -/\n\nlemma three_consecutive_one_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2) := by sorry\n/-- Convergents of an irrational are injective (distinct indices give distinct rationals). -/\n\nlemma convergents_injective (ξ : ℝ) (hξ : Irrational ξ) :\n Function.Injective (ξ.convergent) := by sorry\n/-- For each `n`, at least one of `convergent(3n)`, `convergent(3n+1)`, or `convergent(3n+2)`\n is in the Hurwitz set. This gives a function from `ℕ` into the Hurwitz set. -/\n\nlemma hurwitz_candidate (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ∃ k, k ∈ ({3 * n, 3 * n + 1, 3 * n + 2} : Set ℕ) ∧\n |ξ - ↑(ξ.convergent k)| < 1 / (√5 * ((ξ.convergent k).den : ℝ) ^ 2) := by sorry\n/-- The set of convergent indices whose convergent satisfies the Hurwitz bound is infinite. -/\n\nlemma hurwitz_indices_infinite (ξ : ℝ) (hξ : Irrational ξ) :\n {n : ℕ | |ξ - ↑(ξ.convergent n)| <\n 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2)}.Infinite := by sorry\n/-- The image of infinitely many convergents under `ξ.convergent` gives infinitely many\n rationals in the Hurwitz set. -/\n\nlemma hurwitz_set_infinite (ξ : ℝ) (hξ : Irrational ξ) :\n {q : ℚ | |ξ - ↑q| < 1 / (√5 * (q.den : ℝ) ^ 2)}.Infinite := by sorry"} -{"project_name": "HurwitzApproximation", "name": "hurwitz_approximation", "type": "theorem", "code": "import Mathlib\n\nopen Real GenContFract Set\nnoncomputable section\n/-- The continued fraction of an irrational number does not terminate at any `n`. -/\n\nlemma cf_irrational_not_terminatedAt (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ¬(GenContFract.of ξ).TerminatedAt n := by sorry\n/-- The denominator `Bₙ` of the continued fraction of an irrational number is positive. -/\n\nlemma cf_den_pos (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (0 : ℝ) < (GenContFract.of ξ).dens n := by sorry\n/-- The denominators satisfy `B_{n+2} ≥ B_{n+1} + B_n` for the CF of an irrational. -/\n\nlemma cf_den_recurrence_ineq (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n + (GenContFract.of ξ).dens (n + 1) ≤\n (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The CF denominators satisfy `dens n < dens (n + 2)` for irrationals. -/\n\nlemma cf_den_lt_skip (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (GenContFract.of ξ).dens n < (GenContFract.of ξ).dens (n + 2) := by sorry\n/-- The continuants of `GenContFract.of ξ` are integer-valued. -/\nprivate lemma cf_contsAux_int (ξ : ℝ) (n : ℕ) :\n ∃ A B : ℤ, (GenContFract.of ξ).contsAux n = ⟨(A : ℝ), (B : ℝ)⟩ := by sorry\nprivate lemma cf_num_is_int (ξ : ℝ) (n : ℕ) :\n ∃ A : ℤ, (GenContFract.of ξ).nums n = (A : ℝ) := by sorry\nprivate lemma cf_den_is_int (ξ : ℝ) (n : ℕ) :\n ∃ B : ℤ, (GenContFract.of ξ).dens n = (B : ℝ) := by sorry\n/-- For an irrational `ξ`, the denominator of the rational convergent equals\n the CF denominator: `(ξ.convergent n).den = B_n` (both cast to ℝ). -/\n\nlemma convergent_den_eq_cf_den (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ((ξ.convergent n).den : ℝ) = (GenContFract.of ξ).dens n := by sorry\n/-- Consecutive convergents of an irrational bracket `ξ`:\n `ξ` lies strictly between `c_n` and `c_{n+1}`. This means the errors\n `(ξ - c_n)` and `(ξ - c_{n+1})` have opposite signs. -/\n\nlemma consecutive_convs_bracket (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n (ξ - ↑(ξ.convergent n)) * (ξ - ↑(ξ.convergent (n + 1))) < 0 := by sorry\n/-- The absolute difference of consecutive convergents equals `1 / (B_n * B_{n+1})`. -/\n\nlemma consecutive_convs_diff (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |(↑(ξ.convergent n) : ℝ) - (↑(ξ.convergent (n + 1)) : ℝ)| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- The triangle identity: since consecutive convergents bracket `ξ`,\n `|ξ - c_n| + |ξ - c_{n+1}| = |c_n - c_{n+1}| = 1 / (B_n * B_{n+1})`. -/\n\nlemma triangle_identity (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| + |ξ - ↑(ξ.convergent (n + 1))| =\n 1 / ((GenContFract.of ξ).dens n * (GenContFract.of ξ).dens (n + 1)) := by sorry\n/-- If `r > 0` and `r + 1/r ≤ √5`, then `r² - √5 * r + 1 ≤ 0`,\n which implies `1/φ ≤ r ≤ φ`. -/\n\nlemma quadratic_le_golden (r : ℝ) (hr : 0 < r) (h : r + 1 / r ≤ √5) :\n r ≤ Real.goldenRatio := by sorry\n/-- If `r ≤ φ` and `r > 0`, then `1 + 1/r ≥ φ`. -/\n\nlemma ratio_squeeze (r : ℝ) (hr : 0 < r) (hrφ : r ≤ Real.goldenRatio) :\n Real.goldenRatio ≤ 1 + 1 / r := by sorry\n/-- It is impossible for two positive integers to have ratio exactly `φ`. -/\n\nlemma golden_ratio_not_int_ratio (a b : ℕ)\n (h : (b : ℝ) / (a : ℝ) = Real.goldenRatio) : False := by sorry\n/-- Auxiliary: if neither of two consecutive convergents satisfies the Hurwitz bound,\n then the ratio `B_{n+1}/B_n + B_n/B_{n+1} ≤ √5`. -/\n\nlemma ratio_bound_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n let B_n := (GenContFract.of ξ).dens n\n let B_n1 := (GenContFract.of ξ).dens (n + 1)\n B_n1 / B_n + B_n / B_n1 ≤ √5 := by sorry\n/-- Auxiliary: from `ratio_bound_of_not_hurwitz`, the ratio `B_{n+1}/B_n ≤ φ`. -/\n\nlemma ratio_le_golden_of_not_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n : ¬|ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2))\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio := by sorry\n/-- Auxiliary: from the recurrence and golden ratio bound, we get\n `B_{n+2}/B_{n+1} ≥ φ`. -/\n\nlemma ratio_ge_golden_of_recurrence (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (hr : (GenContFract.of ξ).dens (n + 1) / (GenContFract.of ξ).dens n ≤\n Real.goldenRatio) :\n Real.goldenRatio ≤\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) := by sorry\n/-- Auxiliary: similarly `B_{n+2}/B_{n+1} ≤ φ` from the Hurwitz-bound hypothesis\n on the `(n+1, n+2)` pair. -/\n\nlemma ratio_le_golden_of_not_hurwitz' (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ)\n (h_n1 : ¬|ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2))\n (h_n2 : ¬|ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2)) :\n (GenContFract.of ξ).dens (n + 2) / (GenContFract.of ξ).dens (n + 1) ≤\n Real.goldenRatio := by sorry\n/-- The key lemma: among any three consecutive convergents, at least one\n satisfies the Hurwitz bound `|ξ - q| < 1/(√5 * q.den²)`. -/\n\nlemma three_consecutive_one_hurwitz (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n |ξ - ↑(ξ.convergent n)| < 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 1))| <\n 1 / (√5 * ((ξ.convergent (n + 1)).den : ℝ) ^ 2) ∨\n |ξ - ↑(ξ.convergent (n + 2))| <\n 1 / (√5 * ((ξ.convergent (n + 2)).den : ℝ) ^ 2) := by sorry\n/-- Convergents of an irrational are injective (distinct indices give distinct rationals). -/\n\nlemma convergents_injective (ξ : ℝ) (hξ : Irrational ξ) :\n Function.Injective (ξ.convergent) := by sorry\n/-- For each `n`, at least one of `convergent(3n)`, `convergent(3n+1)`, or `convergent(3n+2)`\n is in the Hurwitz set. This gives a function from `ℕ` into the Hurwitz set. -/\n\nlemma hurwitz_candidate (ξ : ℝ) (hξ : Irrational ξ) (n : ℕ) :\n ∃ k, k ∈ ({3 * n, 3 * n + 1, 3 * n + 2} : Set ℕ) ∧\n |ξ - ↑(ξ.convergent k)| < 1 / (√5 * ((ξ.convergent k).den : ℝ) ^ 2) := by sorry\n/-- The set of convergent indices whose convergent satisfies the Hurwitz bound is infinite. -/\n\nlemma hurwitz_indices_infinite (ξ : ℝ) (hξ : Irrational ξ) :\n {n : ℕ | |ξ - ↑(ξ.convergent n)| <\n 1 / (√5 * ((ξ.convergent n).den : ℝ) ^ 2)}.Infinite := by sorry\n/-- The image of infinitely many convergents under `ξ.convergent` gives infinitely many\n rationals in the Hurwitz set. -/\n\nlemma hurwitz_set_infinite (ξ : ℝ) (hξ : Irrational ξ) :\n {q : ℚ | |ξ - ↑q| < 1 / (√5 * (q.den : ℝ) ^ 2)}.Infinite := by sorry\n/--\nHurwitz approximation in number theory states that for any irrational number ξ\nthere are infinitely many relatively prime integers p and q such that\n|ξ - p/q| < 1/(√5 * q^2).\nFor proof see Hardy and Wright's An Introduction to the Theory of Numbers, chapter 11.\n-/\n\ntheorem hurwitz_approximation (ξ : ℝ) (hξ : Irrational ξ) :\n { q : ℚ | |ξ - q| < 1 / (sqrt 5 * q.den ^ 2) }.Infinite := by sorry"} -{"project_name": "InverseEigenvalue", "name": "Module.End.inv_eigenvalue_iff", "type": "theorem", "code": "import Mathlib\nassert_not_exists Module.End.inv_eigenvalue_iff Matrix.GeneralLinearGroup.inv_eigenvalue\n\ntheorem Module.End.inv_eigenvalue_iff {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]\n (r : Rˣ) (f : M ≃ₗ[R] M) : Module.End.HasEigenvalue f.toLinearMap r ↔\n Module.End.HasEigenvalue f⁻¹.toLinearMap r⁻¹.1 := by sorry"} -{"project_name": "JacobiFourSquareTheorem", "name": "jacobi", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n/-- Jacobi's four-square theorem\nhttps://en.wikipedia.org/wiki/Jacobi%27s_four-square_theorem -/\n\ntheorem jacobi (n : ℕ) : {a : Fin 4 → ℤ | (↑n : ℤ) = ∑ i : Fin 4, a i}.ncard\n = 8 * ∑' m : {m : ℕ | m ∣ n ∧ ¬ 4 ∣ m}, m.val := by sorry"} -{"project_name": "JacobsonMorozovTheorem", "name": "LieRing.of_assoc_lie_pow_succ", "type": "lemma", "code": "import Mathlib\n\nlemma LieRing.of_assoc_lie_pow_succ (A : Type*) [Ring A] (x y : A) (n : ℕ) :\n ⁅x, y ^ (n + 1)⁆ = ⁅x, y ^ n⁆ * y + y ^ n * ⁅x, y⁆ := by sorry"} -{"project_name": "JacobsonMorozovTheorem", "name": "LieAlgebra.isNilpotent_of_isNilpotent_zero_bracket", "type": "lemma", "code": "import Mathlib\n\nlemma LieRing.of_assoc_lie_pow_succ (A : Type*) [Ring A] (x y : A) (n : ℕ) :\n ⁅x, y ^ (n + 1)⁆ = ⁅x, y ^ n⁆ * y + y ^ n * ⁅x, y⁆ := by sorry\n\nlemma LieAlgebra.isNilpotent_of_isNilpotent_zero_bracket\n {K : Type*} [Field K] [IsAlgClosed K] [CharZero K]\n (V : Type*) [AddCommGroup V] [Module K V]\n [FiniteDimensional K V] (A B : Module.End K V) (hA : IsNilpotent A) (hAB : ⁅A, ⁅A, B⁆⁆ = 0) :\n IsNilpotent (A * B) := by sorry"} -{"project_name": "JacobsonMorozovTheorem", "name": "Sl2.OfAssocAlg1", "type": "lemma", "code": "import Mathlib\n\nlemma LieRing.of_assoc_lie_pow_succ (A : Type*) [Ring A] (x y : A) (n : ℕ) :\n ⁅x, y ^ (n + 1)⁆ = ⁅x, y ^ n⁆ * y + y ^ n * ⁅x, y⁆ := by sorry\n\nlemma LieAlgebra.isNilpotent_of_isNilpotent_zero_bracket\n {K : Type*} [Field K] [IsAlgClosed K] [CharZero K]\n (V : Type*) [AddCommGroup V] [Module K V]\n [FiniteDimensional K V] (A B : Module.End K V) (hA : IsNilpotent A) (hAB : ⁅A, ⁅A, B⁆⁆ = 0) :\n IsNilpotent (A * B) := by sorry\n\nlemma Sl2.OfAssocAlg1 {A : Type*} [Ring A] {h x : A}\n (hx : ⁅h, x⁆ = 2 • x) (n : ℕ) : ⁅h, x ^ n⁆ = (2 * n) • x ^ n := by sorry"} -{"project_name": "JacobsonMorozovTheorem", "name": "Sl2.OfAssocAlg2", "type": "lemma", "code": "import Mathlib\n\nlemma LieRing.of_assoc_lie_pow_succ (A : Type*) [Ring A] (x y : A) (n : ℕ) :\n ⁅x, y ^ (n + 1)⁆ = ⁅x, y ^ n⁆ * y + y ^ n * ⁅x, y⁆ := by sorry\n\nlemma LieAlgebra.isNilpotent_of_isNilpotent_zero_bracket\n {K : Type*} [Field K] [IsAlgClosed K] [CharZero K]\n (V : Type*) [AddCommGroup V] [Module K V]\n [FiniteDimensional K V] (A B : Module.End K V) (hA : IsNilpotent A) (hAB : ⁅A, ⁅A, B⁆⁆ = 0) :\n IsNilpotent (A * B) := by sorry\n\nlemma Sl2.OfAssocAlg1 {A : Type*} [Ring A] {h x : A}\n (hx : ⁅h, x⁆ = 2 • x) (n : ℕ) : ⁅h, x ^ n⁆ = (2 * n) • x ^ n := by sorry\n\nlemma Sl2.OfAssocAlg2 (A : Type*)\n [Ring A]\n (z h x : A) (hx : ⁅h, x⁆ = 2 • x) (hz : ⁅z, x⁆ = h) (n : ℕ) :\n ⁅z, x ^ n⁆ = n • (h - n + 1) * x ^ (n - 1) := by sorry"} -{"project_name": "JacobsonMorozovTheorem", "name": "LieAlgebra.exists_Sl2triple", "type": "lemma", "code": "import Mathlib\n\nlemma LieRing.of_assoc_lie_pow_succ (A : Type*) [Ring A] (x y : A) (n : ℕ) :\n ⁅x, y ^ (n + 1)⁆ = ⁅x, y ^ n⁆ * y + y ^ n * ⁅x, y⁆ := by sorry\n\nlemma LieAlgebra.isNilpotent_of_isNilpotent_zero_bracket\n {K : Type*} [Field K] [IsAlgClosed K] [CharZero K]\n (V : Type*) [AddCommGroup V] [Module K V]\n [FiniteDimensional K V] (A B : Module.End K V) (hA : IsNilpotent A) (hAB : ⁅A, ⁅A, B⁆⁆ = 0) :\n IsNilpotent (A * B) := by sorry\n\nlemma Sl2.OfAssocAlg1 {A : Type*} [Ring A] {h x : A}\n (hx : ⁅h, x⁆ = 2 • x) (n : ℕ) : ⁅h, x ^ n⁆ = (2 * n) • x ^ n := by sorry\n\nlemma Sl2.OfAssocAlg2 (A : Type*)\n [Ring A]\n (z h x : A) (hx : ⁅h, x⁆ = 2 • x) (hz : ⁅z, x⁆ = h) (n : ℕ) :\n ⁅z, x ^ n⁆ = n • (h - n + 1) * x ^ (n - 1) := by sorry\n\nvariable (L : Type*) [LieRing L] [LieAlgebra ℂ L]\n\nopen Submodule in\n\nset_option maxHeartbeats 800000 in\n\nlemma LieAlgebra.exists_Sl2triple [FiniteDimensional ℂ L] {x h : L} (hx : ⁅h, x⁆ = 2 • x)\n (hx_nil : IsNilpotent (LieAlgebra.ad ℂ L x))\n (h1 : h ∈ LinearMap.range (LieAlgebra.ad ℂ L x)) :\n ∃ y : L, (x, h, y) = 0 ∨ IsSl2Triple h x y := by sorry"} -{"project_name": "JacobsonMorozovTheorem", "name": "Jacobson_Morozov", "type": "theorem", "code": "import Mathlib\n\nlemma LieRing.of_assoc_lie_pow_succ (A : Type*) [Ring A] (x y : A) (n : ℕ) :\n ⁅x, y ^ (n + 1)⁆ = ⁅x, y ^ n⁆ * y + y ^ n * ⁅x, y⁆ := by sorry\n\nlemma LieAlgebra.isNilpotent_of_isNilpotent_zero_bracket\n {K : Type*} [Field K] [IsAlgClosed K] [CharZero K]\n (V : Type*) [AddCommGroup V] [Module K V]\n [FiniteDimensional K V] (A B : Module.End K V) (hA : IsNilpotent A) (hAB : ⁅A, ⁅A, B⁆⁆ = 0) :\n IsNilpotent (A * B) := by sorry\n\nlemma Sl2.OfAssocAlg1 {A : Type*} [Ring A] {h x : A}\n (hx : ⁅h, x⁆ = 2 • x) (n : ℕ) : ⁅h, x ^ n⁆ = (2 * n) • x ^ n := by sorry\n\nlemma Sl2.OfAssocAlg2 (A : Type*)\n [Ring A]\n (z h x : A) (hx : ⁅h, x⁆ = 2 • x) (hz : ⁅z, x⁆ = h) (n : ℕ) :\n ⁅z, x ^ n⁆ = n • (h - n + 1) * x ^ (n - 1) := by sorry\n\nvariable (L : Type*) [LieRing L] [LieAlgebra ℂ L]\n\nopen Submodule in\n\nset_option maxHeartbeats 800000 in\n\nlemma LieAlgebra.exists_Sl2triple [FiniteDimensional ℂ L] {x h : L} (hx : ⁅h, x⁆ = 2 • x)\n (hx_nil : IsNilpotent (LieAlgebra.ad ℂ L x))\n (h1 : h ∈ LinearMap.range (LieAlgebra.ad ℂ L x)) :\n ∃ y : L, (x, h, y) = 0 ∨ IsSl2Triple h x y := by sorry\n\ntheorem Jacobson_Morozov (x : L) [FiniteDimensional ℂ L] [hL : LieAlgebra.IsSemisimple ℂ L]\n (hx0 : x ≠ 0) (hx : IsNilpotent (LieAlgebra.ad ℂ L x)) : ∃ h y : L, IsSl2Triple h x y := by sorry"} -{"project_name": "JonesLemma", "name": "jones", "type": "theorem", "code": "import Mathlib\n\nopen TopologicalSpace Cardinal Set\n/-- **Jones' Lemma**: Let `X` be a normal and separable space. Let `Y` be a discrete and closed\nsubspace of `X`. Then `2 ^ #Y ≤ 𝔠`.\n-/\n\ntheorem jones {X : Type*} [TopologicalSpace X] [SeparableSpace X] [NormalSpace X] {Y : Set X}\n (hc : IsClosed Y) (hd : IsDiscrete Y) : 2 ^ #Y ≤ 𝔠 := by sorry"} -{"project_name": "JordanSchurTheorem", "name": "jordan_schur", "type": "theorem", "code": "import Mathlib\n\nopen Function Set Matrix Group\n\nvariable (n : ℕ)\n/-- A subgroup being abelian -/\n\nstructure Subgroup.Abelian (G : Type*) [Group G] (H : Subgroup G) : Prop where\n /-- `H` is abelian -/\n mul_comm : ∀ᵉ (a ∈ H) (b ∈ H), a * b = b * a\n\ntheorem jordan_schur : ∃ f : ℕ → ℝ, ∀ n : ℕ, ∀ G : Subgroup (GeneralLinearGroup (Fin n) ℂ),\n Finite G → ∃ H : Subgroup G, H.Normal ∧ H.Abelian ∧ H.index ≤ f n := by sorry"} -{"project_name": "Joubert", "name": "exists_generator_of_minpoly_with_some_zero_coeffs", "type": "theorem", "code": "import Mathlib\n\nopen Polynomial\n/--\nIf $K$ and $L$ are fields, $L$ is a separable field extension of $K$ of degree $6$, and the characteristic of $K$ is not equal to 2, then $L$ is generated over $K$ by some element $\\lambda$ in $L$, such that the minimal polynomial $p$ of $\\lambda$ has the form $p(t) = t^6 + c_4t^4 + c_2t^2 + c_1t + c_0$, for some constants $c_4, c_2, c_1, c_0$ in $K$.\n-/\n\ntheorem exists_generator_of_minpoly_with_some_zero_coeffs (K L : Type*) (p : ℕ)\n [Field K] [Field L] [Algebra K L] [Algebra.IsSeparable K L] [CharP K p] [Fact (2 < p)]\n (h : Field.sepDegree K L = 6) :\n ∃ a : L, L = Algebra.adjoin K {a} ∧\n (∃ c4 c2 c1 c0 : K, minpoly K a = X ^ 6 + C c4 * X ^ 4 + C c2 * X ^ 2 + C c1 * X + C c0) := by sorry"} -{"project_name": "KaplanskyTheoremOnQuadraticForms", "name": "kaplansky_one", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n/-- Kaplansky theorem for `1 ≡ p (mod 16)` -/\n\ntheorem kaplansky_one {p : ℕ} (hp : p.Prime) (hp' : p ≡ 1 [MOD 16]) :\n (∃ x y : ℕ, p = x ^ 2 + 32 * y ^ 2) ↔ ∃ x y : ℕ, p = x ^ 2 + 64 * y ^ 2 := by sorry"} -{"project_name": "KaplanskyTheoremOnQuadraticForms", "name": "kaplansky_two", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n/-- Kaplansky theorem for `1 ≡ p (mod 16)` -/\n\ntheorem kaplansky_one {p : ℕ} (hp : p.Prime) (hp' : p ≡ 1 [MOD 16]) :\n (∃ x y : ℕ, p = x ^ 2 + 32 * y ^ 2) ↔ ∃ x y : ℕ, p = x ^ 2 + 64 * y ^ 2 := by sorry\n/-- Kaplansky theorem for `9 ≡ p (mod 16)` -/\n\ntheorem kaplansky_two {p : ℕ} (hp : p.Prime) (hp' : p ≡ 9 [MOD 16]) :\n ∃! t, (t = 32 ∨ t = 64) ∧ ∃ x y : ℕ, p = x ^ 2 + t * y ^ 2 := by sorry"} -{"project_name": "KoebeQuarterTheorem", "name": "koebe", "type": "theorem", "code": "import Mathlib\n\nopen Set Metric\n\ntheorem koebe {f : ℂ → ℂ} (f_inj : InjOn f (ball 0 1)) (f_diff : DifferentiableOn ℂ f (ball 0 1)) :\n ball (f 0) (‖deriv f 0‖ / 4) ⊆ f '' (ball 0 1) := by sorry"} -{"project_name": "KolmogorovThreeSeriesNecessary", "name": "martingale_sq_sum_sub_sum_integral_sq", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\nlemma martingale_sq_sum_sub_sum_integral_sq\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n))\n (X_memL2 : ∀ n, MemLp (X n) 2 P) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›)\n (fun n ↦ ((∑ i ∈ Finset.range n, X i)^2\n - fun ω ↦ ∑ i ∈ Finset.range n, ∫ ω, (X i ω)^2 ∂P))\n (Filtration.naturalLT X (by measurability) ) P := by sorry"} -{"project_name": "KolmogorovThreeSeriesNecessary", "name": "tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_integral_zero_of_forall_bounded", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\nlemma martingale_sq_sum_sub_sum_integral_sq\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n))\n (X_memL2 : ∀ n, MemLp (X n) 2 P) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›)\n (fun n ↦ ((∑ i ∈ Finset.range n, X i)^2\n - fun ω ↦ ∑ i ∈ Finset.range n, ∫ ω, (X i ω)^2 ∂P))\n (Filtration.naturalLT X (by measurability) ) P := by sorry\n\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_integral_zero_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b)) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry"} -{"project_name": "KolmogorovThreeSeriesNecessary", "name": "tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_bounded", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\nlemma martingale_sq_sum_sub_sum_integral_sq\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n))\n (X_memL2 : ∀ n, MemLp (X n) 2 P) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›)\n (fun n ↦ ((∑ i ∈ Finset.range n, X i)^2\n - fun ω ↦ ∑ i ∈ Finset.range n, ∫ ω, (X i ω)^2 ∂P))\n (Filtration.naturalLT X (by measurability) ) P := by sorry\n\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_integral_zero_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b)) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry\n\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry"} -{"project_name": "KolmogorovThreeSeriesNecessary", "name": "exists_tendsto_sum_integral_of_exists_ae_tendsto_of_forall_bounded", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\nlemma martingale_sq_sum_sub_sum_integral_sq\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n))\n (X_memL2 : ∀ n, MemLp (X n) 2 P) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›)\n (fun n ↦ ((∑ i ∈ Finset.range n, X i)^2\n - fun ω ↦ ∑ i ∈ Finset.range n, ∫ ω, (X i ω)^2 ∂P))\n (Filtration.naturalLT X (by measurability) ) P := by sorry\n\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_integral_zero_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b)) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry\n\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry\n\nlemma exists_tendsto_sum_integral_of_exists_ae_tendsto_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, X n ω ∂P) atTop (𝓝 s) := by sorry"} -{"project_name": "KolmogorovThreeSeriesNecessary", "name": "kolmogorov_three_series_necessity_a", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\nlemma martingale_sq_sum_sub_sum_integral_sq\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n))\n (X_memL2 : ∀ n, MemLp (X n) 2 P) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›)\n (fun n ↦ ((∑ i ∈ Finset.range n, X i)^2\n - fun ω ↦ ∑ i ∈ Finset.range n, ∫ ω, (X i ω)^2 ∂P))\n (Filtration.naturalLT X (by measurability) ) P := by sorry\n\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_integral_zero_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b)) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry\n\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry\n\nlemma exists_tendsto_sum_integral_of_exists_ae_tendsto_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, X n ω ∂P) atTop (𝓝 s) := by sorry\nomit [IsProbabilityMeasure P] in\n\nlemma kolmogorov_three_series_necessity_a\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s))\n {b : ℝ} (b_pos : 0 < b) :\n ∑' n, P {ω | b < |X n ω|} ≠ ∞ := by sorry"} -{"project_name": "KolmogorovThreeSeriesNecessary", "name": "kolmogorov_three_series_necessity_b", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\nlemma martingale_sq_sum_sub_sum_integral_sq\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n))\n (X_memL2 : ∀ n, MemLp (X n) 2 P) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›)\n (fun n ↦ ((∑ i ∈ Finset.range n, X i)^2\n - fun ω ↦ ∑ i ∈ Finset.range n, ∫ ω, (X i ω)^2 ∂P))\n (Filtration.naturalLT X (by measurability) ) P := by sorry\n\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_integral_zero_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b)) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry\n\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry\n\nlemma exists_tendsto_sum_integral_of_exists_ae_tendsto_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, X n ω ∂P) atTop (𝓝 s) := by sorry\nomit [IsProbabilityMeasure P] in\n\nlemma kolmogorov_three_series_necessity_a\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s))\n {b : ℝ} (b_pos : 0 < b) :\n ∑' n, P {ω | b < |X n ω|} ≠ ∞ := by sorry\n\nlemma kolmogorov_three_series_necessity_b\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s))\n {b : ℝ} (b_pos : 0 < b) :\n (∃ s,\n Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, ((Set.indicator {ω | |X n ω| ≤ b} (X n)) ω) ∂P)\n atTop (𝓝 s)) ∧\n (∑' n, evariance (Set.indicator {ω | |X n ω| ≤ b} (X n)) P ≠ ∞) := by sorry"} -{"project_name": "KolmogorovThreeSeriesNecessary", "name": "kolmogorov_three_series_necessity", "type": "theorem", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\ntheorem kolmogorov_three_series_necessity\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s))\n {b : ℝ} (b_pos : 0 < b) :\n (∑' n, P {ω | b < |X n ω|} ≠ ∞) ∧\n (∃ s,\n Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, ((Set.indicator {ω | |X n ω| ≤ b} (X n)) ω) ∂P)\n atTop (𝓝 s)) ∧\n (∑' n, evariance (Set.indicator {ω | |X n ω| ≤ b} (X n)) P ≠ ∞) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.KolmogorovThreeSeriesNecessary.BackgroundLemmas\nopen MeasureTheory ProbabilityTheory Filter Topology\nopen scoped ENNReal NNReal\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\nlemma martingale_sq_sum_sub_sum_integral_sq\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n))\n (X_memL2 : ∀ n, MemLp (X n) 2 P) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›)\n (fun n ↦ ((∑ i ∈ Finset.range n, X i)^2\n - fun ω ↦ ∑ i ∈ Finset.range n, ∫ ω, (X i ω)^2 ∂P))\n (Filtration.naturalLT X (by measurability) ) P := by sorry\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_integral_zero_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b)) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry\nlemma tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n (∑' n, evariance (X n) P ≠ ∞) := by sorry\nlemma exists_tendsto_sum_integral_of_exists_ae_tendsto_of_forall_bounded\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s)) :\n ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, X n ω ∂P) atTop (𝓝 s) := by sorry\nomit [IsProbabilityMeasure P] in\nlemma kolmogorov_three_series_necessity_a\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s))\n {b : ℝ} (b_pos : 0 < b) :\n ∑' n, P {ω | b < |X n ω|} ≠ ∞ := by sorry\nlemma kolmogorov_three_series_necessity_b\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s))\n {b : ℝ} (b_pos : 0 < b) :\n (∃ s,\n Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, ((Set.indicator {ω | |X n ω| ≤ b} (X n)) ω) ∂P)\n atTop (𝓝 s)) ∧\n (∑' n, evariance (Set.indicator {ω | |X n ω| ≤ b} (X n)) P ≠ ∞) := by sorry"} -{"project_name": "KolmogorovThreeSeriesSufficient", "name": "sum_terms_mgale_of_bounded", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\nvariable (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n\nvariable {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n\nvariable (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n\nlemma sum_terms_mgale_of_bounded (X_mble : ∀ n, Measurable (X n))\n (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b)) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›) (fun n ↦ ∑ i ∈ Finset.range n, X i)\n (Filtration.naturalLT X (by measurability) ) P := by sorry"} -{"project_name": "KolmogorovThreeSeriesSufficient", "name": "tendsto_zero_of_tendsto_sum_range", "type": "lemma", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\nvariable (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n\nvariable {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\n\nvariable (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n\nlemma sum_terms_mgale_of_bounded (X_mble : ∀ n, Measurable (X n))\n (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b)) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›) (fun n ↦ ∑ i ∈ Finset.range n, X i)\n (Filtration.naturalLT X (by measurability) ) P := by sorry\n\nopen Finset in\n\nlemma tendsto_zero_of_tendsto_sum_range (t : ℕ → ℝ) {s : ℝ}\n (sum_lim : Tendsto (fun n ↦ ∑ i ∈ range n, t i) atTop (𝓝 s)) :\n Tendsto t atTop (𝓝 0) := by sorry"} -{"project_name": "KolmogorovThreeSeriesSufficient", "name": "kolmogorov_three_series_sufficiency", "type": "theorem", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\n\ntheorem kolmogorov_three_series_sufficiency\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (b_pos : 0 < b) (sum_pr_gt_finite : ∑' n, P {ω | b < |X n ω|} ≠ ∞)\n (sum_ev_indic_finite : ∃ s,\n Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, ((Set.indicator {ω | |X n ω| ≤ b} (X n)) ω) ∂P)\n atTop (𝓝 s))\n (sum_var_indic_finite : ∑' n, evariance (Set.indicator {ω | |X n ω| ≤ b} (X n)) P ≠ ∞) :\n ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.KolmogorovThreeSeriesSufficient.BackgroundLemmas\nopen MeasureTheory ProbabilityTheory Filter Topology\nopen scoped ENNReal NNReal\nvariable {Ω : Type*} [MeasurableSpace Ω] {P : Measure Ω} [IsProbabilityMeasure P]\nvariable (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\nvariable {b : ℝ} (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b))\nvariable (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\nlemma sum_terms_mgale_of_bounded (X_mble : ∀ n, Measurable (X n))\n (X_ae_le_b : ∀ n, |X n| ≤ᵐ[P] (fun _ ↦ b)) (X_zeromean : ∀ n, ∫ ω, X n ω ∂P = 0)\n (X_indep : iIndepFun X P) :\n Martingale (m0 := ‹MeasurableSpace Ω›) (fun n ↦ ∑ i ∈ Finset.range n, X i)\n (Filtration.naturalLT X (by measurability) ) P := by sorry\nopen Finset in\nlemma tendsto_zero_of_tendsto_sum_range (t : ℕ → ℝ) {s : ℝ}\n (sum_lim : Tendsto (fun n ↦ ∑ i ∈ range n, t i) atTop (𝓝 s)) :\n Tendsto t atTop (𝓝 0) := by sorry"} -{"project_name": "KoukoulopoulosMaynard", "name": "koukoulopoulos_maynard", "type": "theorem", "code": "import Mathlib\n\nopen MeasureTheory Set Nat\n\ntheorem koukoulopoulos_maynard {f : ℕ → ℝ} (hf : ∀ n, 0 < f n) :\n (∀ᵐ (x : ℝ), {(p, q) : ℕ × ℕ | p.Coprime q ∧ |x - p / (↑q : ℝ)|\n < f q / (↑q : ℝ)}.Finite) ↔ Summable fun n ↦ φ n * f n / (↑n : ℝ) := sorry"} -{"project_name": "Kraft", "name": "mem_stringsOfLength", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\n\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\n\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\n\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\n\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry"} -{"project_name": "Kraft", "name": "card_stringsOfLength", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\n\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\n\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\n\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\n\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry\nomit [Nonempty σ] in\n/-- There are `D^n` strings of length `n` over an alphabet of size `D`. -/\n\nlemma card_stringsOfLength (n : ℕ) :\n (stringsOfLength (σ := σ) n).card = (Fintype.card σ) ^ n := by sorry"} -{"project_name": "Kraft", "name": "card_extensions", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\n\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\n\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\n\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\n\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry\nomit [Nonempty σ] in\n/-- There are `D^n` strings of length `n` over an alphabet of size `D`. -/\n\nlemma card_stringsOfLength (n : ℕ) :\n (stringsOfLength (σ := σ) n).card = (Fintype.card σ) ^ n := by sorry\n/-- The set of extensions of `w` to length `n`, i.e.,\n `{v : List σ | v.length = n ∧ w.IsPrefix v}`. -/\n\ndef extensions (w : List σ) (n : ℕ) : Finset (List σ) :=\n (stringsOfLength n).filter (fun v => w.IsPrefix v)\nomit [Nonempty σ] in\n/-- The number of extensions of `w` to length `n` is `D^{n - |w|}`. -/\n\nlemma card_extensions (w : List σ) (n : ℕ) (hn : w.length ≤ n) :\n (extensions w n).card = (Fintype.card σ) ^ (n - w.length) := by sorry"} -{"project_name": "Kraft", "name": "extensions_disjoint", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\n\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\n\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\n\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\n\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry\nomit [Nonempty σ] in\n/-- There are `D^n` strings of length `n` over an alphabet of size `D`. -/\n\nlemma card_stringsOfLength (n : ℕ) :\n (stringsOfLength (σ := σ) n).card = (Fintype.card σ) ^ n := by sorry\n/-- The set of extensions of `w` to length `n`, i.e.,\n `{v : List σ | v.length = n ∧ w.IsPrefix v}`. -/\n\ndef extensions (w : List σ) (n : ℕ) : Finset (List σ) :=\n (stringsOfLength n).filter (fun v => w.IsPrefix v)\nomit [Nonempty σ] in\n/-- The number of extensions of `w` to length `n` is `D^{n - |w|}`. -/\n\nlemma card_extensions (w : List σ) (n : ℕ) (hn : w.length ≤ n) :\n (extensions w n).card = (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- A string `w` is *blocked* by a code `C` if some codeword in `C`\n is a prefix of `w`, or `w` is a prefix of some codeword in `C`. -/\n\ndef blocked (C : Code σ) (w : List σ) : Prop :=\n (∃ c ∈ C, c.IsPrefix w) ∨ (∃ c ∈ C, w.IsPrefix c)\n/-- `blocked` is decidable since prefix checking is decidable. -/\n\ninstance blockedDecidable (C : Code σ) (w : List σ) : Decidable (blocked C w) :=\n inferInstanceAs (Decidable (_ ∨ _))\nomit [Nonempty σ] in\n/-- Extensions of distinct codewords in a prefix-free code are disjoint. -/\n\nlemma extensions_disjoint (C : Code σ) (hC : PrefixFree C) (n : ℕ) :\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁ ≠ w₂ →\n Disjoint (extensions w₁ n) (extensions w₂ n) := by sorry"} -{"project_name": "Kraft", "name": "card_blocked_eq", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\n\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\n\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\n\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\n\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry\nomit [Nonempty σ] in\n/-- There are `D^n` strings of length `n` over an alphabet of size `D`. -/\n\nlemma card_stringsOfLength (n : ℕ) :\n (stringsOfLength (σ := σ) n).card = (Fintype.card σ) ^ n := by sorry\n/-- The set of extensions of `w` to length `n`, i.e.,\n `{v : List σ | v.length = n ∧ w.IsPrefix v}`. -/\n\ndef extensions (w : List σ) (n : ℕ) : Finset (List σ) :=\n (stringsOfLength n).filter (fun v => w.IsPrefix v)\nomit [Nonempty σ] in\n/-- The number of extensions of `w` to length `n` is `D^{n - |w|}`. -/\n\nlemma card_extensions (w : List σ) (n : ℕ) (hn : w.length ≤ n) :\n (extensions w n).card = (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- A string `w` is *blocked* by a code `C` if some codeword in `C`\n is a prefix of `w`, or `w` is a prefix of some codeword in `C`. -/\n\ndef blocked (C : Code σ) (w : List σ) : Prop :=\n (∃ c ∈ C, c.IsPrefix w) ∨ (∃ c ∈ C, w.IsPrefix c)\n/-- `blocked` is decidable since prefix checking is decidable. -/\n\ninstance blockedDecidable (C : Code σ) (w : List σ) : Decidable (blocked C w) :=\n inferInstanceAs (Decidable (_ ∨ _))\nomit [Nonempty σ] in\n/-- Extensions of distinct codewords in a prefix-free code are disjoint. -/\n\nlemma extensions_disjoint (C : Code σ) (hC : PrefixFree C) (n : ℕ) :\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁ ≠ w₂ →\n Disjoint (extensions w₁ n) (extensions w₂ n) := by sorry\nomit [Nonempty σ] in\n/-- The total number of blocked strings of length `n` by a prefix-free code. -/\n\nlemma card_blocked_eq (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n) :\n (C.biUnion (fun w => extensions w n)).card =\n ∑ w ∈ C, (Fintype.card σ) ^ (n - w.length) := by sorry"} -{"project_name": "Kraft", "name": "exists_free_string", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\n\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\n\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\n\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\n\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry\nomit [Nonempty σ] in\n/-- There are `D^n` strings of length `n` over an alphabet of size `D`. -/\n\nlemma card_stringsOfLength (n : ℕ) :\n (stringsOfLength (σ := σ) n).card = (Fintype.card σ) ^ n := by sorry\n/-- The set of extensions of `w` to length `n`, i.e.,\n `{v : List σ | v.length = n ∧ w.IsPrefix v}`. -/\n\ndef extensions (w : List σ) (n : ℕ) : Finset (List σ) :=\n (stringsOfLength n).filter (fun v => w.IsPrefix v)\nomit [Nonempty σ] in\n/-- The number of extensions of `w` to length `n` is `D^{n - |w|}`. -/\n\nlemma card_extensions (w : List σ) (n : ℕ) (hn : w.length ≤ n) :\n (extensions w n).card = (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- A string `w` is *blocked* by a code `C` if some codeword in `C`\n is a prefix of `w`, or `w` is a prefix of some codeword in `C`. -/\n\ndef blocked (C : Code σ) (w : List σ) : Prop :=\n (∃ c ∈ C, c.IsPrefix w) ∨ (∃ c ∈ C, w.IsPrefix c)\n/-- `blocked` is decidable since prefix checking is decidable. -/\n\ninstance blockedDecidable (C : Code σ) (w : List σ) : Decidable (blocked C w) :=\n inferInstanceAs (Decidable (_ ∨ _))\nomit [Nonempty σ] in\n/-- Extensions of distinct codewords in a prefix-free code are disjoint. -/\n\nlemma extensions_disjoint (C : Code σ) (hC : PrefixFree C) (n : ℕ) :\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁ ≠ w₂ →\n Disjoint (extensions w₁ n) (extensions w₂ n) := by sorry\nomit [Nonempty σ] in\n/-- The total number of blocked strings of length `n` by a prefix-free code. -/\n\nlemma card_blocked_eq (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n) :\n (C.biUnion (fun w => extensions w n)).card =\n ∑ w ∈ C, (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- If `C` is prefix-free, all codewords have length ≤ `n`, and the\n Kraft sum of `C` plus `D^{-n}` is at most 1, then there exists a\n string of length `n` not blocked by `C`. -/\n\nlemma exists_free_string (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n)\n (hkraft : (∑ w ∈ C, (1 : ℚ) / (Fintype.card σ : ℚ) ^ w.length) +\n (1 : ℚ) / (Fintype.card σ : ℚ) ^ n ≤ 1) :\n ∃ w : List σ, w.length = n ∧ ¬ blocked C w := by sorry"} -{"project_name": "Kraft", "name": "prefixFree_insert", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\n\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\n\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\n\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\n\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry\nomit [Nonempty σ] in\n/-- There are `D^n` strings of length `n` over an alphabet of size `D`. -/\n\nlemma card_stringsOfLength (n : ℕ) :\n (stringsOfLength (σ := σ) n).card = (Fintype.card σ) ^ n := by sorry\n/-- The set of extensions of `w` to length `n`, i.e.,\n `{v : List σ | v.length = n ∧ w.IsPrefix v}`. -/\n\ndef extensions (w : List σ) (n : ℕ) : Finset (List σ) :=\n (stringsOfLength n).filter (fun v => w.IsPrefix v)\nomit [Nonempty σ] in\n/-- The number of extensions of `w` to length `n` is `D^{n - |w|}`. -/\n\nlemma card_extensions (w : List σ) (n : ℕ) (hn : w.length ≤ n) :\n (extensions w n).card = (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- A string `w` is *blocked* by a code `C` if some codeword in `C`\n is a prefix of `w`, or `w` is a prefix of some codeword in `C`. -/\n\ndef blocked (C : Code σ) (w : List σ) : Prop :=\n (∃ c ∈ C, c.IsPrefix w) ∨ (∃ c ∈ C, w.IsPrefix c)\n/-- `blocked` is decidable since prefix checking is decidable. -/\n\ninstance blockedDecidable (C : Code σ) (w : List σ) : Decidable (blocked C w) :=\n inferInstanceAs (Decidable (_ ∨ _))\nomit [Nonempty σ] in\n/-- Extensions of distinct codewords in a prefix-free code are disjoint. -/\n\nlemma extensions_disjoint (C : Code σ) (hC : PrefixFree C) (n : ℕ) :\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁ ≠ w₂ →\n Disjoint (extensions w₁ n) (extensions w₂ n) := by sorry\nomit [Nonempty σ] in\n/-- The total number of blocked strings of length `n` by a prefix-free code. -/\n\nlemma card_blocked_eq (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n) :\n (C.biUnion (fun w => extensions w n)).card =\n ∑ w ∈ C, (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- If `C` is prefix-free, all codewords have length ≤ `n`, and the\n Kraft sum of `C` plus `D^{-n}` is at most 1, then there exists a\n string of length `n` not blocked by `C`. -/\n\nlemma exists_free_string (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n)\n (hkraft : (∑ w ∈ C, (1 : ℚ) / (Fintype.card σ : ℚ) ^ w.length) +\n (1 : ℚ) / (Fintype.card σ : ℚ) ^ n ≤ 1) :\n ∃ w : List σ, w.length = n ∧ ¬ blocked C w := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Adding a non-blocked string to a prefix-free code preserves prefix-freeness. -/\n\nlemma prefixFree_insert (C : Code σ) (hC : PrefixFree C) (w : List σ)\n (hw : ¬ blocked C w) (hw_notin : w ∉ C) :\n PrefixFree (insert w C) := by sorry"} -{"project_name": "Kraft", "name": "isChain_ge_head_le", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\n\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\n\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\n\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\n\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry\nomit [Nonempty σ] in\n/-- There are `D^n` strings of length `n` over an alphabet of size `D`. -/\n\nlemma card_stringsOfLength (n : ℕ) :\n (stringsOfLength (σ := σ) n).card = (Fintype.card σ) ^ n := by sorry\n/-- The set of extensions of `w` to length `n`, i.e.,\n `{v : List σ | v.length = n ∧ w.IsPrefix v}`. -/\n\ndef extensions (w : List σ) (n : ℕ) : Finset (List σ) :=\n (stringsOfLength n).filter (fun v => w.IsPrefix v)\nomit [Nonempty σ] in\n/-- The number of extensions of `w` to length `n` is `D^{n - |w|}`. -/\n\nlemma card_extensions (w : List σ) (n : ℕ) (hn : w.length ≤ n) :\n (extensions w n).card = (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- A string `w` is *blocked* by a code `C` if some codeword in `C`\n is a prefix of `w`, or `w` is a prefix of some codeword in `C`. -/\n\ndef blocked (C : Code σ) (w : List σ) : Prop :=\n (∃ c ∈ C, c.IsPrefix w) ∨ (∃ c ∈ C, w.IsPrefix c)\n/-- `blocked` is decidable since prefix checking is decidable. -/\n\ninstance blockedDecidable (C : Code σ) (w : List σ) : Decidable (blocked C w) :=\n inferInstanceAs (Decidable (_ ∨ _))\nomit [Nonempty σ] in\n/-- Extensions of distinct codewords in a prefix-free code are disjoint. -/\n\nlemma extensions_disjoint (C : Code σ) (hC : PrefixFree C) (n : ℕ) :\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁ ≠ w₂ →\n Disjoint (extensions w₁ n) (extensions w₂ n) := by sorry\nomit [Nonempty σ] in\n/-- The total number of blocked strings of length `n` by a prefix-free code. -/\n\nlemma card_blocked_eq (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n) :\n (C.biUnion (fun w => extensions w n)).card =\n ∑ w ∈ C, (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- If `C` is prefix-free, all codewords have length ≤ `n`, and the\n Kraft sum of `C` plus `D^{-n}` is at most 1, then there exists a\n string of length `n` not blocked by `C`. -/\n\nlemma exists_free_string (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n)\n (hkraft : (∑ w ∈ C, (1 : ℚ) / (Fintype.card σ : ℚ) ^ w.length) +\n (1 : ℚ) / (Fintype.card σ : ℚ) ^ n ≤ 1) :\n ∃ w : List σ, w.length = n ∧ ¬ blocked C w := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Adding a non-blocked string to a prefix-free code preserves prefix-freeness. -/\n\nlemma prefixFree_insert (C : Code σ) (hC : PrefixFree C) (w : List σ)\n (hw : ¬ blocked C w) (hw_notin : w ∉ C) :\n PrefixFree (insert w C) := by sorry\n/-- In a descending chain `l :: ls`, every element of `ls` is ≤ `l`. -/\n\nlemma isChain_ge_head_le {l : ℕ} {ls : List ℕ}\n (hs : List.IsChain (· ≥ ·) (l :: ls)) (x : ℕ) (hx : x ∈ ls) : x ≤ l := by sorry"} -{"project_name": "Kraft", "name": "kraft_sorted", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\n\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\n\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\n\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\n\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry\nomit [Nonempty σ] in\n/-- There are `D^n` strings of length `n` over an alphabet of size `D`. -/\n\nlemma card_stringsOfLength (n : ℕ) :\n (stringsOfLength (σ := σ) n).card = (Fintype.card σ) ^ n := by sorry\n/-- The set of extensions of `w` to length `n`, i.e.,\n `{v : List σ | v.length = n ∧ w.IsPrefix v}`. -/\n\ndef extensions (w : List σ) (n : ℕ) : Finset (List σ) :=\n (stringsOfLength n).filter (fun v => w.IsPrefix v)\nomit [Nonempty σ] in\n/-- The number of extensions of `w` to length `n` is `D^{n - |w|}`. -/\n\nlemma card_extensions (w : List σ) (n : ℕ) (hn : w.length ≤ n) :\n (extensions w n).card = (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- A string `w` is *blocked* by a code `C` if some codeword in `C`\n is a prefix of `w`, or `w` is a prefix of some codeword in `C`. -/\n\ndef blocked (C : Code σ) (w : List σ) : Prop :=\n (∃ c ∈ C, c.IsPrefix w) ∨ (∃ c ∈ C, w.IsPrefix c)\n/-- `blocked` is decidable since prefix checking is decidable. -/\n\ninstance blockedDecidable (C : Code σ) (w : List σ) : Decidable (blocked C w) :=\n inferInstanceAs (Decidable (_ ∨ _))\nomit [Nonempty σ] in\n/-- Extensions of distinct codewords in a prefix-free code are disjoint. -/\n\nlemma extensions_disjoint (C : Code σ) (hC : PrefixFree C) (n : ℕ) :\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁ ≠ w₂ →\n Disjoint (extensions w₁ n) (extensions w₂ n) := by sorry\nomit [Nonempty σ] in\n/-- The total number of blocked strings of length `n` by a prefix-free code. -/\n\nlemma card_blocked_eq (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n) :\n (C.biUnion (fun w => extensions w n)).card =\n ∑ w ∈ C, (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- If `C` is prefix-free, all codewords have length ≤ `n`, and the\n Kraft sum of `C` plus `D^{-n}` is at most 1, then there exists a\n string of length `n` not blocked by `C`. -/\n\nlemma exists_free_string (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n)\n (hkraft : (∑ w ∈ C, (1 : ℚ) / (Fintype.card σ : ℚ) ^ w.length) +\n (1 : ℚ) / (Fintype.card σ : ℚ) ^ n ≤ 1) :\n ∃ w : List σ, w.length = n ∧ ¬ blocked C w := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Adding a non-blocked string to a prefix-free code preserves prefix-freeness. -/\n\nlemma prefixFree_insert (C : Code σ) (hC : PrefixFree C) (w : List σ)\n (hw : ¬ blocked C w) (hw_notin : w ∉ C) :\n PrefixFree (insert w C) := by sorry\n/-- In a descending chain `l :: ls`, every element of `ls` is ≤ `l`. -/\n\nlemma isChain_ge_head_le {l : ℕ} {ls : List ℕ}\n (hs : List.IsChain (· ≥ ·) (l :: ls)) (x : ℕ) (hx : x ∈ ls) : x ≤ l := by sorry\ntermination_by ls.length\n/-- Greedy construction of a prefix-free code from a descending list of lengths. -/\n\nlemma kraft_sorted (ls : List ℕ) (hs : List.IsChain (· ≥ ·) ls)\n (hkraft : kraftSum σ ls ≤ 1) :\n ∃ C : Code σ, PrefixFree C ∧\n C.val.map List.length = (ls : Multiset ℕ) := by sorry"} -{"project_name": "Kraft", "name": "kraft", "type": "theorem", "code": "import Mathlib\n\nuniverse u\n\nnamespace Kraft\n\nvariable {σ : Type u} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- **Kraft's Theorem**: For every list of lengths `ls`, if the Kraft sum of `ls` is\nless than or equal to 1, then there exists a prefix-free code `C` such that\nthe length of the codewords in `C` is equal to `ls`.\n-/\n\ntheorem kraft (ls : List ℕ) (hkraft : kraftSum σ ls ≤ 1) :\n ∃ C : Code σ, PrefixFree C ∧\n C.val.map List.length = (ls : Multiset ℕ) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.Kraft.BackgroundLemmas\nopen scoped BigOperators\nuniverse u\nnamespace Kraft\nvariable {σ : Type*} [Fintype σ] [DecidableEq σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- A code is *prefix-free* if no codeword is a prefix of another. -/\ndef PrefixFree (C : Code σ) : Prop :=\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁.IsPrefix w₂ → w₁ = w₂\n/-- The *Kraft sum* of a list of codeword lengths `l₁, …, lₘ` with respect\nto an alphabet `σ` of size `D = Fintype.card σ` is `∑ᵢ D^{-lᵢ}`. -/\ndef kraftSum (σ : Type*) [Fintype σ] (ls : List ℕ) : ℚ :=\n (ls.map (fun l => (1 : ℚ) / (Fintype.card σ : ℚ) ^ l)).sum\n/-- All strings of length `n` over `σ`, as a `Finset`. -/\ndef stringsOfLength (n : ℕ) :\n Finset (List σ) :=\n Finset.univ.image (fun f : Fin n → σ => List.ofFn f)\nomit [Nonempty σ] in\n/-- A string belongs to `stringsOfLength n` iff its length is `n`. -/\nlemma mem_stringsOfLength {w : List σ} {n : ℕ} :\n w ∈ stringsOfLength n ↔ w.length = n := by sorry\nomit [Nonempty σ] in\n/-- There are `D^n` strings of length `n` over an alphabet of size `D`. -/\nlemma card_stringsOfLength (n : ℕ) :\n (stringsOfLength (σ := σ) n).card = (Fintype.card σ) ^ n := by sorry\n/-- The set of extensions of `w` to length `n`, i.e.,\n `{v : List σ | v.length = n ∧ w.IsPrefix v}`. -/\ndef extensions (w : List σ) (n : ℕ) : Finset (List σ) :=\n (stringsOfLength n).filter (fun v => w.IsPrefix v)\nomit [Nonempty σ] in\n/-- The number of extensions of `w` to length `n` is `D^{n - |w|}`. -/\nlemma card_extensions (w : List σ) (n : ℕ) (hn : w.length ≤ n) :\n (extensions w n).card = (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- A string `w` is *blocked* by a code `C` if some codeword in `C`\n is a prefix of `w`, or `w` is a prefix of some codeword in `C`. -/\ndef blocked (C : Code σ) (w : List σ) : Prop :=\n (∃ c ∈ C, c.IsPrefix w) ∨ (∃ c ∈ C, w.IsPrefix c)\n/-- `blocked` is decidable since prefix checking is decidable. -/\ninstance blockedDecidable (C : Code σ) (w : List σ) : Decidable (blocked C w) :=\n inferInstanceAs (Decidable (_ ∨ _))\nomit [Nonempty σ] in\n/-- Extensions of distinct codewords in a prefix-free code are disjoint. -/\nlemma extensions_disjoint (C : Code σ) (hC : PrefixFree C) (n : ℕ) :\n ∀ w₁ ∈ C, ∀ w₂ ∈ C, w₁ ≠ w₂ →\n Disjoint (extensions w₁ n) (extensions w₂ n) := by sorry\nomit [Nonempty σ] in\n/-- The total number of blocked strings of length `n` by a prefix-free code. -/\nlemma card_blocked_eq (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n) :\n (C.biUnion (fun w => extensions w n)).card =\n ∑ w ∈ C, (Fintype.card σ) ^ (n - w.length) := by sorry\n/-- If `C` is prefix-free, all codewords have length ≤ `n`, and the\n Kraft sum of `C` plus `D^{-n}` is at most 1, then there exists a\n string of length `n` not blocked by `C`. -/\nlemma exists_free_string (C : Code σ) (hC : PrefixFree C) (n : ℕ)\n (hn : ∀ w ∈ C, w.length ≤ n)\n (hkraft : (∑ w ∈ C, (1 : ℚ) / (Fintype.card σ : ℚ) ^ w.length) +\n (1 : ℚ) / (Fintype.card σ : ℚ) ^ n ≤ 1) :\n ∃ w : List σ, w.length = n ∧ ¬ blocked C w := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Adding a non-blocked string to a prefix-free code preserves prefix-freeness. -/\nlemma prefixFree_insert (C : Code σ) (hC : PrefixFree C) (w : List σ)\n (hw : ¬ blocked C w) (hw_notin : w ∉ C) :\n PrefixFree (insert w C) := by sorry\n/-- In a descending chain `l :: ls`, every element of `ls` is ≤ `l`. -/\nlemma isChain_ge_head_le {l : ℕ} {ls : List ℕ}\n (hs : List.IsChain (· ≥ ·) (l :: ls)) (x : ℕ) (hx : x ∈ ls) : x ≤ l := by sorry\ntermination_by ls.length\n/-- Greedy construction of a prefix-free code from a descending list of lengths. -/\nlemma kraft_sorted (ls : List ℕ) (hs : List.IsChain (· ≥ ·) ls)\n (hkraft : kraftSum σ ls ≤ 1) :\n ∃ C : Code σ, PrefixFree C ∧\n C.val.map List.length = (ls : Multiset ℕ) := by sorry\nend Kraft"} -{"project_name": "KroneckerWeberTheorem", "name": "KroneckerWeber", "type": "theorem", "code": "import Mathlib\n\ntheorem KroneckerWeber (F : Type*) [Field F] [NumberField F] [IsAbelianGalois ℚ F] :\n ∃ n, ∃ (K : Type*) (_ : Field K) (_ : Algebra ℚ K) (_ : Algebra F K) (_ : IsScalarTower ℚ F K),\n IsCyclotomicExtension {n} ℚ K := sorry"} -{"project_name": "KrullSeparationLemma", "name": "krull_separation", "type": "theorem", "code": "import Mathlib\n\nopen Ideal\n\nuniverse u\n/-- Krull's spearation lemma. If this is too hard, it should be much easier in the commutative case,\nsee https://link.springer.com/content/pdf/10.1007/BF01110546.pdf -/\n\ntheorem krull_separation {R : Type u} [Ring R] {M : Submonoid R} {I : Ideal R}\n (h : M.carrier ∩ I.carrier = ∅) :\n ∃ P : Ideal R, IsPrime P ∧ M.carrier ∩ P.carrier = ∅ ∧ I ≤ P := sorry"} -{"project_name": "LagrangeTheorem", "name": "lagrange", "type": "theorem", "code": "import Mathlib\n\nopen Polynomial Nat\n/-- Lagrange theorem in number theory,\nhttps://en.wikipedia.org/wiki/Lagrange's_theorem_(number_theory) -/\n\ntheorem lagrange {p : ℕ} (hp : p.Prime) {f : Polynomial ℤ} (h : ∃ n : ℕ, ¬ (↑p : ℤ) ∣ f.coeff n):\n {n : ℕ | n ≤ p ∧ ↑p ∣ eval (↑n : ℤ) f}.ncard ≤ f.natDegree := sorry"} -{"project_name": "LeCamTheorem", "name": "LeCamTheorem", "type": "theorem", "code": "import Mathlib\n/--\nGiven a list of PMFs, we can construct a new PMF\nthat represents the distribution of the sum of independent random variables drawn from those PMFs.\n-/\nnoncomputable def independentSum {α : Type} [AddMonoid α] : List (PMF α) → PMF α\n | [] => PMF.pure 0\n | X :: XS => do\n let x ← X\n let y ← independentSum XS\n pure (x + y)\n/--\nA Bernoulli distribution with parameter p from the unitInterval and natural number 0-1 value\n-/\nnoncomputable def PMF.bernoulliNat_of_unitInterval (p : unitInterval) : PMF ℕ := do\n let x ← PMF.bernoulli p.val.toNNReal (by simp; grind)\n pure (if x = 0 then 0 else 1)\n\ntheorem LeCamTheorem (ps : List unitInterval) (hps : ∀ p ∈ ps, 0 ≤ p ∧ p ≤ 1) :\n let mean := (ps.map (fun p => p.val)).sum\n let sum := independentSum (ps.map (fun k => PMF.bernoulliNat_of_unitInterval (k) ) )\n ∑ k ∈ Finset.range (ps.length+1),\n |(sum k).toReal - (Real.exp (-mean) * mean ^ k / k.factorial)| ≤ 2 * (ps.map (fun p => p.val ^ 2)).sum := sorry"} -{"project_name": "LeastCommonMultipleLowerBound", "name": "Complex.betaIntegral_eq_sum", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nlemma Complex.betaIntegral_eq_sum (m j : ℕ) (hm : 0 < m) :\n Complex.betaIntegral (m : ℂ) ((j + 1) : ℂ) =\n ∑ k ∈ Finset.range (j + 1), (-1 : ℚ) ^ k * j.choose k * (1 / (m + k)) := by sorry"} -{"project_name": "LeastCommonMultipleLowerBound", "name": "mul_choose_dvd_LCM", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nlemma Complex.betaIntegral_eq_sum (m j : ℕ) (hm : 0 < m) :\n Complex.betaIntegral (m : ℂ) ((j + 1) : ℂ) =\n ∑ k ∈ Finset.range (j + 1), (-1 : ℚ) ^ k * j.choose k * (1 / (m + k)) := by sorry\n\nopen IsLocalization in\n\nlemma mul_choose_dvd_LCM (m j : ℕ) (hm : 0 < m) : m * (Nat.binom m j) ∣ LCM (m + j) := by sorry"} -{"project_name": "LeastCommonMultipleLowerBound", "name": "bound_odd_LCM", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nlemma Complex.betaIntegral_eq_sum (m j : ℕ) (hm : 0 < m) :\n Complex.betaIntegral (m : ℂ) ((j + 1) : ℂ) =\n ∑ k ∈ Finset.range (j + 1), (-1 : ℚ) ^ k * j.choose k * (1 / (m + k)) := by sorry\n\nopen IsLocalization in\n\nlemma mul_choose_dvd_LCM (m j : ℕ) (hm : 0 < m) : m * (Nat.binom m j) ∣ LCM (m + j) := by sorry\n\nlemma bound_odd_LCM (n : ℕ) (hn : 4 ≤ n) : (2 * n + 1) * 4 ^ n ≤ LCM (2 * n + 1) := sorry"} -{"project_name": "LeastCommonMultipleLowerBound", "name": "Nat.even_or_odd_pos", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nlemma Complex.betaIntegral_eq_sum (m j : ℕ) (hm : 0 < m) :\n Complex.betaIntegral (m : ℂ) ((j + 1) : ℂ) =\n ∑ k ∈ Finset.range (j + 1), (-1 : ℚ) ^ k * j.choose k * (1 / (m + k)) := by sorry\n\nopen IsLocalization in\n\nlemma mul_choose_dvd_LCM (m j : ℕ) (hm : 0 < m) : m * (Nat.binom m j) ∣ LCM (m + j) := by sorry\n\nlemma bound_odd_LCM (n : ℕ) (hn : 4 ≤ n) : (2 * n + 1) * 4 ^ n ≤ LCM (2 * n + 1) := sorry\n\nlemma Nat.even_or_odd_pos (n : ℕ) (hn : 1 ≤ n) : ∃ k, n = 2 * k + 2 ∨ n = 2 * k + 1 := by sorry"} -{"project_name": "LeastCommonMultipleLowerBound", "name": "LCM_lower_bound_9_le", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nlemma Complex.betaIntegral_eq_sum (m j : ℕ) (hm : 0 < m) :\n Complex.betaIntegral (m : ℂ) ((j + 1) : ℂ) =\n ∑ k ∈ Finset.range (j + 1), (-1 : ℚ) ^ k * j.choose k * (1 / (m + k)) := by sorry\n\nopen IsLocalization in\n\nlemma mul_choose_dvd_LCM (m j : ℕ) (hm : 0 < m) : m * (Nat.binom m j) ∣ LCM (m + j) := by sorry\n\nlemma bound_odd_LCM (n : ℕ) (hn : 4 ≤ n) : (2 * n + 1) * 4 ^ n ≤ LCM (2 * n + 1) := sorry\n\nlemma Nat.even_or_odd_pos (n : ℕ) (hn : 1 ≤ n) : ∃ k, n = 2 * k + 2 ∨ n = 2 * k + 1 := by sorry\n\nlemma LCM_lower_bound_9_le (n : ℕ) (hn : 9 ≤ n) : 2 ^ n ≤ LCM n := by sorry"} -{"project_name": "LeastCommonMultipleLowerBound", "name": "Nat.LCM_lower_bound", "type": "theorem", "code": "import Mathlib\n\ntheorem Nat.LCM_lower_bound (n : ℕ) (hn : 7 ≤ n) : 2 ^ n ≤ LCM n := sorry", "imported_file": "-- File: LiveLeanTriathlon.LeastCommonMultipleLowerBound.BackgroundLemmas\nopen Nat\nlemma Complex.betaIntegral_eq_sum (m j : ℕ) (hm : 0 < m) :\n Complex.betaIntegral (m : ℂ) ((j + 1) : ℂ) =\n ∑ k ∈ Finset.range (j + 1), (-1 : ℚ) ^ k * j.choose k * (1 / (m + k)) := by sorry\nopen IsLocalization in\nlemma mul_choose_dvd_LCM (m j : ℕ) (hm : 0 < m) : m * (Nat.binom m j) ∣ LCM (m + j) := by sorry\nlemma bound_odd_LCM (n : ℕ) (hn : 4 ≤ n) : (2 * n + 1) * 4 ^ n ≤ LCM (2 * n + 1) := sorry\nlemma Nat.even_or_odd_pos (n : ℕ) (hn : 1 ≤ n) : ∃ k, n = 2 * k + 2 ∨ n = 2 * k + 1 := by sorry\nlemma LCM_lower_bound_9_le (n : ℕ) (hn : 9 ≤ n) : 2 ^ n ≤ LCM n := by sorry"} -{"project_name": "LevitzkyTheorem", "name": "levitzky_theorem", "type": "theorem", "code": "import Mathlib\n/-- A left ideal `I` is nil if every element of `I` is nilpotent. -/\n\ndef Ideal.IsNil {R : Type*} [Ring R] (I : Ideal R) : Prop :=\n ∀ (x : R), x ∈ I → IsNilpotent x\n/-- **Levitzky's theorem.** In a right Noetherian ring, every nil left ideal is nilpotent. -/\n\ntheorem levitzky_theorem {R : Type*} [Ring R]\n [IsNoetherianRing (MulOpposite R)]\n (I : Ideal R) (hnil : I.IsNil) :\n IsNilpotent I := by sorry"} -{"project_name": "LinnikTheorem", "name": "linnik", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n/-- The least prime in an arithmetic progression -/\nnoncomputable def d : ℕ → ℕ → ℕ := fun a b ↦ sInf ({a + k * b | k : ℕ} ∩ {p | p.Prime})\n\ntheorem linnik : ∃ c L : ℝ, ∀ ⦃a b : ℕ⦄, a.Coprime b → d a b ≤ c * (↑b : ℝ) ^ L := by sorry"} -{"project_name": "LukacsProportionSumIndependenceTheorem", "name": "lukacs_proportion_sum_independence_iff", "type": "theorem", "code": "import Mathlib\n\nopen MeasureTheory ProbabilityTheory\n/-- **Lukacs's Proportion-Sum Independence Theorem (iff version).**\nLet X and Y be independent, positive (a.e.), non-degenerate real random variables on a\nprobability space. Then X/(X+Y) is independent of X+Y if and only if there exist\nalpha, gamma, r > 0 such that X ~ Gamma(alpha, r) and Y ~ Gamma(gamma, r). -/\n\ntheorem lukacs_proportion_sum_independence_iff\n {Omega : Type*} [MeasurableSpace Omega]\n {P : Measure Omega} [IsProbabilityMeasure P]\n {X Y : Omega → ℝ}\n (hXm : Measurable X) (hYm : Measurable Y)\n (hXY : IndepFun X Y P)\n (hXpos : ∀ᵐ ω ∂P, 0 < X ω)\n (hYpos : ∀ᵐ ω ∂P, 0 < Y ω)\n (hXnd : ¬∃ c, ∀ᵐ ω ∂P, X ω = c)\n (hYnd : ¬∃ c, ∀ᵐ ω ∂P, Y ω = c) :\n IndepFun (fun ω => X ω / (X ω + Y ω)) (fun ω => X ω + Y ω) P ↔\n ∃ alpha gamma r : ℝ,\n 0 < alpha ∧ 0 < gamma ∧ 0 < r ∧\n HasLaw X (gammaMeasure alpha r) P ∧\n HasLaw Y (gammaMeasure gamma r) P := by sorry"} -{"project_name": "LusinTheorem", "name": "lusin", "type": "theorem", "code": "import Mathlib\n\nopen Set Function MeasureTheory\n/-- This is the classical version, there is a generalisation on wikipedia -/\n\ntheorem lusin {a b ε : ℝ} (ab : a < b) {f : ℝ → ℂ} (f_meas : Measurable f) (εp : 0 < ε) :\n ∃ E ⊆ Icc a b, IsCompact E ∧ Continuous (restrict E f) ∧ b - a - ε < (volume E).toReal := by sorry"} -{"project_name": "McMillan", "name": "tupleEncode_eq_encode_ofFn", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry"} -{"project_name": "McMillan", "name": "tupleEncode_injective", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry"} -{"project_name": "McMillan", "name": "tupleEncode_length", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry"} -{"project_name": "McMillan", "name": "count_tuples_le", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\n\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry"} -{"project_name": "McMillan", "name": "kraftSum_eq_sum_subtype", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\n\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry\nomit [Nonempty σ] in\n/-- kraftSum as a sum over the subtype ↥C. -/\n\nlemma kraftSum_eq_sum_subtype (C : Code σ) :\n kraftSum C =\n ∑ w : C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (w : List σ).length) := by sorry"} -{"project_name": "McMillan", "name": "kraftSum_pow_eq_sum_tuples", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\n\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry\nomit [Nonempty σ] in\n/-- kraftSum as a sum over the subtype ↥C. -/\n\nlemma kraftSum_eq_sum_subtype (C : Code σ) :\n kraftSum C =\n ∑ w : C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (w : List σ).length) := by sorry\nomit [Nonempty σ] in\n/-- The `n`-th power of the Kraft sum expanded as a sum over tuples. -/\n\nlemma kraftSum_pow_eq_sum_tuples (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C, ∏ i : Fin n,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) := by sorry"} -{"project_name": "McMillan", "name": "tuple_contrib", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\n\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry\nomit [Nonempty σ] in\n/-- kraftSum as a sum over the subtype ↥C. -/\n\nlemma kraftSum_eq_sum_subtype (C : Code σ) :\n kraftSum C =\n ∑ w : C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (w : List σ).length) := by sorry\nomit [Nonempty σ] in\n/-- The `n`-th power of the Kraft sum expanded as a sum over tuples. -/\n\nlemma kraftSum_pow_eq_sum_tuples (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C, ∏ i : Fin n,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) := by sorry\nomit [Nonempty σ] in\n/-- Each tuple contributes `D^{-totalLength t}`. -/\n\nlemma tuple_contrib (C : Code σ) (n : ℕ) (t : Fin n → C) :\n ∏ i : Fin n, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) =\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry"} -{"project_name": "McMillan", "name": "kraftSum_pow_eq_sum_inv", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\n\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry\nomit [Nonempty σ] in\n/-- kraftSum as a sum over the subtype ↥C. -/\n\nlemma kraftSum_eq_sum_subtype (C : Code σ) :\n kraftSum C =\n ∑ w : C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (w : List σ).length) := by sorry\nomit [Nonempty σ] in\n/-- The `n`-th power of the Kraft sum expanded as a sum over tuples. -/\n\nlemma kraftSum_pow_eq_sum_tuples (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C, ∏ i : Fin n,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) := by sorry\nomit [Nonempty σ] in\n/-- Each tuple contributes `D^{-totalLength t}`. -/\n\nlemma tuple_contrib (C : Code σ) (n : ℕ) (t : Fin n → C) :\n ∏ i : Fin n, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) =\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Nonempty σ] in\n/-- `K^n` as a sum of `D^{-totalLength t}` over all `n`-tuples. -/\n\nlemma kraftSum_pow_eq_sum_inv (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry"} -{"project_name": "McMillan", "name": "totalLength_le_mul_maxLength", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\n\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry\nomit [Nonempty σ] in\n/-- kraftSum as a sum over the subtype ↥C. -/\n\nlemma kraftSum_eq_sum_subtype (C : Code σ) :\n kraftSum C =\n ∑ w : C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (w : List σ).length) := by sorry\nomit [Nonempty σ] in\n/-- The `n`-th power of the Kraft sum expanded as a sum over tuples. -/\n\nlemma kraftSum_pow_eq_sum_tuples (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C, ∏ i : Fin n,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) := by sorry\nomit [Nonempty σ] in\n/-- Each tuple contributes `D^{-totalLength t}`. -/\n\nlemma tuple_contrib (C : Code σ) (n : ℕ) (t : Fin n → C) :\n ∏ i : Fin n, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) =\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Nonempty σ] in\n/-- `K^n` as a sum of `D^{-totalLength t}` over all `n`-tuples. -/\n\nlemma kraftSum_pow_eq_sum_inv (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The total length of any `n`-tuple is at most `n * maxLength C`. -/\n\nlemma totalLength_le_mul_maxLength (C : Code σ) (n : ℕ) (t : Fin n → C) :\n totalLength C n t ≤ n * maxLength C := by sorry"} -{"project_name": "McMillan", "name": "sum_inv_by_length_le", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\n\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry\nomit [Nonempty σ] in\n/-- kraftSum as a sum over the subtype ↥C. -/\n\nlemma kraftSum_eq_sum_subtype (C : Code σ) :\n kraftSum C =\n ∑ w : C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (w : List σ).length) := by sorry\nomit [Nonempty σ] in\n/-- The `n`-th power of the Kraft sum expanded as a sum over tuples. -/\n\nlemma kraftSum_pow_eq_sum_tuples (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C, ∏ i : Fin n,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) := by sorry\nomit [Nonempty σ] in\n/-- Each tuple contributes `D^{-totalLength t}`. -/\n\nlemma tuple_contrib (C : Code σ) (n : ℕ) (t : Fin n → C) :\n ∏ i : Fin n, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) =\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Nonempty σ] in\n/-- `K^n` as a sum of `D^{-totalLength t}` over all `n`-tuples. -/\n\nlemma kraftSum_pow_eq_sum_inv (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The total length of any `n`-tuple is at most `n * maxLength C`. -/\n\nlemma totalLength_le_mul_maxLength (C : Code σ) (n : ℕ) (t : Fin n → C) :\n totalLength C n t ≤ n * maxLength C := by sorry\n/-- The core counting bound: `A(n,k) / D^k ≤ 1`. -/\n\nlemma sum_inv_by_length_le (C : Code σ) (hC : UniquelyDecodable C)\n (n k : ℕ) :\n (Fintype.card { t : Fin n → C // totalLength C n t = k } : ℚ) /\n ((Fintype.card σ : ℚ) ^ k) ≤ 1 := by sorry"} -{"project_name": "McMillan", "name": "kraftSum_pow_le", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\n\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry\nomit [Nonempty σ] in\n/-- kraftSum as a sum over the subtype ↥C. -/\n\nlemma kraftSum_eq_sum_subtype (C : Code σ) :\n kraftSum C =\n ∑ w : C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (w : List σ).length) := by sorry\nomit [Nonempty σ] in\n/-- The `n`-th power of the Kraft sum expanded as a sum over tuples. -/\n\nlemma kraftSum_pow_eq_sum_tuples (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C, ∏ i : Fin n,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) := by sorry\nomit [Nonempty σ] in\n/-- Each tuple contributes `D^{-totalLength t}`. -/\n\nlemma tuple_contrib (C : Code σ) (n : ℕ) (t : Fin n → C) :\n ∏ i : Fin n, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) =\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Nonempty σ] in\n/-- `K^n` as a sum of `D^{-totalLength t}` over all `n`-tuples. -/\n\nlemma kraftSum_pow_eq_sum_inv (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The total length of any `n`-tuple is at most `n * maxLength C`. -/\n\nlemma totalLength_le_mul_maxLength (C : Code σ) (n : ℕ) (t : Fin n → C) :\n totalLength C n t ≤ n * maxLength C := by sorry\n/-- The core counting bound: `A(n,k) / D^k ≤ 1`. -/\n\nlemma sum_inv_by_length_le (C : Code σ) (hC : UniquelyDecodable C)\n (n k : ℕ) :\n (Fintype.card { t : Fin n → C // totalLength C n t = k } : ℚ) /\n ((Fintype.card σ : ℚ) ^ k) ≤ 1 := by sorry\n/-- `(kraftSum C) ^ n ≤ n * maxLength C + 1`.\nThe proof expands `K^n` as a sum over `n`-tuples, then regroups by total length:\n `K^n = ∑_t D^{-totalLength(t)} = ∑_{k=0}^{nL} A(n,k) · D^{-k}`\nwhere `A(n,k) = |{t : totalLength t = k}|` and `L = maxLength C`.\nEach fiber contributes `A(n,k) / D^k ≤ 1` (by `count_tuples_le`),\nand there are `nL + 1` fibers. -/\n\nlemma kraftSum_pow_le (C : Code σ) (hC : UniquelyDecodable C) (n : ℕ) :\n (kraftSum C) ^ n ≤ ↑(n * maxLength C + 1) := by sorry"} -{"project_name": "McMillan", "name": "bernoulli_ineq", "type": "lemma", "code": "import Mathlib\n\nopen scoped BigOperators\n\nuniverse u\n\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\n\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\n\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\n\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\n\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\n\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\n\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\n\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\n\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\n\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\n\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\n\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry\nomit [Nonempty σ] in\n/-- kraftSum as a sum over the subtype ↥C. -/\n\nlemma kraftSum_eq_sum_subtype (C : Code σ) :\n kraftSum C =\n ∑ w : C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (w : List σ).length) := by sorry\nomit [Nonempty σ] in\n/-- The `n`-th power of the Kraft sum expanded as a sum over tuples. -/\n\nlemma kraftSum_pow_eq_sum_tuples (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C, ∏ i : Fin n,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) := by sorry\nomit [Nonempty σ] in\n/-- Each tuple contributes `D^{-totalLength t}`. -/\n\nlemma tuple_contrib (C : Code σ) (n : ℕ) (t : Fin n → C) :\n ∏ i : Fin n, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) =\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Nonempty σ] in\n/-- `K^n` as a sum of `D^{-totalLength t}` over all `n`-tuples. -/\n\nlemma kraftSum_pow_eq_sum_inv (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The total length of any `n`-tuple is at most `n * maxLength C`. -/\n\nlemma totalLength_le_mul_maxLength (C : Code σ) (n : ℕ) (t : Fin n → C) :\n totalLength C n t ≤ n * maxLength C := by sorry\n/-- The core counting bound: `A(n,k) / D^k ≤ 1`. -/\n\nlemma sum_inv_by_length_le (C : Code σ) (hC : UniquelyDecodable C)\n (n k : ℕ) :\n (Fintype.card { t : Fin n → C // totalLength C n t = k } : ℚ) /\n ((Fintype.card σ : ℚ) ^ k) ≤ 1 := by sorry\n/-- `(kraftSum C) ^ n ≤ n * maxLength C + 1`.\nThe proof expands `K^n` as a sum over `n`-tuples, then regroups by total length:\n `K^n = ∑_t D^{-totalLength(t)} = ∑_{k=0}^{nL} A(n,k) · D^{-k}`\nwhere `A(n,k) = |{t : totalLength t = k}|` and `L = maxLength C`.\nEach fiber contributes `A(n,k) / D^k ≤ 1` (by `count_tuples_le`),\nand there are `nL + 1` fibers. -/\n\nlemma kraftSum_pow_le (C : Code σ) (hC : UniquelyDecodable C) (n : ℕ) :\n (kraftSum C) ^ n ≤ ↑(n * maxLength C + 1) := by sorry\n/-- Bernoulli's inequality over `ℚ`: `(1 + a)^n ≥ 1 + na` for `a ≥ 0`. -/\n\nlemma bernoulli_ineq {a : ℚ} (ha : 0 ≤ a) (n : ℕ) :\n 1 + ↑n * a ≤ (1 + a) ^ n := by sorry"} -{"project_name": "McMillan", "name": "mcmillan", "type": "theorem", "code": "import Mathlib\n\nuniverse u\n\nvariable {σ : Type u} [Fintype σ] [Nonempty σ]\n/-- **McMillan's Theorem**: Every uniquely decodable code satisfies the\nKraft inequality: `kraftSum C ≤ 1`. -/\n\ntheorem mcmillan (C : Code σ) (hC : UniquelyDecodable C) :\n kraftSum C ≤ 1 := by sorry", "imported_file": "-- File: LiveLeanTriathlon.McMillan.BackgroundLemmas\nopen scoped BigOperators\nuniverse u\nvariable {σ : Type*} [Fintype σ] [Nonempty σ]\n/-- A `Code σ` is a finite set of codewords over alphabet `σ`. -/\nabbrev Code (σ : Type*) := Finset (List σ)\n/-- Encode a sequence of codewords from `C` by concatenating them. -/\ndef encode (C : Code σ) (ws : List C) : List σ :=\n (ws.map (·.val)).flatten\n/-- A code `C` is *uniquely decodable* if no two distinct sequences of\ncodewords from `C` produce the same encoded string. -/\ndef UniquelyDecodable (C : Code σ) : Prop :=\n Function.Injective (encode C)\n/-- The Kraft sum of a code `C` over alphabet `σ`.\n `kraftSum C = ∑ w ∈ C, D⁻ˡᵉⁿ⁽ʷ⁾` where `D = |σ|`. -/\ndef kraftSum (C : Code σ) : ℚ :=\n ∑ w ∈ C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ w.length)\n/-- The maximum codeword length in a code. Returns 0 for empty codes. -/\ndef maxLength (C : Code σ) : ℕ :=\n C.sup List.length\n/-- The total length of an n-tuple of codewords. -/\ndef totalLength (C : Code σ) (n : ℕ) (t : Fin n → C) : ℕ :=\n ∑ i, (t i).val.length\n/-- The concatenation of an n-tuple of codewords. -/\ndef tupleEncode (C : Code σ) (n : ℕ) (t : Fin n → C) : List σ :=\n (List.ofFn (fun i => (t i).val)).flatten\nomit [Fintype σ] [Nonempty σ] in\n/-- `tupleEncode C n` equals `encode C ∘ List.ofFn`. -/\nlemma tupleEncode_eq_encode_ofFn (C : Code σ) (n : ℕ) (t : Fin n → C) :\n tupleEncode C n t = encode C (List.ofFn t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- Unique decodability implies `tupleEncode C n` is injective:\nif two n-tuples of codewords concatenate to the same string, they are equal. -/\nlemma tupleEncode_injective (C : Code σ) (hC : UniquelyDecodable C)\n (n : ℕ) : Function.Injective (tupleEncode C n) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The length of `tupleEncode C n t` equals the total length of the tuple. -/\nlemma tupleEncode_length (C : Code σ) (n : ℕ) (t : Fin n → C) :\n (tupleEncode C n t).length = totalLength C n t := by sorry\nomit [Nonempty σ] in\n/-- The number of n-tuples of codewords from `C` with total length `k` is\nat most `D^k`, where `D = Fintype.card σ`. This follows from injectivity\nof `tupleEncode`: distinct tuples map to distinct strings of length `k`,\nand strings of length `k` correspond to `Fin k → σ` which has `D^k` elements. -/\nlemma count_tuples_le (C : Code σ) (hC : UniquelyDecodable C) (n k : ℕ) :\n Fintype.card { t : Fin n → C // totalLength C n t = k } ≤\n (Fintype.card σ) ^ k := by sorry\nomit [Nonempty σ] in\n/-- kraftSum as a sum over the subtype ↥C. -/\nlemma kraftSum_eq_sum_subtype (C : Code σ) :\n kraftSum C =\n ∑ w : C, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (w : List σ).length) := by sorry\nomit [Nonempty σ] in\n/-- The `n`-th power of the Kraft sum expanded as a sum over tuples. -/\nlemma kraftSum_pow_eq_sum_tuples (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C, ∏ i : Fin n,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) := by sorry\nomit [Nonempty σ] in\n/-- Each tuple contributes `D^{-totalLength t}`. -/\nlemma tuple_contrib (C : Code σ) (n : ℕ) (t : Fin n → C) :\n ∏ i : Fin n, (1 : ℚ) / ((Fintype.card σ : ℚ) ^ (t i).val.length) =\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Nonempty σ] in\n/-- `K^n` as a sum of `D^{-totalLength t}` over all `n`-tuples. -/\nlemma kraftSum_pow_eq_sum_inv (C : Code σ) (n : ℕ) :\n (kraftSum C) ^ n =\n ∑ t : Fin n → C,\n (1 : ℚ) / ((Fintype.card σ : ℚ) ^ totalLength C n t) := by sorry\nomit [Fintype σ] [Nonempty σ] in\n/-- The total length of any `n`-tuple is at most `n * maxLength C`. -/\nlemma totalLength_le_mul_maxLength (C : Code σ) (n : ℕ) (t : Fin n → C) :\n totalLength C n t ≤ n * maxLength C := by sorry\n/-- The core counting bound: `A(n,k) / D^k ≤ 1`. -/\nlemma sum_inv_by_length_le (C : Code σ) (hC : UniquelyDecodable C)\n (n k : ℕ) :\n (Fintype.card { t : Fin n → C // totalLength C n t = k } : ℚ) /\n ((Fintype.card σ : ℚ) ^ k) ≤ 1 := by sorry\n/-- `(kraftSum C) ^ n ≤ n * maxLength C + 1`.\nThe proof expands `K^n` as a sum over `n`-tuples, then regroups by total length:\n `K^n = ∑_t D^{-totalLength(t)} = ∑_{k=0}^{nL} A(n,k) · D^{-k}`\nwhere `A(n,k) = |{t : totalLength t = k}|` and `L = maxLength C`.\nEach fiber contributes `A(n,k) / D^k ≤ 1` (by `count_tuples_le`),\nand there are `nL + 1` fibers. -/\nlemma kraftSum_pow_le (C : Code σ) (hC : UniquelyDecodable C) (n : ℕ) :\n (kraftSum C) ^ n ≤ ↑(n * maxLength C + 1) := by sorry\n/-- Bernoulli's inequality over `ℚ`: `(1 + a)^n ≥ 1 + na` for `a ≥ 0`. -/\nlemma bernoulli_ineq {a : ℚ} (ha : 0 ≤ a) (n : ℕ) :\n 1 + ↑n * a ≤ (1 + a) ^ n := by sorry"} -{"project_name": "MergelyanTheorem", "name": "mergelyan", "type": "theorem", "code": "import Mathlib\n\ntheorem mergelyan {K : Set ℂ} (K_compact : IsCompact K) (K_conn : IsConnected Kᶜ)\n {f : ℂ → ℂ} (f_cont : ContinuousOn f K) (f_diff : DifferentiableOn ℂ f (interior K)) :\n ∀ ε > 0, ∃ p : Polynomial ℂ, ∀ x ∈ K, ‖f x - p.eval x‖ₑ < ε := by sorry"} -{"project_name": "MertensFirstTheorem", "name": "merten_first", "type": "theorem", "code": "import Mathlib\n\nopen Nat Set\n/-- Set of the primes -/\n\ndef Primes' : Set ℕ := {p | p.Prime}\n/-- Primes less than a number -/\n\ndef PrimesLe (n : ℕ) : Set ℕ := Icc 0 n ∩ Primes'\n/-- First theorem -/\n\ntheorem merten_first {n : ℕ} (hn : 2 ≤ n) :\n - Real.log n + ∑' k : PrimesLe n, Real.log k / k ≤ 2 := by sorry"} -{"project_name": "Mistakes", "name": "logDeriv_Polynomial_mistaken", "type": "lemma", "code": "import Mathlib\n\nnamespace Mistakes\n\nsection\n\nopen Polynomial\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\nNote: This formalization has an error due to the use of `p.roots.toFinset`, which removes\nmultiplicities of roots. The correct statement should account for the multiplicities of each root.\n-/\n\nlemma logDeriv_Polynomial_mistaken (p : ℂ[X]) :\n logDeriv p.eval = fun z => ∑ r ∈ p.roots.toFinset, (z - r)⁻¹ := by sorry"} -{"project_name": "Mistakes", "name": "dilworth", "type": "lemma", "code": "import Mathlib\n\nnamespace Mistakes\n\nsection\n\nopen Polynomial\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\nNote: This formalization has an error due to the use of `p.roots.toFinset`, which removes\nmultiplicities of roots. The correct statement should account for the multiplicities of each root.\n-/\n\nlemma logDeriv_Polynomial_mistaken (p : ℂ[X]) :\n logDeriv p.eval = fun z => ∑ r ∈ p.roots.toFinset, (z - r)⁻¹ := by sorry\n\nend\n\nsection Dilworth\n\nopen Finset\n\nuniverse u\n\nvariable {P : Type u} [PartialOrder P] [Fintype P]\n/-- This definition of a chain partition for Dilworth's theorem is flawed - it is missing a condition that the members of the partition should be nonempty. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nThe Dilworth's theorem statement below is also flawed due to the `IsLeast` and `IsGreatest` being swapped.\n-/\n\nlemma dilworth (S : Finset P) :\n ∃ n,\n IsLeast { k | ∃ (s : Finset P), s ⊆ S ∧ IsAntichain (· ≤ ·) (SetLike.coe s) ∧ s.card = k } n\n ∧\n IsGreatest { k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧ C.card = k } n := by sorry"} -{"project_name": "Mistakes", "name": "exists_interval_measure_inter_gt_mul_measure_mistaken", "type": "theorem", "code": "import Mathlib\n\nnamespace Mistakes\n\nsection\n\nopen Polynomial\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\nNote: This formalization has an error due to the use of `p.roots.toFinset`, which removes\nmultiplicities of roots. The correct statement should account for the multiplicities of each root.\n-/\n\nlemma logDeriv_Polynomial_mistaken (p : ℂ[X]) :\n logDeriv p.eval = fun z => ∑ r ∈ p.roots.toFinset, (z - r)⁻¹ := by sorry\n\nend\n\nsection Dilworth\n\nopen Finset\n\nuniverse u\n\nvariable {P : Type u} [PartialOrder P] [Fintype P]\n/-- This definition of a chain partition for Dilworth's theorem is flawed - it is missing a condition that the members of the partition should be nonempty. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nThe Dilworth's theorem statement below is also flawed due to the `IsLeast` and `IsGreatest` being swapped.\n-/\n\nlemma dilworth (S : Finset P) :\n ∃ n,\n IsLeast { k | ∃ (s : Finset P), s ⊆ S ∧ IsAntichain (· ≤ ·) (SetLike.coe s) ∧ s.card = k } n\n ∧\n IsGreatest { k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧ C.card = k } n := by sorry\n\nend Dilworth\n\nsection DifferenceSetContainsInterval\n\nopen Real Set Pointwise MeasureTheory\n/--\nNote: This formalization has an error due to using A rather than J in the statement of the theorem.\n-/\n\ntheorem exists_interval_measure_inter_gt_mul_measure_mistaken {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior A).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry"} -{"project_name": "Mistakes", "name": "diller_dress", "type": "theorem", "code": "import Mathlib\n\nnamespace Mistakes\n\nsection\n\nopen Polynomial\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\nNote: This formalization has an error due to the use of `p.roots.toFinset`, which removes\nmultiplicities of roots. The correct statement should account for the multiplicities of each root.\n-/\n\nlemma logDeriv_Polynomial_mistaken (p : ℂ[X]) :\n logDeriv p.eval = fun z => ∑ r ∈ p.roots.toFinset, (z - r)⁻¹ := by sorry\n\nend\n\nsection Dilworth\n\nopen Finset\n\nuniverse u\n\nvariable {P : Type u} [PartialOrder P] [Fintype P]\n/-- This definition of a chain partition for Dilworth's theorem is flawed - it is missing a condition that the members of the partition should be nonempty. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nThe Dilworth's theorem statement below is also flawed due to the `IsLeast` and `IsGreatest` being swapped.\n-/\n\nlemma dilworth (S : Finset P) :\n ∃ n,\n IsLeast { k | ∃ (s : Finset P), s ⊆ S ∧ IsAntichain (· ≤ ·) (SetLike.coe s) ∧ s.card = k } n\n ∧\n IsGreatest { k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧ C.card = k } n := by sorry\n\nend Dilworth\n\nsection DifferenceSetContainsInterval\n\nopen Real Set Pointwise MeasureTheory\n/--\nNote: This formalization has an error due to using A rather than J in the statement of the theorem.\n-/\n\ntheorem exists_interval_measure_inter_gt_mul_measure_mistaken {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior A).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry\n\nend DifferenceSetContainsInterval\n\nsection DillerDress\n\nuniverse u\n/-- A (semi)ring is Pythagorean if every sum of two squares is itself a square. -/\n\nclass Pythagorean (R : Type u) [Semiring R] : Prop where\n sum_sq : ∀ a b : R, IsSquare (a ^ 2 + b ^ 2)\n/--\nK and L are permuted here, the theorem should state that the smaller field (K) is Pythagorean, as a consequence of the larger field (L) being Pythagorean.\n-/\n\ntheorem diller_dress (K L : Type*) [Field K] [Field L] [Algebra K L] [Module.Finite K L]\n [Pythagorean K] : Pythagorean L := by sorry"} -{"project_name": "Mistakes", "name": "ErdosGallaiTheorem", "type": "theorem", "code": "import Mathlib\n\nnamespace Mistakes\n\nsection\n\nopen Polynomial\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\nNote: This formalization has an error due to the use of `p.roots.toFinset`, which removes\nmultiplicities of roots. The correct statement should account for the multiplicities of each root.\n-/\n\nlemma logDeriv_Polynomial_mistaken (p : ℂ[X]) :\n logDeriv p.eval = fun z => ∑ r ∈ p.roots.toFinset, (z - r)⁻¹ := by sorry\n\nend\n\nsection Dilworth\n\nopen Finset\n\nuniverse u\n\nvariable {P : Type u} [PartialOrder P] [Fintype P]\n/-- This definition of a chain partition for Dilworth's theorem is flawed - it is missing a condition that the members of the partition should be nonempty. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nThe Dilworth's theorem statement below is also flawed due to the `IsLeast` and `IsGreatest` being swapped.\n-/\n\nlemma dilworth (S : Finset P) :\n ∃ n,\n IsLeast { k | ∃ (s : Finset P), s ⊆ S ∧ IsAntichain (· ≤ ·) (SetLike.coe s) ∧ s.card = k } n\n ∧\n IsGreatest { k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧ C.card = k } n := by sorry\n\nend Dilworth\n\nsection DifferenceSetContainsInterval\n\nopen Real Set Pointwise MeasureTheory\n/--\nNote: This formalization has an error due to using A rather than J in the statement of the theorem.\n-/\n\ntheorem exists_interval_measure_inter_gt_mul_measure_mistaken {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior A).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry\n\nend DifferenceSetContainsInterval\n\nsection DillerDress\n\nuniverse u\n/-- A (semi)ring is Pythagorean if every sum of two squares is itself a square. -/\n\nclass Pythagorean (R : Type u) [Semiring R] : Prop where\n sum_sq : ∀ a b : R, IsSquare (a ^ 2 + b ^ 2)\n/--\nK and L are permuted here, the theorem should state that the smaller field (K) is Pythagorean, as a consequence of the larger field (L) being Pythagorean.\n-/\n\ntheorem diller_dress (K L : Type*) [Field K] [Field L] [Algebra K L] [Module.Finite K L]\n [Pythagorean K] : Pythagorean L := by sorry\n\nend DillerDress\n\nsection ErdosGallai\n/--\nThe multiset of degrees of a finite graph.\n-/\n\ndef degreeMultiset {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n Multiset ℕ :=\n (Finset.univ : Finset V).val.map (fun v => G.degree v)\n/--\nThe list of degrees of a finite graph, sorted in non-increasing order.\n-/\n\ndef degreeList {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n List ℕ :=\n (degreeMultiset G).sort (· ≥ ·)\n/--\nThe theorem lacks the condition that the degree sequence should be non-increasing.\n-/\n\ntheorem ErdosGallaiTheorem (d : List ℕ) :\n (∃ V, ∃ fV : Fintype V, ∃ G : SimpleGraph V, ∃ dG : DecidableRel G.Adj, degreeList G = d) ↔\n Even d.sum ∧\n ∀ k ∈ Set.Ioc 0 d.length,\n (d.take k).sum ≤ k * (k - 1) + ((d.drop k).map fun x => min x k).sum := by sorry"} -{"project_name": "Mistakes", "name": "borsuk_ulam", "type": "theorem", "code": "import Mathlib\n\nnamespace Mistakes\n\nsection\n\nopen Polynomial\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\nNote: This formalization has an error due to the use of `p.roots.toFinset`, which removes\nmultiplicities of roots. The correct statement should account for the multiplicities of each root.\n-/\n\nlemma logDeriv_Polynomial_mistaken (p : ℂ[X]) :\n logDeriv p.eval = fun z => ∑ r ∈ p.roots.toFinset, (z - r)⁻¹ := by sorry\n\nend\n\nsection Dilworth\n\nopen Finset\n\nuniverse u\n\nvariable {P : Type u} [PartialOrder P] [Fintype P]\n/-- This definition of a chain partition for Dilworth's theorem is flawed - it is missing a condition that the members of the partition should be nonempty. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nThe Dilworth's theorem statement below is also flawed due to the `IsLeast` and `IsGreatest` being swapped.\n-/\n\nlemma dilworth (S : Finset P) :\n ∃ n,\n IsLeast { k | ∃ (s : Finset P), s ⊆ S ∧ IsAntichain (· ≤ ·) (SetLike.coe s) ∧ s.card = k } n\n ∧\n IsGreatest { k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧ C.card = k } n := by sorry\n\nend Dilworth\n\nsection DifferenceSetContainsInterval\n\nopen Real Set Pointwise MeasureTheory\n/--\nNote: This formalization has an error due to using A rather than J in the statement of the theorem.\n-/\n\ntheorem exists_interval_measure_inter_gt_mul_measure_mistaken {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior A).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry\n\nend DifferenceSetContainsInterval\n\nsection DillerDress\n\nuniverse u\n/-- A (semi)ring is Pythagorean if every sum of two squares is itself a square. -/\n\nclass Pythagorean (R : Type u) [Semiring R] : Prop where\n sum_sq : ∀ a b : R, IsSquare (a ^ 2 + b ^ 2)\n/--\nK and L are permuted here, the theorem should state that the smaller field (K) is Pythagorean, as a consequence of the larger field (L) being Pythagorean.\n-/\n\ntheorem diller_dress (K L : Type*) [Field K] [Field L] [Algebra K L] [Module.Finite K L]\n [Pythagorean K] : Pythagorean L := by sorry\n\nend DillerDress\n\nsection ErdosGallai\n/--\nThe multiset of degrees of a finite graph.\n-/\n\ndef degreeMultiset {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n Multiset ℕ :=\n (Finset.univ : Finset V).val.map (fun v => G.degree v)\n/--\nThe list of degrees of a finite graph, sorted in non-increasing order.\n-/\n\ndef degreeList {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n List ℕ :=\n (degreeMultiset G).sort (· ≥ ·)\n/--\nThe theorem lacks the condition that the degree sequence should be non-increasing.\n-/\n\ntheorem ErdosGallaiTheorem (d : List ℕ) :\n (∃ V, ∃ fV : Fintype V, ∃ G : SimpleGraph V, ∃ dG : DecidableRel G.Adj, degreeList G = d) ↔\n Even d.sum ∧\n ∀ k ∈ Set.Ioc 0 d.length,\n (d.take k).sum ≤ k * (k - 1) + ((d.drop k).map fun x => min x k).sum := by sorry\n\nend ErdosGallai\n\nsection BorsukUlam\n\nopen Metric\n/--\nThe issue here is that the type lifter from the set `sphere (0 : (Fin n → ℝ)) 1`\nis not the `n`-sphere `S^n` to which the theorem refers, but rather `S^(n-1)`.\nThe `n`-sphere is defined as the set of points in `ℝ^(n+1)` at distance 1 from the origin,\n(so that the dimensionality of the manifold matches the name,\nnot the dimensionality of the ambient space),\nso the correct type should be `sphere (0 : (Fin (n + 1) → ℝ)) 1`.\n-/\n\ntheorem borsuk_ulam (n : ℕ) {g : sphere (0 : (Fin n → ℝ)) 1 → Fin n → ℝ}\n (hg : ∀ x : sphere (0 : (Fin n → ℝ)) 1, g (-x) = g x) (cont : Continuous g):\n ∃ x : sphere (0 : (Fin n → ℝ)) 1, g x = 0 := by sorry"} -{"project_name": "Mistakes", "name": "riemann_summation", "type": "theorem", "code": "import Mathlib\n\nnamespace Mistakes\n\nsection\n\nopen Polynomial\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\nNote: This formalization has an error due to the use of `p.roots.toFinset`, which removes\nmultiplicities of roots. The correct statement should account for the multiplicities of each root.\n-/\n\nlemma logDeriv_Polynomial_mistaken (p : ℂ[X]) :\n logDeriv p.eval = fun z => ∑ r ∈ p.roots.toFinset, (z - r)⁻¹ := by sorry\n\nend\n\nsection Dilworth\n\nopen Finset\n\nuniverse u\n\nvariable {P : Type u} [PartialOrder P] [Fintype P]\n/-- This definition of a chain partition for Dilworth's theorem is flawed - it is missing a condition that the members of the partition should be nonempty. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nThe Dilworth's theorem statement below is also flawed due to the `IsLeast` and `IsGreatest` being swapped.\n-/\n\nlemma dilworth (S : Finset P) :\n ∃ n,\n IsLeast { k | ∃ (s : Finset P), s ⊆ S ∧ IsAntichain (· ≤ ·) (SetLike.coe s) ∧ s.card = k } n\n ∧\n IsGreatest { k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧ C.card = k } n := by sorry\n\nend Dilworth\n\nsection DifferenceSetContainsInterval\n\nopen Real Set Pointwise MeasureTheory\n/--\nNote: This formalization has an error due to using A rather than J in the statement of the theorem.\n-/\n\ntheorem exists_interval_measure_inter_gt_mul_measure_mistaken {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior A).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry\n\nend DifferenceSetContainsInterval\n\nsection DillerDress\n\nuniverse u\n/-- A (semi)ring is Pythagorean if every sum of two squares is itself a square. -/\n\nclass Pythagorean (R : Type u) [Semiring R] : Prop where\n sum_sq : ∀ a b : R, IsSquare (a ^ 2 + b ^ 2)\n/--\nK and L are permuted here, the theorem should state that the smaller field (K) is Pythagorean, as a consequence of the larger field (L) being Pythagorean.\n-/\n\ntheorem diller_dress (K L : Type*) [Field K] [Field L] [Algebra K L] [Module.Finite K L]\n [Pythagorean K] : Pythagorean L := by sorry\n\nend DillerDress\n\nsection ErdosGallai\n/--\nThe multiset of degrees of a finite graph.\n-/\n\ndef degreeMultiset {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n Multiset ℕ :=\n (Finset.univ : Finset V).val.map (fun v => G.degree v)\n/--\nThe list of degrees of a finite graph, sorted in non-increasing order.\n-/\n\ndef degreeList {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n List ℕ :=\n (degreeMultiset G).sort (· ≥ ·)\n/--\nThe theorem lacks the condition that the degree sequence should be non-increasing.\n-/\n\ntheorem ErdosGallaiTheorem (d : List ℕ) :\n (∃ V, ∃ fV : Fintype V, ∃ G : SimpleGraph V, ∃ dG : DecidableRel G.Adj, degreeList G = d) ↔\n Even d.sum ∧\n ∀ k ∈ Set.Ioc 0 d.length,\n (d.take k).sum ≤ k * (k - 1) + ((d.drop k).map fun x => min x k).sum := by sorry\n\nend ErdosGallai\n\nsection BorsukUlam\n\nopen Metric\n/--\nThe issue here is that the type lifter from the set `sphere (0 : (Fin n → ℝ)) 1`\nis not the `n`-sphere `S^n` to which the theorem refers, but rather `S^(n-1)`.\nThe `n`-sphere is defined as the set of points in `ℝ^(n+1)` at distance 1 from the origin,\n(so that the dimensionality of the manifold matches the name,\nnot the dimensionality of the ambient space),\nso the correct type should be `sphere (0 : (Fin (n + 1) → ℝ)) 1`.\n-/\n\ntheorem borsuk_ulam (n : ℕ) {g : sphere (0 : (Fin n → ℝ)) 1 → Fin n → ℝ}\n (hg : ∀ x : sphere (0 : (Fin n → ℝ)) 1, g (-x) = g x) (cont : Continuous g):\n ∃ x : sphere (0 : (Fin n → ℝ)) 1, g x = 0 := by sorry\n\nend BorsukUlam\n\nsection RiemannSeries\n\nopen Filter Function Topology\n/--\nThe issue here is that `Summable` is not the same as convergence of the sequence of partial sums.\nA sequence (and indeed the sequences highlighted by this theorem) can have convergent partial sums\nwithout being summable, which requires that they sum along the filter atTop of all finite sets.\n-/\n\ntheorem riemann_summation {a : ℕ → ℝ} (h : Summable a) (h' : ¬ Summable (fun n ↦ |a n|)) :\n ∀ r : ℝ, ∃ p : ℕ → ℕ,\n Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop (𝓝 r) := sorry"} -{"project_name": "Mistakes", "name": "riemann_summation_attop", "type": "theorem", "code": "import Mathlib\n\nnamespace Mistakes\n\nsection\n\nopen Polynomial\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\nNote: This formalization has an error due to the use of `p.roots.toFinset`, which removes\nmultiplicities of roots. The correct statement should account for the multiplicities of each root.\n-/\n\nlemma logDeriv_Polynomial_mistaken (p : ℂ[X]) :\n logDeriv p.eval = fun z => ∑ r ∈ p.roots.toFinset, (z - r)⁻¹ := by sorry\n\nend\n\nsection Dilworth\n\nopen Finset\n\nuniverse u\n\nvariable {P : Type u} [PartialOrder P] [Fintype P]\n/-- This definition of a chain partition for Dilworth's theorem is flawed - it is missing a condition that the members of the partition should be nonempty. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nThe Dilworth's theorem statement below is also flawed due to the `IsLeast` and `IsGreatest` being swapped.\n-/\n\nlemma dilworth (S : Finset P) :\n ∃ n,\n IsLeast { k | ∃ (s : Finset P), s ⊆ S ∧ IsAntichain (· ≤ ·) (SetLike.coe s) ∧ s.card = k } n\n ∧\n IsGreatest { k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧ C.card = k } n := by sorry\n\nend Dilworth\n\nsection DifferenceSetContainsInterval\n\nopen Real Set Pointwise MeasureTheory\n/--\nNote: This formalization has an error due to using A rather than J in the statement of the theorem.\n-/\n\ntheorem exists_interval_measure_inter_gt_mul_measure_mistaken {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior A).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry\n\nend DifferenceSetContainsInterval\n\nsection DillerDress\n\nuniverse u\n/-- A (semi)ring is Pythagorean if every sum of two squares is itself a square. -/\n\nclass Pythagorean (R : Type u) [Semiring R] : Prop where\n sum_sq : ∀ a b : R, IsSquare (a ^ 2 + b ^ 2)\n/--\nK and L are permuted here, the theorem should state that the smaller field (K) is Pythagorean, as a consequence of the larger field (L) being Pythagorean.\n-/\n\ntheorem diller_dress (K L : Type*) [Field K] [Field L] [Algebra K L] [Module.Finite K L]\n [Pythagorean K] : Pythagorean L := by sorry\n\nend DillerDress\n\nsection ErdosGallai\n/--\nThe multiset of degrees of a finite graph.\n-/\n\ndef degreeMultiset {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n Multiset ℕ :=\n (Finset.univ : Finset V).val.map (fun v => G.degree v)\n/--\nThe list of degrees of a finite graph, sorted in non-increasing order.\n-/\n\ndef degreeList {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n List ℕ :=\n (degreeMultiset G).sort (· ≥ ·)\n/--\nThe theorem lacks the condition that the degree sequence should be non-increasing.\n-/\n\ntheorem ErdosGallaiTheorem (d : List ℕ) :\n (∃ V, ∃ fV : Fintype V, ∃ G : SimpleGraph V, ∃ dG : DecidableRel G.Adj, degreeList G = d) ↔\n Even d.sum ∧\n ∀ k ∈ Set.Ioc 0 d.length,\n (d.take k).sum ≤ k * (k - 1) + ((d.drop k).map fun x => min x k).sum := by sorry\n\nend ErdosGallai\n\nsection BorsukUlam\n\nopen Metric\n/--\nThe issue here is that the type lifter from the set `sphere (0 : (Fin n → ℝ)) 1`\nis not the `n`-sphere `S^n` to which the theorem refers, but rather `S^(n-1)`.\nThe `n`-sphere is defined as the set of points in `ℝ^(n+1)` at distance 1 from the origin,\n(so that the dimensionality of the manifold matches the name,\nnot the dimensionality of the ambient space),\nso the correct type should be `sphere (0 : (Fin (n + 1) → ℝ)) 1`.\n-/\n\ntheorem borsuk_ulam (n : ℕ) {g : sphere (0 : (Fin n → ℝ)) 1 → Fin n → ℝ}\n (hg : ∀ x : sphere (0 : (Fin n → ℝ)) 1, g (-x) = g x) (cont : Continuous g):\n ∃ x : sphere (0 : (Fin n → ℝ)) 1, g x = 0 := by sorry\n\nend BorsukUlam\n\nsection RiemannSeries\n\nopen Filter Function Topology\n/--\nThe issue here is that `Summable` is not the same as convergence of the sequence of partial sums.\nA sequence (and indeed the sequences highlighted by this theorem) can have convergent partial sums\nwithout being summable, which requires that they sum along the filter atTop of all finite sets.\n-/\n\ntheorem riemann_summation {a : ℕ → ℝ} (h : Summable a) (h' : ¬ Summable (fun n ↦ |a n|)) :\n ∀ r : ℝ, ∃ p : ℕ → ℕ,\n Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop (𝓝 r) := sorry\n\ntheorem riemann_summation_attop {a : ℕ → ℝ} (h : Summable a) (h' : ¬ Summable (fun n ↦ |a n|)) :\n ∃ p : ℕ → ℕ, Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop atTop := sorry"} -{"project_name": "Mistakes", "name": "riemann_summation_atbot", "type": "theorem", "code": "import Mathlib\n\nnamespace Mistakes\n\nsection\n\nopen Polynomial\n/--\nThe logarithmic derivative of a complex polynomial (interpreted as a function from ℂ to ℂ)\nis the sum of the inverses of its factors.\nNote: This formalization has an error due to the use of `p.roots.toFinset`, which removes\nmultiplicities of roots. The correct statement should account for the multiplicities of each root.\n-/\n\nlemma logDeriv_Polynomial_mistaken (p : ℂ[X]) :\n logDeriv p.eval = fun z => ∑ r ∈ p.roots.toFinset, (z - r)⁻¹ := by sorry\n\nend\n\nsection Dilworth\n\nopen Finset\n\nuniverse u\n\nvariable {P : Type u} [PartialOrder P] [Fintype P]\n/-- This definition of a chain partition for Dilworth's theorem is flawed - it is missing a condition that the members of the partition should be nonempty. -/\n\ndef IsChainPartition (C : Set (Set P)) (S : Set P) : Prop :=\n (∀ c ∈ C, IsChain (· ≤ ·) c)\n ∧\n (∀ c₁ ∈ C, ∀ c₂ ∈ C, c₁ ≠ c₂ → Disjoint c₁ c₂)\n ∧\n (C.sUnion = S)\n/--\nThe Dilworth's theorem statement below is also flawed due to the `IsLeast` and `IsGreatest` being swapped.\n-/\n\nlemma dilworth (S : Finset P) :\n ∃ n,\n IsLeast { k | ∃ (s : Finset P), s ⊆ S ∧ IsAntichain (· ≤ ·) (SetLike.coe s) ∧ s.card = k } n\n ∧\n IsGreatest { k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧ C.card = k } n := by sorry\n\nend Dilworth\n\nsection DifferenceSetContainsInterval\n\nopen Real Set Pointwise MeasureTheory\n/--\nNote: This formalization has an error due to using A rather than J in the statement of the theorem.\n-/\n\ntheorem exists_interval_measure_inter_gt_mul_measure_mistaken {A : Set ℝ} (A_mble : MeasurableSet A)\n (A_pos : 0 < MeasureTheory.volume A) (A_fin : MeasureTheory.volume A < ⊤) {r : ENNReal}\n (r_lt_one : r < 1) :\n ∃ (J : Set ℝ), IsConnected J ∧ (interior A).Nonempty ∧\n MeasureTheory.volume (J ∩ A) > r * MeasureTheory.volume J := by sorry\n\nend DifferenceSetContainsInterval\n\nsection DillerDress\n\nuniverse u\n/-- A (semi)ring is Pythagorean if every sum of two squares is itself a square. -/\n\nclass Pythagorean (R : Type u) [Semiring R] : Prop where\n sum_sq : ∀ a b : R, IsSquare (a ^ 2 + b ^ 2)\n/--\nK and L are permuted here, the theorem should state that the smaller field (K) is Pythagorean, as a consequence of the larger field (L) being Pythagorean.\n-/\n\ntheorem diller_dress (K L : Type*) [Field K] [Field L] [Algebra K L] [Module.Finite K L]\n [Pythagorean K] : Pythagorean L := by sorry\n\nend DillerDress\n\nsection ErdosGallai\n/--\nThe multiset of degrees of a finite graph.\n-/\n\ndef degreeMultiset {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n Multiset ℕ :=\n (Finset.univ : Finset V).val.map (fun v => G.degree v)\n/--\nThe list of degrees of a finite graph, sorted in non-increasing order.\n-/\n\ndef degreeList {V : Type} [Fintype V] (G : SimpleGraph V) [DecidableRel G.Adj] :\n List ℕ :=\n (degreeMultiset G).sort (· ≥ ·)\n/--\nThe theorem lacks the condition that the degree sequence should be non-increasing.\n-/\n\ntheorem ErdosGallaiTheorem (d : List ℕ) :\n (∃ V, ∃ fV : Fintype V, ∃ G : SimpleGraph V, ∃ dG : DecidableRel G.Adj, degreeList G = d) ↔\n Even d.sum ∧\n ∀ k ∈ Set.Ioc 0 d.length,\n (d.take k).sum ≤ k * (k - 1) + ((d.drop k).map fun x => min x k).sum := by sorry\n\nend ErdosGallai\n\nsection BorsukUlam\n\nopen Metric\n/--\nThe issue here is that the type lifter from the set `sphere (0 : (Fin n → ℝ)) 1`\nis not the `n`-sphere `S^n` to which the theorem refers, but rather `S^(n-1)`.\nThe `n`-sphere is defined as the set of points in `ℝ^(n+1)` at distance 1 from the origin,\n(so that the dimensionality of the manifold matches the name,\nnot the dimensionality of the ambient space),\nso the correct type should be `sphere (0 : (Fin (n + 1) → ℝ)) 1`.\n-/\n\ntheorem borsuk_ulam (n : ℕ) {g : sphere (0 : (Fin n → ℝ)) 1 → Fin n → ℝ}\n (hg : ∀ x : sphere (0 : (Fin n → ℝ)) 1, g (-x) = g x) (cont : Continuous g):\n ∃ x : sphere (0 : (Fin n → ℝ)) 1, g x = 0 := by sorry\n\nend BorsukUlam\n\nsection RiemannSeries\n\nopen Filter Function Topology\n/--\nThe issue here is that `Summable` is not the same as convergence of the sequence of partial sums.\nA sequence (and indeed the sequences highlighted by this theorem) can have convergent partial sums\nwithout being summable, which requires that they sum along the filter atTop of all finite sets.\n-/\n\ntheorem riemann_summation {a : ℕ → ℝ} (h : Summable a) (h' : ¬ Summable (fun n ↦ |a n|)) :\n ∀ r : ℝ, ∃ p : ℕ → ℕ,\n Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop (𝓝 r) := sorry\n\ntheorem riemann_summation_attop {a : ℕ → ℝ} (h : Summable a) (h' : ¬ Summable (fun n ↦ |a n|)) :\n ∃ p : ℕ → ℕ, Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop atTop := sorry\n\ntheorem riemann_summation_atbot {a : ℕ → ℝ} (h : Summable a) (h' : ¬ Summable (fun n ↦ |a n|)) :\n ∃ p : ℕ → ℕ, Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop atBot := sorry"} -{"project_name": "MittagLeffler", "name": "nonempty_limit_of_nonempty_obj_of_MiLe", "type": "lemma", "code": "import Mathlib\n\nopen CategoryTheory Limits Functor\n\nuniverse u v\n\nvariable {I : Type u} [Preorder I] (F : Iᵒᵖ ⥤ Type v) [hI : Countable I] [IsDirected I (· ≤ ·)]\n@[stacks 0597]\n\nlemma nonempty_limit_of_nonempty_obj_of_MiLe (hF : F.IsMittagLeffler)\n (h : ∀ i :Iᵒᵖ, Nonempty (F.obj i)) : Nonempty (limit F) := by sorry"} -{"project_name": "MittagLeffler", "name": "IsMittagLeffler.mapShortExact", "type": "theorem", "code": "import Mathlib\n\nopen CategoryTheory Limits Functor\n\nuniverse u v\n\nvariable {I : Type u} [Preorder I] (F : Iᵒᵖ ⥤ Type v) [hI : Countable I] [IsDirected I (· ≤ ·)]\n@[stacks 0597]\n\nlemma nonempty_limit_of_nonempty_obj_of_MiLe (hF : F.IsMittagLeffler)\n (h : ∀ i :Iᵒᵖ, Nonempty (F.obj i)) : Nonempty (limit F) := by sorry\n\nset_option backward.isDefEq.respectTransparency false in\n\nopen ShortComplex Opposite in\n@[stacks 0598, AMS 18]\n\ntheorem IsMittagLeffler.mapShortExact (S : ShortComplex (Iᵒᵖ ⥤ Ab)) (hS : S.ShortExact)\n (hA : (S.X₁ ⋙ forget Ab).IsMittagLeffler) : (S.map lim).ShortExact := by sorry"} -{"project_name": "MycielskiTheorem", "name": "mycielskian_adj_inl_inl", "type": "theorem", "code": "import Mathlib\n\nnamespace SimpleGraph\n\nvariable {V : Type*} (G : SimpleGraph V)\n/-- The **Mycielskian** of a graph `G`. -/\n\ndef mycielskian : SimpleGraph (V ⊕ V ⊕ Unit) where\n Adj x y := match x, y with\n | .inl vi, .inl vj => G.Adj vi vj\n | .inl vi, .inr (.inl uj) => G.Adj vi uj\n | .inr (.inl ui), .inl vj => G.Adj ui vj\n | .inr (.inl _), .inr (.inr _) => True\n | .inr (.inr _), .inr (.inl _) => True\n | _, _ => False\n symm := by\n intro x y h\n rcases x with vi | ui | ⟨⟩ <;> rcases y with vj | uj | ⟨⟩ <;>\n first | exact G.symm h | exact h\n loopless := ⟨fun x h => by\n rcases x with v | u | ⟨⟩\n .\n exact G.loopless.irrefl v h\n .\n exact h\n .\n exact h⟩\n@[simp]\n\ntheorem mycielskian_adj_inl_inl (vi vj : V) :\n (G.mycielskian).Adj (.inl vi) (.inl vj) ↔ G.Adj vi vj := sorry"} -{"project_name": "MycielskiTheorem", "name": "mycielskian_adj_inl_shadow", "type": "theorem", "code": "import Mathlib\n\nnamespace SimpleGraph\n\nvariable {V : Type*} (G : SimpleGraph V)\n/-- The **Mycielskian** of a graph `G`. -/\n\ndef mycielskian : SimpleGraph (V ⊕ V ⊕ Unit) where\n Adj x y := match x, y with\n | .inl vi, .inl vj => G.Adj vi vj\n | .inl vi, .inr (.inl uj) => G.Adj vi uj\n | .inr (.inl ui), .inl vj => G.Adj ui vj\n | .inr (.inl _), .inr (.inr _) => True\n | .inr (.inr _), .inr (.inl _) => True\n | _, _ => False\n symm := by\n intro x y h\n rcases x with vi | ui | ⟨⟩ <;> rcases y with vj | uj | ⟨⟩ <;>\n first | exact G.symm h | exact h\n loopless := ⟨fun x h => by\n rcases x with v | u | ⟨⟩\n .\n exact G.loopless.irrefl v h\n .\n exact h\n .\n exact h⟩\n@[simp]\n\ntheorem mycielskian_adj_inl_inl (vi vj : V) :\n (G.mycielskian).Adj (.inl vi) (.inl vj) ↔ G.Adj vi vj := sorry\n@[simp]\n\ntheorem mycielskian_adj_inl_shadow (vi uj : V) :\n (G.mycielskian).Adj (.inl vi) (.inr (.inl uj)) ↔ G.Adj vi uj := sorry"} -{"project_name": "MycielskiTheorem", "name": "mycielskian_adj_shadow_inl", "type": "theorem", "code": "import Mathlib\n\nnamespace SimpleGraph\n\nvariable {V : Type*} (G : SimpleGraph V)\n/-- The **Mycielskian** of a graph `G`. -/\n\ndef mycielskian : SimpleGraph (V ⊕ V ⊕ Unit) where\n Adj x y := match x, y with\n | .inl vi, .inl vj => G.Adj vi vj\n | .inl vi, .inr (.inl uj) => G.Adj vi uj\n | .inr (.inl ui), .inl vj => G.Adj ui vj\n | .inr (.inl _), .inr (.inr _) => True\n | .inr (.inr _), .inr (.inl _) => True\n | _, _ => False\n symm := by\n intro x y h\n rcases x with vi | ui | ⟨⟩ <;> rcases y with vj | uj | ⟨⟩ <;>\n first | exact G.symm h | exact h\n loopless := ⟨fun x h => by\n rcases x with v | u | ⟨⟩\n .\n exact G.loopless.irrefl v h\n .\n exact h\n .\n exact h⟩\n@[simp]\n\ntheorem mycielskian_adj_inl_inl (vi vj : V) :\n (G.mycielskian).Adj (.inl vi) (.inl vj) ↔ G.Adj vi vj := sorry\n@[simp]\n\ntheorem mycielskian_adj_inl_shadow (vi uj : V) :\n (G.mycielskian).Adj (.inl vi) (.inr (.inl uj)) ↔ G.Adj vi uj := sorry\n@[simp]\n\ntheorem mycielskian_adj_shadow_inl (ui vj : V) :\n (G.mycielskian).Adj (.inr (.inl ui)) (.inl vj) ↔ G.Adj ui vj := sorry"} -{"project_name": "MycielskiTheorem", "name": "mycielskian_cliqueFree", "type": "theorem", "code": "import Mathlib\n\nnamespace SimpleGraph\n\nvariable {V : Type*} (G : SimpleGraph V)\n/-- The **Mycielskian** of a graph `G`. -/\n\ndef mycielskian : SimpleGraph (V ⊕ V ⊕ Unit) where\n Adj x y := match x, y with\n | .inl vi, .inl vj => G.Adj vi vj\n | .inl vi, .inr (.inl uj) => G.Adj vi uj\n | .inr (.inl ui), .inl vj => G.Adj ui vj\n | .inr (.inl _), .inr (.inr _) => True\n | .inr (.inr _), .inr (.inl _) => True\n | _, _ => False\n symm := by\n intro x y h\n rcases x with vi | ui | ⟨⟩ <;> rcases y with vj | uj | ⟨⟩ <;>\n first | exact G.symm h | exact h\n loopless := ⟨fun x h => by\n rcases x with v | u | ⟨⟩\n .\n exact G.loopless.irrefl v h\n .\n exact h\n .\n exact h⟩\n@[simp]\n\ntheorem mycielskian_adj_inl_inl (vi vj : V) :\n (G.mycielskian).Adj (.inl vi) (.inl vj) ↔ G.Adj vi vj := sorry\n@[simp]\n\ntheorem mycielskian_adj_inl_shadow (vi uj : V) :\n (G.mycielskian).Adj (.inl vi) (.inr (.inl uj)) ↔ G.Adj vi uj := sorry\n@[simp]\n\ntheorem mycielskian_adj_shadow_inl (ui vj : V) :\n (G.mycielskian).Adj (.inr (.inl ui)) (.inl vj) ↔ G.Adj ui vj := sorry\n/-- If `G` is triangle-free then the Mycielskian `μ(G)` is also triangle-free. -/\n\ntheorem mycielskian_cliqueFree (hG : G.CliqueFree 3) : (G.mycielskian).CliqueFree 3 := by sorry"} -{"project_name": "MycielskiTheorem", "name": "mycielskian_colorable_pred", "type": "theorem", "code": "import Mathlib\n\nnamespace SimpleGraph\n\nvariable {V : Type*} (G : SimpleGraph V)\n/-- The **Mycielskian** of a graph `G`. -/\n\ndef mycielskian : SimpleGraph (V ⊕ V ⊕ Unit) where\n Adj x y := match x, y with\n | .inl vi, .inl vj => G.Adj vi vj\n | .inl vi, .inr (.inl uj) => G.Adj vi uj\n | .inr (.inl ui), .inl vj => G.Adj ui vj\n | .inr (.inl _), .inr (.inr _) => True\n | .inr (.inr _), .inr (.inl _) => True\n | _, _ => False\n symm := by\n intro x y h\n rcases x with vi | ui | ⟨⟩ <;> rcases y with vj | uj | ⟨⟩ <;>\n first | exact G.symm h | exact h\n loopless := ⟨fun x h => by\n rcases x with v | u | ⟨⟩\n .\n exact G.loopless.irrefl v h\n .\n exact h\n .\n exact h⟩\n@[simp]\n\ntheorem mycielskian_adj_inl_inl (vi vj : V) :\n (G.mycielskian).Adj (.inl vi) (.inl vj) ↔ G.Adj vi vj := sorry\n@[simp]\n\ntheorem mycielskian_adj_inl_shadow (vi uj : V) :\n (G.mycielskian).Adj (.inl vi) (.inr (.inl uj)) ↔ G.Adj vi uj := sorry\n@[simp]\n\ntheorem mycielskian_adj_shadow_inl (ui vj : V) :\n (G.mycielskian).Adj (.inr (.inl ui)) (.inl vj) ↔ G.Adj ui vj := sorry\n/-- If `G` is triangle-free then the Mycielskian `μ(G)` is also triangle-free. -/\n\ntheorem mycielskian_cliqueFree (hG : G.CliqueFree 3) : (G.mycielskian).CliqueFree 3 := by sorry\n/-- A coloring of `μ(G)` with `n+1` colors yields a coloring of `G` with `n` colors.\nThis implies the Mycielskian strictly increases the chromatic number. -/\n\ntheorem mycielskian_colorable_pred (n : ℕ) :\n (G.mycielskian).Colorable (n + 1) → G.Colorable n := by sorry"} -{"project_name": "MycielskiTheorem", "name": "mycielski", "type": "theorem", "code": "import Mathlib\n\nnamespace SimpleGraph\n\nvariable {V : Type*} (G : SimpleGraph V)\n/-- The **Mycielskian** of a graph `G`. -/\n\ndef mycielskian : SimpleGraph (V ⊕ V ⊕ Unit) where\n Adj x y := match x, y with\n | .inl vi, .inl vj => G.Adj vi vj\n | .inl vi, .inr (.inl uj) => G.Adj vi uj\n | .inr (.inl ui), .inl vj => G.Adj ui vj\n | .inr (.inl _), .inr (.inr _) => True\n | .inr (.inr _), .inr (.inl _) => True\n | _, _ => False\n symm := by\n intro x y h\n rcases x with vi | ui | ⟨⟩ <;> rcases y with vj | uj | ⟨⟩ <;>\n first | exact G.symm h | exact h\n loopless := ⟨fun x h => by\n rcases x with v | u | ⟨⟩\n .\n exact G.loopless.irrefl v h\n .\n exact h\n .\n exact h⟩\n@[simp]\n\ntheorem mycielskian_adj_inl_inl (vi vj : V) :\n (G.mycielskian).Adj (.inl vi) (.inl vj) ↔ G.Adj vi vj := sorry\n@[simp]\n\ntheorem mycielskian_adj_inl_shadow (vi uj : V) :\n (G.mycielskian).Adj (.inl vi) (.inr (.inl uj)) ↔ G.Adj vi uj := sorry\n@[simp]\n\ntheorem mycielskian_adj_shadow_inl (ui vj : V) :\n (G.mycielskian).Adj (.inr (.inl ui)) (.inl vj) ↔ G.Adj ui vj := sorry\n/-- If `G` is triangle-free then the Mycielskian `μ(G)` is also triangle-free. -/\n\ntheorem mycielskian_cliqueFree (hG : G.CliqueFree 3) : (G.mycielskian).CliqueFree 3 := by sorry\n/-- A coloring of `μ(G)` with `n+1` colors yields a coloring of `G` with `n` colors.\nThis implies the Mycielskian strictly increases the chromatic number. -/\n\ntheorem mycielskian_colorable_pred (n : ℕ) :\n (G.mycielskian).Colorable (n + 1) → G.Colorable n := by sorry\n/-- **Mycielski's theorem**: for every `n`, there exists a triangle-free graph\nwith chromatic number at least `n`. -/\n\ntheorem mycielski (n : ℕ) :\n ∃ (W : Type) (H : SimpleGraph W), H.CliqueFree 3 ∧ (n : ℕ∞) ≤ H.chromaticNumber := by sorry"} -{"project_name": "NagellLutzTheorem", "name": "NagellLutz1", "type": "theorem", "code": "import Mathlib\n\ntheorem NagellLutz1 {E : WeierstrassCurve.Affine ℚ}\n (h1 : E.IsIntegral ℤ) (h2 : E.Δ ≠ 0) {x y : ℚ} (h : E.Nonsingular x y)\n (hx : 0 < addOrderOf (WeierstrassCurve.Affine.Point.some x y h)) :\n x ∈ (algebraMap ℤ ℚ).range ∧ y ∈ (algebraMap ℤ ℚ).range := sorry"} -{"project_name": "NagellLutzTheorem", "name": "NagellLutz2", "type": "theorem", "code": "import Mathlib\n\ntheorem NagellLutz1 {E : WeierstrassCurve.Affine ℚ}\n (h1 : E.IsIntegral ℤ) (h2 : E.Δ ≠ 0) {x y : ℚ} (h : E.Nonsingular x y)\n (hx : 0 < addOrderOf (WeierstrassCurve.Affine.Point.some x y h)) :\n x ∈ (algebraMap ℤ ℚ).range ∧ y ∈ (algebraMap ℤ ℚ).range := sorry\n\ntheorem NagellLutz2 {E : WeierstrassCurve.Affine ℚ}\n (h1 : E.IsIntegral ℤ)\n (h2 : E.Δ ≠ 0) {x y : ℚ} (h : E.Nonsingular x y)\n (hx : 0 < addOrderOf (WeierstrassCurve.Affine.Point.some x y h)) :\n (y = 0 ∧ addOrderOf (WeierstrassCurve.Affine.Point.some x y h) = 2) ∨\n (NagellLutz1 h1 h2 h hx).2.choose ^ 2 ∣ (E.Δ_integral_of_isIntegral ℤ).choose := sorry"} -{"project_name": "NonSquareFreeWeird", "name": "Abundant.mul_of_pos", "type": "lemma", "code": "import Mathlib\n\nopen Nat ArithmeticFunction.sigma\n\nsection Definitions\n/--\nThe odd part of a natural number `n` is the largest odd divisor of `n`.\n-/\n\ndef Nat.oddPart (n : ℕ) : ℕ := ordCompl[2] n\n\nend Definitions\n\nsection HelperLemmas\n\nlemma Abundant.mul_of_pos {n m : ℕ} (hn : Abundant n) (hm : 0 < m) : Abundant (n * m) := by sorry"} -{"project_name": "NonSquareFreeWeird", "name": "Nat.oddPart_of_odd", "type": "lemma", "code": "import Mathlib\n\nopen Nat ArithmeticFunction.sigma\n\nsection Definitions\n/--\nThe odd part of a natural number `n` is the largest odd divisor of `n`.\n-/\n\ndef Nat.oddPart (n : ℕ) : ℕ := ordCompl[2] n\n\nend Definitions\n\nsection HelperLemmas\n\nlemma Abundant.mul_of_pos {n m : ℕ} (hn : Abundant n) (hm : 0 < m) : Abundant (n * m) := by sorry\n\nlemma Nat.oddPart_of_odd {n : ℕ} (h : Odd n) : n.oddPart = n := by sorry"} -{"project_name": "NonSquareFreeWeird", "name": "Nat.Prime.not_squarefree_pow", "type": "lemma", "code": "import Mathlib\n\nopen Nat ArithmeticFunction.sigma\n\nsection Definitions\n/--\nThe odd part of a natural number `n` is the largest odd divisor of `n`.\n-/\n\ndef Nat.oddPart (n : ℕ) : ℕ := ordCompl[2] n\n\nend Definitions\n\nsection HelperLemmas\n\nlemma Abundant.mul_of_pos {n m : ℕ} (hn : Abundant n) (hm : 0 < m) : Abundant (n * m) := by sorry\n\nlemma Nat.oddPart_of_odd {n : ℕ} (h : Odd n) : n.oddPart = n := by sorry\n\nlemma Nat.Prime.not_squarefree_pow {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hn : 2 ≤ n) :\n ¬ Squarefree (p ^ n) := by sorry"} -{"project_name": "NonSquareFreeWeird", "name": "Nat.factorization_eq_zero_of_coprime", "type": "lemma", "code": "import Mathlib\n\nopen Nat ArithmeticFunction.sigma\n\nsection Definitions\n/--\nThe odd part of a natural number `n` is the largest odd divisor of `n`.\n-/\n\ndef Nat.oddPart (n : ℕ) : ℕ := ordCompl[2] n\n\nend Definitions\n\nsection HelperLemmas\n\nlemma Abundant.mul_of_pos {n m : ℕ} (hn : Abundant n) (hm : 0 < m) : Abundant (n * m) := by sorry\n\nlemma Nat.oddPart_of_odd {n : ℕ} (h : Odd n) : n.oddPart = n := by sorry\n\nlemma Nat.Prime.not_squarefree_pow {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hn : 2 ≤ n) :\n ¬ Squarefree (p ^ n) := by sorry\n\nlemma Nat.factorization_eq_zero_of_coprime {n p : ℕ} (hcoprime : Coprime n p) :\n n.factorization p = 0 := by sorry"} -{"project_name": "NonSquareFreeWeird", "name": "Nat.oddPart_mul", "type": "lemma", "code": "import Mathlib\n\nopen Nat ArithmeticFunction.sigma\n\nsection Definitions\n/--\nThe odd part of a natural number `n` is the largest odd divisor of `n`.\n-/\n\ndef Nat.oddPart (n : ℕ) : ℕ := ordCompl[2] n\n\nend Definitions\n\nsection HelperLemmas\n\nlemma Abundant.mul_of_pos {n m : ℕ} (hn : Abundant n) (hm : 0 < m) : Abundant (n * m) := by sorry\n\nlemma Nat.oddPart_of_odd {n : ℕ} (h : Odd n) : n.oddPart = n := by sorry\n\nlemma Nat.Prime.not_squarefree_pow {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hn : 2 ≤ n) :\n ¬ Squarefree (p ^ n) := by sorry\n\nlemma Nat.factorization_eq_zero_of_coprime {n p : ℕ} (hcoprime : Coprime n p) :\n n.factorization p = 0 := by sorry\n\nlemma Nat.oddPart_mul {n m : ℕ} :\n (n * m).oddPart = n.oddPart * m.oddPart := by sorry"} -{"project_name": "NonSquareFreeWeird", "name": "sum_filter_p_dvd_form", "type": "lemma", "code": "import Mathlib\n\nopen Nat ArithmeticFunction.sigma\n\nsection Definitions\n/--\nThe odd part of a natural number `n` is the largest odd divisor of `n`.\n-/\n\ndef Nat.oddPart (n : ℕ) : ℕ := ordCompl[2] n\n\nend Definitions\n\nsection HelperLemmas\n\nlemma Abundant.mul_of_pos {n m : ℕ} (hn : Abundant n) (hm : 0 < m) : Abundant (n * m) := by sorry\n\nlemma Nat.oddPart_of_odd {n : ℕ} (h : Odd n) : n.oddPart = n := by sorry\n\nlemma Nat.Prime.not_squarefree_pow {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hn : 2 ≤ n) :\n ¬ Squarefree (p ^ n) := by sorry\n\nlemma Nat.factorization_eq_zero_of_coprime {n p : ℕ} (hcoprime : Coprime n p) :\n n.factorization p = 0 := by sorry\n\nlemma Nat.oddPart_mul {n m : ℕ} :\n (n * m).oddPart = n.oddPart * m.oddPart := by sorry\nprivate lemma sum_filter_p_dvd_form {n p : ℕ} (hp : Nat.Prime p) {S : Finset ℕ}\n (hS₁_form : ∀ d ∈ S.filter (p ∣ ·), ∃ a, a ∣ n ∧ a < n ∧ d = a * p) :\n ∑ i ∈ S.filter (p ∣ ·), i = p * ∑ i ∈ (S.filter (p ∣ ·)).image (· / p), i := by sorry"} -{"project_name": "NonSquareFreeWeird", "name": "Weird.mul_prime_large", "type": "lemma", "code": "import Mathlib\n\nopen Nat ArithmeticFunction.sigma\n\nsection Definitions\n/--\nThe odd part of a natural number `n` is the largest odd divisor of `n`.\n-/\n\ndef Nat.oddPart (n : ℕ) : ℕ := ordCompl[2] n\n\nend Definitions\n\nsection HelperLemmas\n\nlemma Abundant.mul_of_pos {n m : ℕ} (hn : Abundant n) (hm : 0 < m) : Abundant (n * m) := by sorry\n\nlemma Nat.oddPart_of_odd {n : ℕ} (h : Odd n) : n.oddPart = n := by sorry\n\nlemma Nat.Prime.not_squarefree_pow {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hn : 2 ≤ n) :\n ¬ Squarefree (p ^ n) := by sorry\n\nlemma Nat.factorization_eq_zero_of_coprime {n p : ℕ} (hcoprime : Coprime n p) :\n n.factorization p = 0 := by sorry\n\nlemma Nat.oddPart_mul {n m : ℕ} :\n (n * m).oddPart = n.oddPart * m.oddPart := by sorry\nprivate lemma sum_filter_p_dvd_form {n p : ℕ} (hp : Nat.Prime p) {S : Finset ℕ}\n (hS₁_form : ∀ d ∈ S.filter (p ∣ ·), ∃ a, a ∣ n ∧ a < n ∧ d = a * p) :\n ∑ i ∈ S.filter (p ∣ ·), i = p * ∑ i ∈ (S.filter (p ∣ ·)).image (· / p), i := by sorry\n\nlemma Weird.mul_prime_large {n p : ℕ} (hn : Weird n) (hp : Nat.Prime p)\n (hlarge : σ 1 (ordCompl[p] n) < p) : Weird (n * p) := by sorry"} -{"project_name": "NonSquareFreeWeird", "name": "Weird.mul_prime_pow_large", "type": "lemma", "code": "import Mathlib\n\nopen Nat ArithmeticFunction.sigma\n\nsection Definitions\n/--\nThe odd part of a natural number `n` is the largest odd divisor of `n`.\n-/\n\ndef Nat.oddPart (n : ℕ) : ℕ := ordCompl[2] n\n\nend Definitions\n\nsection HelperLemmas\n\nlemma Abundant.mul_of_pos {n m : ℕ} (hn : Abundant n) (hm : 0 < m) : Abundant (n * m) := by sorry\n\nlemma Nat.oddPart_of_odd {n : ℕ} (h : Odd n) : n.oddPart = n := by sorry\n\nlemma Nat.Prime.not_squarefree_pow {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hn : 2 ≤ n) :\n ¬ Squarefree (p ^ n) := by sorry\n\nlemma Nat.factorization_eq_zero_of_coprime {n p : ℕ} (hcoprime : Coprime n p) :\n n.factorization p = 0 := by sorry\n\nlemma Nat.oddPart_mul {n m : ℕ} :\n (n * m).oddPart = n.oddPart * m.oddPart := by sorry\nprivate lemma sum_filter_p_dvd_form {n p : ℕ} (hp : Nat.Prime p) {S : Finset ℕ}\n (hS₁_form : ∀ d ∈ S.filter (p ∣ ·), ∃ a, a ∣ n ∧ a < n ∧ d = a * p) :\n ∑ i ∈ S.filter (p ∣ ·), i = p * ∑ i ∈ (S.filter (p ∣ ·)).image (· / p), i := by sorry\n\nlemma Weird.mul_prime_large {n p : ℕ} (hn : Weird n) (hp : Nat.Prime p)\n (hlarge : σ 1 (ordCompl[p] n) < p) : Weird (n * p) := by sorry\n\nlemma Weird.mul_prime_pow_large {n p k : ℕ} (hn : Weird n)\n (hp : Nat.Prime p) (hcoprime : Coprime n p) (hlarge : σ 1 n < p) : Weird (n * p ^ k) := by sorry"} -{"project_name": "NonSquareFreeWeird", "name": "weird_squarefree_infinite", "type": "theorem", "code": "import Mathlib\n\nopen Nat ArithmeticFunction.sigma\n\nsection Definitions\n/--\nThe odd part of a natural number `n` is the largest odd divisor of `n`.\n-/\n\ndef Nat.oddPart (n : ℕ) : ℕ := ordCompl[2] n\n\nend Definitions\n\nsection HelperLemmas\n\nlemma Abundant.mul_of_pos {n m : ℕ} (hn : Abundant n) (hm : 0 < m) : Abundant (n * m) := by sorry\n\nlemma Nat.oddPart_of_odd {n : ℕ} (h : Odd n) : n.oddPart = n := by sorry\n\nlemma Nat.Prime.not_squarefree_pow {p : ℕ} (hp : Nat.Prime p) {n : ℕ} (hn : 2 ≤ n) :\n ¬ Squarefree (p ^ n) := by sorry\n\nlemma Nat.factorization_eq_zero_of_coprime {n p : ℕ} (hcoprime : Coprime n p) :\n n.factorization p = 0 := by sorry\n\nlemma Nat.oddPart_mul {n m : ℕ} :\n (n * m).oddPart = n.oddPart * m.oddPart := by sorry\nprivate lemma sum_filter_p_dvd_form {n p : ℕ} (hp : Nat.Prime p) {S : Finset ℕ}\n (hS₁_form : ∀ d ∈ S.filter (p ∣ ·), ∃ a, a ∣ n ∧ a < n ∧ d = a * p) :\n ∑ i ∈ S.filter (p ∣ ·), i = p * ∑ i ∈ (S.filter (p ∣ ·)).image (· / p), i := by sorry\n\nlemma Weird.mul_prime_large {n p : ℕ} (hn : Weird n) (hp : Nat.Prime p)\n (hlarge : σ 1 (ordCompl[p] n) < p) : Weird (n * p) := by sorry\n\nlemma Weird.mul_prime_pow_large {n p k : ℕ} (hn : Weird n)\n (hp : Nat.Prime p) (hcoprime : Coprime n p) (hlarge : σ 1 n < p) : Weird (n * p ^ k) := by sorry\n\nend HelperLemmas\n\nsection MainTheorem\n\ntheorem weird_squarefree_infinite : ∀ N, ∃ n > N, Weird n ∧ ¬ Squarefree (n.oddPart) := by sorry"} -{"project_name": "OreTheorem", "name": "ore_maximal_hamiltonian_cycle_free_graph", "type": "lemma", "code": "import Mathlib\n/-- Auxiliary lemma for Ore's theorem: in a finite simple graph on `n ≥ 3` vertices\nthat is not Hamiltonian but becomes Hamiltonian when any edge is added,\nthe degree sum of any pair of distinct non-adjacent vertices is at most `n - 1`. -/\n\nlemma ore_maximal_hamiltonian_cycle_free_graph {α : Type*} [Fintype α] [DecidableEq α]\n (G : SimpleGraph α) [DecidableRel G.Adj]\n (hn : 3 ≤ Fintype.card α)\n (hG : ¬ G.IsHamiltonian)\n (hMax : ∀ (H : SimpleGraph α) [DecidableRel H.Adj], G < H → H.IsHamiltonian) :\n ∀ v w : α, v ≠ w → ¬ G.Adj v w → G.degree v + G.degree w ≤ Fintype.card α - 1 := by sorry"} -{"project_name": "OreTheorem", "name": "ore_theorem", "type": "theorem", "code": "import Mathlib\n/-- Auxiliary lemma for Ore's theorem: in a finite simple graph on `n ≥ 3` vertices\nthat is not Hamiltonian but becomes Hamiltonian when any edge is added,\nthe degree sum of any pair of distinct non-adjacent vertices is at most `n - 1`. -/\n\nlemma ore_maximal_hamiltonian_cycle_free_graph {α : Type*} [Fintype α] [DecidableEq α]\n (G : SimpleGraph α) [DecidableRel G.Adj]\n (hn : 3 ≤ Fintype.card α)\n (hG : ¬ G.IsHamiltonian)\n (hMax : ∀ (H : SimpleGraph α) [DecidableRel H.Adj], G < H → H.IsHamiltonian) :\n ∀ v w : α, v ≠ w → ¬ G.Adj v w → G.degree v + G.degree w ≤ Fintype.card α - 1 := by sorry\n/-- **Ore's Theorem**: If `G` is a finite simple graph on `n ≥ 3` vertices such that\n`deg v + deg w ≥ n` for every pair of distinct non-adjacent vertices `v` and `w`,\nthen `G` is Hamiltonian. -/\n\ntheorem ore_theorem {α : Type*} [Fintype α] [DecidableEq α] (G : SimpleGraph α)\n [DecidableRel G.Adj]\n (hn : 3 ≤ Fintype.card α)\n (h : ∀ v w : α, v ≠ w → ¬G.Adj v w → Fintype.card α ≤ G.degree v + G.degree w) :\n G.IsHamiltonian := by sorry"} -{"project_name": "PicardGroupUfd", "name": "Ideal.gcd_mem_of_flat", "type": "lemma", "code": "import Mathlib\n\nopen CommRing\n\nuniverse u\n\nvariable {R : Type u} [CommRing R] [IsDomain R] [UniqueFactorizationMonoid R]\nomit [UniqueFactorizationMonoid R] in\n/-- For a flat ideal in a GCD domain, the gcd of two elements in the ideal is in the ideal. -/\n\nlemma Ideal.gcd_mem_of_flat [GCDMonoid R] {I : Ideal R} [Module.Flat R I]\n {a b : R} (ha : a ∈ I) (hb : b ∈ I) : gcd a b ∈ I := by sorry"} -{"project_name": "PicardGroupUfd", "name": "Ideal.ne_bot_of_invertible", "type": "lemma", "code": "import Mathlib\n\nopen CommRing\n\nuniverse u\n\nvariable {R : Type u} [CommRing R] [IsDomain R] [UniqueFactorizationMonoid R]\nomit [UniqueFactorizationMonoid R] in\n/-- For a flat ideal in a GCD domain, the gcd of two elements in the ideal is in the ideal. -/\n\nlemma Ideal.gcd_mem_of_flat [GCDMonoid R] {I : Ideal R} [Module.Flat R I]\n {a b : R} (ha : a ∈ I) (hb : b ∈ I) : gcd a b ∈ I := by sorry\n\nsection InvertibleModuleFree\nomit [UniqueFactorizationMonoid R] in\n/-- An invertible ideal is nonzero. -/\n\nlemma Ideal.ne_bot_of_invertible\n (I : Ideal R) [Module.Invertible R I] :\n I ≠ ⊥ := by sorry"} -{"project_name": "PicardGroupUfd", "name": "Ideal.isPrincipal_of_invertible", "type": "lemma", "code": "import Mathlib\n\nopen CommRing\n\nuniverse u\n\nvariable {R : Type u} [CommRing R] [IsDomain R] [UniqueFactorizationMonoid R]\nomit [UniqueFactorizationMonoid R] in\n/-- For a flat ideal in a GCD domain, the gcd of two elements in the ideal is in the ideal. -/\n\nlemma Ideal.gcd_mem_of_flat [GCDMonoid R] {I : Ideal R} [Module.Flat R I]\n {a b : R} (ha : a ∈ I) (hb : b ∈ I) : gcd a b ∈ I := by sorry\n\nsection InvertibleModuleFree\nomit [UniqueFactorizationMonoid R] in\n/-- An invertible ideal is nonzero. -/\n\nlemma Ideal.ne_bot_of_invertible\n (I : Ideal R) [Module.Invertible R I] :\n I ≠ ⊥ := by sorry\n/-- An invertible ideal in a UFD is principal. -/\n\nlemma Ideal.isPrincipal_of_invertible\n (I : Ideal R) [Module.Invertible R I] :\n I.IsPrincipal := by sorry"} -{"project_name": "PicardGroupUfd", "name": "free_of_invertible_of_ufd", "type": "lemma", "code": "import Mathlib\n\nopen CommRing\n\nuniverse u\n\nvariable {R : Type u} [CommRing R] [IsDomain R] [UniqueFactorizationMonoid R]\nomit [UniqueFactorizationMonoid R] in\n/-- For a flat ideal in a GCD domain, the gcd of two elements in the ideal is in the ideal. -/\n\nlemma Ideal.gcd_mem_of_flat [GCDMonoid R] {I : Ideal R} [Module.Flat R I]\n {a b : R} (ha : a ∈ I) (hb : b ∈ I) : gcd a b ∈ I := by sorry\n\nsection InvertibleModuleFree\nomit [UniqueFactorizationMonoid R] in\n/-- An invertible ideal is nonzero. -/\n\nlemma Ideal.ne_bot_of_invertible\n (I : Ideal R) [Module.Invertible R I] :\n I ≠ ⊥ := by sorry\n/-- An invertible ideal in a UFD is principal. -/\n\nlemma Ideal.isPrincipal_of_invertible\n (I : Ideal R) [Module.Invertible R I] :\n I.IsPrincipal := by sorry\n/-- Every invertible module over a UFD is free. -/\n\nlemma free_of_invertible_of_ufd\n (M : Type u) [AddCommGroup M] [Module R M] [Module.Invertible R M] :\n Module.Free R M := by sorry"} -{"project_name": "PicardTheorem", "name": "picard", "type": "theorem", "code": "import Mathlib\n\nopen Function Set\n\ntheorem picard {f : ℂ → ℂ} (f_diff : Differentiable ℂ f) (f_ne_const : ∀ a : ℂ, ∃ b : ℂ, f b ≠ a) :\n ∃ x : ℂ, {x}ᶜ ⊆ range f := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "sum_of_three_odd_squares", "type": "lemma", "code": "import Mathlib\n\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "lemma1aAux", "type": "lemma", "code": "import Mathlib\n\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\n\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "lemma1b", "type": "lemma", "code": "import Mathlib\n\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\n\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\n\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "lemma2a", "type": "lemma", "code": "import Mathlib\n\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\n\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\n\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry\n\nlemma lemma2a (N m: ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (a b r : ℤ) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) (hb2 : b < 2/3 +\n √(8 * N / m - 8)): b ^ 2 < 4 * a := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "lemma2b", "type": "lemma", "code": "import Mathlib\n\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\n\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\n\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry\n\nlemma lemma2a (N m: ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (a b r : ℤ) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) (hb2 : b < 2/3 +\n √(8 * N / m - 8)): b ^ 2 < 4 * a := by sorry\nattribute [local grind! .] sq_nonneg in\n\nlemma lemma2b (N m: ℤ) (hm : 3 ≤ m) (hN : 2 * m ≤ N) (a b r : ℤ) (hr1 : 0 ≤ r) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) :\n 3 * a < b ^ 2 + 2 * b + 4 := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "sum_le_sum_sq", "type": "lemma", "code": "import Mathlib\n\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\n\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\n\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry\n\nlemma lemma2a (N m: ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (a b r : ℤ) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) (hb2 : b < 2/3 +\n √(8 * N / m - 8)): b ^ 2 < 4 * a := by sorry\nattribute [local grind! .] sq_nonneg in\n\nlemma lemma2b (N m: ℤ) (hm : 3 ≤ m) (hN : 2 * m ≤ N) (a b r : ℤ) (hr1 : 0 ≤ r) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) :\n 3 * a < b ^ 2 + 2 * b + 4 := by sorry\n\nlemma sum_le_sum_sq (x y z : ℝ) : x + y + z ≤ √3 * √(x ^ 2 + y ^ 2 + z ^ 2) := sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "sq_mod_8", "type": "lemma", "code": "import Mathlib\n\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\n\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\n\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry\n\nlemma lemma2a (N m: ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (a b r : ℤ) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) (hb2 : b < 2/3 +\n √(8 * N / m - 8)): b ^ 2 < 4 * a := by sorry\nattribute [local grind! .] sq_nonneg in\n\nlemma lemma2b (N m: ℤ) (hm : 3 ≤ m) (hN : 2 * m ≤ N) (a b r : ℤ) (hr1 : 0 ≤ r) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) :\n 3 * a < b ^ 2 + 2 * b + 4 := by sorry\n\nlemma sum_le_sum_sq (x y z : ℝ) : x + y + z ≤ √3 * √(x ^ 2 + y ^ 2 + z ^ 2) := sorry\n@[grind →]\n\nlemma sq_mod_8 (a : ℤ) (ha : Odd a) : a ^ 2 % 8 = 1 := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "lemma3", "type": "lemma", "code": "import Mathlib\n\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\n\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\n\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry\n\nlemma lemma2a (N m: ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (a b r : ℤ) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) (hb2 : b < 2/3 +\n √(8 * N / m - 8)): b ^ 2 < 4 * a := by sorry\nattribute [local grind! .] sq_nonneg in\n\nlemma lemma2b (N m: ℤ) (hm : 3 ≤ m) (hN : 2 * m ≤ N) (a b r : ℤ) (hr1 : 0 ≤ r) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) :\n 3 * a < b ^ 2 + 2 * b + 4 := by sorry\n\nlemma sum_le_sum_sq (x y z : ℝ) : x + y + z ≤ √3 * √(x ^ 2 + y ^ 2 + z ^ 2) := sorry\n@[grind →]\n\nlemma sq_mod_8 (a : ℤ) (ha : Odd a) : a ^ 2 % 8 = 1 := by sorry\n\nlemma lemma3 (a b : ℤ) (ha : Odd a) (hb : Odd b) (h1 : b ^ 2 < 4 * a) (h2 : 3 * a < b ^ 2 + 2 * b +\n 4) (hb : b ≥ 0): ∃ (s t u v : ℤ), a = s ^ 2 + t ^ 2 + u ^ 2 + v ^ 2 ∧ b = s + t +\n u + v := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "sum_of_three_triangles", "type": "theorem", "code": "import Mathlib\n/-- the polygonal numbers (should delete if have time) -/\n\ndef pol_num (m : ℤ) (k : ℤ) := m * k * (k - 1) / 2 + k\n\ntheorem sum_of_three_triangles (N : ℤ) (hN : N ≥ 0) : ∃ (k1 k2 k3 : ℤ), N = k1 * (k1 + 1) / 2 + k2\n * (k2 + 1) / 2 + k3 * (k3 + 1) / 2 := by sorry", "imported_file": "-- File: LiveLeanTriathlon.PolygonalNumberTheorem.BackgroundLemmas\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry\nlemma lemma2a (N m: ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (a b r : ℤ) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) (hb2 : b < 2/3 +\n √(8 * N / m - 8)): b ^ 2 < 4 * a := by sorry\nattribute [local grind! .] sq_nonneg in\nlemma lemma2b (N m: ℤ) (hm : 3 ≤ m) (hN : 2 * m ≤ N) (a b r : ℤ) (hr1 : 0 ≤ r) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) :\n 3 * a < b ^ 2 + 2 * b + 4 := by sorry\nlemma sum_le_sum_sq (x y z : ℝ) : x + y + z ≤ √3 * √(x ^ 2 + y ^ 2 + z ^ 2) := sorry\n@[grind →]\nlemma sq_mod_8 (a : ℤ) (ha : Odd a) : a ^ 2 % 8 = 1 := by sorry\nlemma lemma3 (a b : ℤ) (ha : Odd a) (hb : Odd b) (h1 : b ^ 2 < 4 * a) (h2 : 3 * a < b ^ 2 + 2 * b +\n 4) (hb : b ≥ 0): ∃ (s t u v : ℤ), a = s ^ 2 + t ^ 2 + u ^ 2 + v ^ 2 ∧ b = s + t +\n u + v := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "polygonal_number_theorem_odd", "type": "theorem", "code": "import Mathlib\n/-- the polygonal numbers (should delete if have time) -/\n\ndef pol_num (m : ℤ) (k : ℤ) := m * k * (k - 1) / 2 + k\n\ntheorem sum_of_three_triangles (N : ℤ) (hN : N ≥ 0) : ∃ (k1 k2 k3 : ℤ), N = k1 * (k1 + 1) / 2 + k2\n * (k2 + 1) / 2 + k3 * (k3 + 1) / 2 := by sorry\n\ntheorem polygonal_number_theorem_odd (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 28 * m ^ 3) (hm2 : Odd m) :\n ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num m k4 := by sorry", "imported_file": "-- File: LiveLeanTriathlon.PolygonalNumberTheorem.BackgroundLemmas\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry\nlemma lemma2a (N m: ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (a b r : ℤ) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) (hb2 : b < 2/3 +\n √(8 * N / m - 8)): b ^ 2 < 4 * a := by sorry\nattribute [local grind! .] sq_nonneg in\nlemma lemma2b (N m: ℤ) (hm : 3 ≤ m) (hN : 2 * m ≤ N) (a b r : ℤ) (hr1 : 0 ≤ r) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) :\n 3 * a < b ^ 2 + 2 * b + 4 := by sorry\nlemma sum_le_sum_sq (x y z : ℝ) : x + y + z ≤ √3 * √(x ^ 2 + y ^ 2 + z ^ 2) := sorry\n@[grind →]\nlemma sq_mod_8 (a : ℤ) (ha : Odd a) : a ^ 2 % 8 = 1 := by sorry\nlemma lemma3 (a b : ℤ) (ha : Odd a) (hb : Odd b) (h1 : b ^ 2 < 4 * a) (h2 : 3 * a < b ^ 2 + 2 * b +\n 4) (hb : b ≥ 0): ∃ (s t u v : ℤ), a = s ^ 2 + t ^ 2 + u ^ 2 + v ^ 2 ∧ b = s + t +\n u + v := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "polygonal_number_theorem_even'", "type": "lemma", "code": "import Mathlib\n/-- the polygonal numbers (should delete if have time) -/\n\ndef pol_num (m : ℤ) (k : ℤ) := m * k * (k - 1) / 2 + k\n\ntheorem sum_of_three_triangles (N : ℤ) (hN : N ≥ 0) : ∃ (k1 k2 k3 : ℤ), N = k1 * (k1 + 1) / 2 + k2\n * (k2 + 1) / 2 + k3 * (k3 + 1) / 2 := by sorry\n\ntheorem polygonal_number_theorem_odd (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 28 * m ^ 3) (hm2 : Odd m) :\n ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num m k4 := by sorry\n\nlemma polygonal_number_theorem_even' (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 7 * m ^ 3) (hN' : Odd N)\n (hm2 : Even m) : ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num\n m k4 := by sorry", "imported_file": "-- File: LiveLeanTriathlon.PolygonalNumberTheorem.BackgroundLemmas\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry\nlemma lemma2a (N m: ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (a b r : ℤ) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) (hb2 : b < 2/3 +\n √(8 * N / m - 8)): b ^ 2 < 4 * a := by sorry\nattribute [local grind! .] sq_nonneg in\nlemma lemma2b (N m: ℤ) (hm : 3 ≤ m) (hN : 2 * m ≤ N) (a b r : ℤ) (hr1 : 0 ≤ r) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) :\n 3 * a < b ^ 2 + 2 * b + 4 := by sorry\nlemma sum_le_sum_sq (x y z : ℝ) : x + y + z ≤ √3 * √(x ^ 2 + y ^ 2 + z ^ 2) := sorry\n@[grind →]\nlemma sq_mod_8 (a : ℤ) (ha : Odd a) : a ^ 2 % 8 = 1 := by sorry\nlemma lemma3 (a b : ℤ) (ha : Odd a) (hb : Odd b) (h1 : b ^ 2 < 4 * a) (h2 : 3 * a < b ^ 2 + 2 * b +\n 4) (hb : b ≥ 0): ∃ (s t u v : ℤ), a = s ^ 2 + t ^ 2 + u ^ 2 + v ^ 2 ∧ b = s + t +\n u + v := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "polygonal_number_theorem_even", "type": "theorem", "code": "import Mathlib\n/-- the polygonal numbers (should delete if have time) -/\n\ndef pol_num (m : ℤ) (k : ℤ) := m * k * (k - 1) / 2 + k\n\ntheorem sum_of_three_triangles (N : ℤ) (hN : N ≥ 0) : ∃ (k1 k2 k3 : ℤ), N = k1 * (k1 + 1) / 2 + k2\n * (k2 + 1) / 2 + k3 * (k3 + 1) / 2 := by sorry\n\ntheorem polygonal_number_theorem_odd (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 28 * m ^ 3) (hm2 : Odd m) :\n ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num m k4 := by sorry\n\nlemma polygonal_number_theorem_even' (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 7 * m ^ 3) (hN' : Odd N)\n (hm2 : Even m) : ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num\n m k4 := by sorry\n\ntheorem polygonal_number_theorem_even (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 28 * m ^ 3) (hm2 : Even m) :\n ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num m k4 ∨ N =\n pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num m k4 + 1 := by sorry", "imported_file": "-- File: LiveLeanTriathlon.PolygonalNumberTheorem.BackgroundLemmas\nlemma sum_of_three_odd_squares (N : ℤ) (hNpos : 0 ≤ N) (hN : N % 8 = 3) : ∃ (x y z : ℤ), Odd x ∧ Odd\n y ∧ Odd z ∧ N = x ^ 2 + y ^ 2 + z ^ 2 := by sorry\nlemma lemma1aAux (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN1 : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) -\n √(6 * N / m - 3) + 1/6) (l : ℝ) (h : N / m ≥ 7 * (l - 1 / 6) ^ 2 + 5) : l < L := by sorry\nlemma lemma1b (m : ℤ) (N : ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (L : ℝ) (hL : L = √(8 * N / m - 8) - √(6\n * N / m - 3)+ 1/6) (l : ℝ) (hl : 1 ≤ l) (h1 : 7 * l ^ 2 * m ^ 3 ≤ N) : l * m < L := sorry\nlemma lemma2a (N m: ℤ) (hm : m ≥ 3) (hN : N ≥ 2 * m) (a b r : ℤ) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) (hb2 : b < 2/3 +\n √(8 * N / m - 8)): b ^ 2 < 4 * a := by sorry\nattribute [local grind! .] sq_nonneg in\nlemma lemma2b (N m: ℤ) (hm : 3 ≤ m) (hN : 2 * m ≤ N) (a b r : ℤ) (hr1 : 0 ≤ r) (hr2 : r < m)\n (h : N = (m / (2 : ℝ)) * (a - b) + b + r) (hb1 : 1/2 + √(6 * N / m - 3) < b) :\n 3 * a < b ^ 2 + 2 * b + 4 := by sorry\nlemma sum_le_sum_sq (x y z : ℝ) : x + y + z ≤ √3 * √(x ^ 2 + y ^ 2 + z ^ 2) := sorry\n@[grind →]\nlemma sq_mod_8 (a : ℤ) (ha : Odd a) : a ^ 2 % 8 = 1 := by sorry\nlemma lemma3 (a b : ℤ) (ha : Odd a) (hb : Odd b) (h1 : b ^ 2 < 4 * a) (h2 : 3 * a < b ^ 2 + 2 * b +\n 4) (hb : b ≥ 0): ∃ (s t u v : ℤ), a = s ^ 2 + t ^ 2 + u ^ 2 + v ^ 2 ∧ b = s + t +\n u + v := by sorry"} -{"project_name": "PrekopaLeindler", "name": "one_dim_BMInequality", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry"} -{"project_name": "PrekopaLeindler", "name": "one_dim_BMInequality_of_nullmeasurable", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry"} -{"project_name": "PrekopaLeindler", "name": "PL_dim1_cond_swap", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n/-- condition for Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_cond (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (x y : EuclideanSpace ℝ (Fin 1)) → (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)\n\nlemma PL_dim1_cond_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_cond t f g h ↔ PL_dim1_cond (1 - t) g f h := by sorry"} -{"project_name": "PrekopaLeindler", "name": "PL_dim1_conclusion_swap", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n/-- condition for Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_cond (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (x y : EuclideanSpace ℝ (Fin 1)) → (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)\n\nlemma PL_dim1_cond_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_cond t f g h ↔ PL_dim1_cond (1 - t) g f h := by sorry\n/-- theorem content of Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_conclusion (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (1 - t) ^ (1 - t) * t ^ t * (∫ x, h x)\n\nlemma PL_dim1_conclusion_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_conclusion t f g h ↔ PL_dim1_conclusion (1 - t) g f h := by sorry"} -{"project_name": "PrekopaLeindler", "name": "superlevel_subset", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n/-- condition for Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_cond (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (x y : EuclideanSpace ℝ (Fin 1)) → (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)\n\nlemma PL_dim1_cond_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_cond t f g h ↔ PL_dim1_cond (1 - t) g f h := by sorry\n/-- theorem content of Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_conclusion (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (1 - t) ^ (1 - t) * t ^ t * (∫ x, h x)\n\nlemma PL_dim1_conclusion_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_conclusion t f g h ↔ PL_dim1_conclusion (1 - t) g f h := by sorry\n\nlemma superlevel_subset {t : ℝ} (ht1 : 0 < t) (ht3 : 0 < 1 - t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {l : ℝ} (hl_pos : 0 < l) (hPL : PL_dim1_cond t f g h) :\n superlevel_set f l + superlevel_set g l ⊆ superlevel_set h l := by sorry"} -{"project_name": "PrekopaLeindler", "name": "fgh_nor_splsets_vol_le", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n/-- condition for Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_cond (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (x y : EuclideanSpace ℝ (Fin 1)) → (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)\n\nlemma PL_dim1_cond_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_cond t f g h ↔ PL_dim1_cond (1 - t) g f h := by sorry\n/-- theorem content of Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_conclusion (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (1 - t) ^ (1 - t) * t ^ t * (∫ x, h x)\n\nlemma PL_dim1_conclusion_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_conclusion t f g h ↔ PL_dim1_conclusion (1 - t) g f h := by sorry\n\nlemma superlevel_subset {t : ℝ} (ht1 : 0 < t) (ht3 : 0 < 1 - t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {l : ℝ} (hl_pos : 0 < l) (hPL : PL_dim1_cond t f g h) :\n superlevel_set f l + superlevel_set g l ⊆ superlevel_set h l := by sorry\nattribute [local instance] WithLp.measurableSpace in\n\nlemma fgh_nor_splsets_vol_le {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {t l : ℝ} (ht1 : 0 < t)\n (hf1 : 0 ≤ f) (ht3 : 0 < 1 - t) (h0l : 0 < l) (hf3 : IsEssBdd f) (hf5 : 0 < essSup f volume)\n (hg1 : 0 ≤ g) (hg3 : IsEssBdd g) (hg5 : 0 < essSup g volume) (hPL : PL_dim1_cond t f g h)\n (hf6 : 0 ≤ fun x ↦ (f x) / essSup f volume) (hg6 : 0 ≤ fun x ↦ (g x) / essSup g volume)\n (hl1 : l < 1) (hf7 : Integrable (fun x ↦ (f x) / essSup f volume))\n (hg7 : Integrable (fun x ↦ (g x) / essSup g volume)) :\n volume (superlevel_set (fun x ↦ (f x) / essSup f volume) l) + volume (superlevel_set (fun x ↦\n (g x) / essSup g volume) l) ≤ volume (superlevel_set (fun x ↦ (h x) / (essSup f volume ^ (1 - t)\n * essSup g volume ^ t)) l) := by sorry"} -{"project_name": "PrekopaLeindler", "name": "prekopa_leindler_dim1_essBdd", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n/-- condition for Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_cond (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (x y : EuclideanSpace ℝ (Fin 1)) → (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)\n\nlemma PL_dim1_cond_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_cond t f g h ↔ PL_dim1_cond (1 - t) g f h := by sorry\n/-- theorem content of Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_conclusion (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (1 - t) ^ (1 - t) * t ^ t * (∫ x, h x)\n\nlemma PL_dim1_conclusion_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_conclusion t f g h ↔ PL_dim1_conclusion (1 - t) g f h := by sorry\n\nlemma superlevel_subset {t : ℝ} (ht1 : 0 < t) (ht3 : 0 < 1 - t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {l : ℝ} (hl_pos : 0 < l) (hPL : PL_dim1_cond t f g h) :\n superlevel_set f l + superlevel_set g l ⊆ superlevel_set h l := by sorry\nattribute [local instance] WithLp.measurableSpace in\n\nlemma fgh_nor_splsets_vol_le {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {t l : ℝ} (ht1 : 0 < t)\n (hf1 : 0 ≤ f) (ht3 : 0 < 1 - t) (h0l : 0 < l) (hf3 : IsEssBdd f) (hf5 : 0 < essSup f volume)\n (hg1 : 0 ≤ g) (hg3 : IsEssBdd g) (hg5 : 0 < essSup g volume) (hPL : PL_dim1_cond t f g h)\n (hf6 : 0 ≤ fun x ↦ (f x) / essSup f volume) (hg6 : 0 ≤ fun x ↦ (g x) / essSup g volume)\n (hl1 : l < 1) (hf7 : Integrable (fun x ↦ (f x) / essSup f volume))\n (hg7 : Integrable (fun x ↦ (g x) / essSup g volume)) :\n volume (superlevel_set (fun x ↦ (f x) / essSup f volume) l) + volume (superlevel_set (fun x ↦\n (g x) / essSup g volume) l) ≤ volume (superlevel_set (fun x ↦ (h x) / (essSup f volume ^ (1 - t)\n * essSup g volume ^ t)) l) := by sorry\n\nlemma prekopa_leindler_dim1_essBdd\n {t : ℝ} (ht1 : 0 < t) (ht2 : t < 1) {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf1 : 0 ≤ f)\n (hf2 : Integrable f) (hg1 : 0 ≤ g) (hg2 : Integrable g) (hh1 : 0 ≤ h) (hh2 : Integrable h)\n (hf3 : IsEssBdd f) (hg3 : IsEssBdd g) (hPL : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := by sorry"} -{"project_name": "PrekopaLeindler", "name": "prekopa_leindler_dim1_from_g_essBdd", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n/-- condition for Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_cond (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (x y : EuclideanSpace ℝ (Fin 1)) → (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)\n\nlemma PL_dim1_cond_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_cond t f g h ↔ PL_dim1_cond (1 - t) g f h := by sorry\n/-- theorem content of Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_conclusion (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (1 - t) ^ (1 - t) * t ^ t * (∫ x, h x)\n\nlemma PL_dim1_conclusion_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_conclusion t f g h ↔ PL_dim1_conclusion (1 - t) g f h := by sorry\n\nlemma superlevel_subset {t : ℝ} (ht1 : 0 < t) (ht3 : 0 < 1 - t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {l : ℝ} (hl_pos : 0 < l) (hPL : PL_dim1_cond t f g h) :\n superlevel_set f l + superlevel_set g l ⊆ superlevel_set h l := by sorry\nattribute [local instance] WithLp.measurableSpace in\n\nlemma fgh_nor_splsets_vol_le {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {t l : ℝ} (ht1 : 0 < t)\n (hf1 : 0 ≤ f) (ht3 : 0 < 1 - t) (h0l : 0 < l) (hf3 : IsEssBdd f) (hf5 : 0 < essSup f volume)\n (hg1 : 0 ≤ g) (hg3 : IsEssBdd g) (hg5 : 0 < essSup g volume) (hPL : PL_dim1_cond t f g h)\n (hf6 : 0 ≤ fun x ↦ (f x) / essSup f volume) (hg6 : 0 ≤ fun x ↦ (g x) / essSup g volume)\n (hl1 : l < 1) (hf7 : Integrable (fun x ↦ (f x) / essSup f volume))\n (hg7 : Integrable (fun x ↦ (g x) / essSup g volume)) :\n volume (superlevel_set (fun x ↦ (f x) / essSup f volume) l) + volume (superlevel_set (fun x ↦\n (g x) / essSup g volume) l) ≤ volume (superlevel_set (fun x ↦ (h x) / (essSup f volume ^ (1 - t)\n * essSup g volume ^ t)) l) := by sorry\n\nlemma prekopa_leindler_dim1_essBdd\n {t : ℝ} (ht1 : 0 < t) (ht2 : t < 1) {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf1 : 0 ≤ f)\n (hf2 : Integrable f) (hg1 : 0 ≤ g) (hg2 : Integrable g) (hh1 : 0 ≤ h) (hh2 : Integrable h)\n (hf3 : IsEssBdd f) (hg3 : IsEssBdd g) (hPL : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := by sorry\n\nopen scoped Topology in\n\nlemma prekopa_leindler_dim1_from_g_essBdd\n {t : ℝ} (h0t : 0 < t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ}\n (hf_nonneg : 0 ≤ f)\n (hg_nonneg : 0 ≤ g) (hg2 : Integrable g)\n (hfgh_pow_le : PL_dim1_cond t f g h)\n (hgg_essBdd_true : {gg : EuclideanSpace ℝ (Fin 1) → ℝ} →\n (hgg_nonneg : 0 ≤ gg) → (hgg_integrable : Integrable gg) →\n (hgg_essBdd : IsEssBdd gg) →\n (hfggh_pow_le : PL_dim1_cond t f gg h) →\n PL_dim1_conclusion t f gg h) :\n PL_dim1_conclusion t f g h := by sorry"} -{"project_name": "PrekopaLeindler", "name": "prekopa_leindler_dim1_from_f_essBdd", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n/-- condition for Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_cond (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (x y : EuclideanSpace ℝ (Fin 1)) → (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)\n\nlemma PL_dim1_cond_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_cond t f g h ↔ PL_dim1_cond (1 - t) g f h := by sorry\n/-- theorem content of Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_conclusion (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (1 - t) ^ (1 - t) * t ^ t * (∫ x, h x)\n\nlemma PL_dim1_conclusion_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_conclusion t f g h ↔ PL_dim1_conclusion (1 - t) g f h := by sorry\n\nlemma superlevel_subset {t : ℝ} (ht1 : 0 < t) (ht3 : 0 < 1 - t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {l : ℝ} (hl_pos : 0 < l) (hPL : PL_dim1_cond t f g h) :\n superlevel_set f l + superlevel_set g l ⊆ superlevel_set h l := by sorry\nattribute [local instance] WithLp.measurableSpace in\n\nlemma fgh_nor_splsets_vol_le {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {t l : ℝ} (ht1 : 0 < t)\n (hf1 : 0 ≤ f) (ht3 : 0 < 1 - t) (h0l : 0 < l) (hf3 : IsEssBdd f) (hf5 : 0 < essSup f volume)\n (hg1 : 0 ≤ g) (hg3 : IsEssBdd g) (hg5 : 0 < essSup g volume) (hPL : PL_dim1_cond t f g h)\n (hf6 : 0 ≤ fun x ↦ (f x) / essSup f volume) (hg6 : 0 ≤ fun x ↦ (g x) / essSup g volume)\n (hl1 : l < 1) (hf7 : Integrable (fun x ↦ (f x) / essSup f volume))\n (hg7 : Integrable (fun x ↦ (g x) / essSup g volume)) :\n volume (superlevel_set (fun x ↦ (f x) / essSup f volume) l) + volume (superlevel_set (fun x ↦\n (g x) / essSup g volume) l) ≤ volume (superlevel_set (fun x ↦ (h x) / (essSup f volume ^ (1 - t)\n * essSup g volume ^ t)) l) := by sorry\n\nlemma prekopa_leindler_dim1_essBdd\n {t : ℝ} (ht1 : 0 < t) (ht2 : t < 1) {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf1 : 0 ≤ f)\n (hf2 : Integrable f) (hg1 : 0 ≤ g) (hg2 : Integrable g) (hh1 : 0 ≤ h) (hh2 : Integrable h)\n (hf3 : IsEssBdd f) (hg3 : IsEssBdd g) (hPL : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := by sorry\n\nopen scoped Topology in\n\nlemma prekopa_leindler_dim1_from_g_essBdd\n {t : ℝ} (h0t : 0 < t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ}\n (hf_nonneg : 0 ≤ f)\n (hg_nonneg : 0 ≤ g) (hg2 : Integrable g)\n (hfgh_pow_le : PL_dim1_cond t f g h)\n (hgg_essBdd_true : {gg : EuclideanSpace ℝ (Fin 1) → ℝ} →\n (hgg_nonneg : 0 ≤ gg) → (hgg_integrable : Integrable gg) →\n (hgg_essBdd : IsEssBdd gg) →\n (hfggh_pow_le : PL_dim1_cond t f gg h) →\n PL_dim1_conclusion t f gg h) :\n PL_dim1_conclusion t f g h := by sorry\n\nlemma prekopa_leindler_dim1_from_f_essBdd {t : ℝ} (ht1 : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf1 : 0 ≤ f) (hf2 : Integrable f) (hg1 : 0 ≤ g)\n (hfgh_pow_le : PL_dim1_cond t f g h) (hff5 : {ff : EuclideanSpace ℝ (Fin 1) → ℝ} →\n (hff_nonneg : 0 ≤ ff) → (hff_integrable : Integrable ff) → (hff_essBdd : IsEssBdd ff) →\n (hffgh_pow_le : PL_dim1_cond t ff g h) → PL_dim1_conclusion t ff g h) :\n PL_dim1_conclusion t f g h := sorry"} -{"project_name": "PrekopaLeindler", "name": "prekopa_leindler_dim1_f_essBdd", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n/-- condition for Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_cond (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (x y : EuclideanSpace ℝ (Fin 1)) → (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)\n\nlemma PL_dim1_cond_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_cond t f g h ↔ PL_dim1_cond (1 - t) g f h := by sorry\n/-- theorem content of Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_conclusion (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (1 - t) ^ (1 - t) * t ^ t * (∫ x, h x)\n\nlemma PL_dim1_conclusion_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_conclusion t f g h ↔ PL_dim1_conclusion (1 - t) g f h := by sorry\n\nlemma superlevel_subset {t : ℝ} (ht1 : 0 < t) (ht3 : 0 < 1 - t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {l : ℝ} (hl_pos : 0 < l) (hPL : PL_dim1_cond t f g h) :\n superlevel_set f l + superlevel_set g l ⊆ superlevel_set h l := by sorry\nattribute [local instance] WithLp.measurableSpace in\n\nlemma fgh_nor_splsets_vol_le {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {t l : ℝ} (ht1 : 0 < t)\n (hf1 : 0 ≤ f) (ht3 : 0 < 1 - t) (h0l : 0 < l) (hf3 : IsEssBdd f) (hf5 : 0 < essSup f volume)\n (hg1 : 0 ≤ g) (hg3 : IsEssBdd g) (hg5 : 0 < essSup g volume) (hPL : PL_dim1_cond t f g h)\n (hf6 : 0 ≤ fun x ↦ (f x) / essSup f volume) (hg6 : 0 ≤ fun x ↦ (g x) / essSup g volume)\n (hl1 : l < 1) (hf7 : Integrable (fun x ↦ (f x) / essSup f volume))\n (hg7 : Integrable (fun x ↦ (g x) / essSup g volume)) :\n volume (superlevel_set (fun x ↦ (f x) / essSup f volume) l) + volume (superlevel_set (fun x ↦\n (g x) / essSup g volume) l) ≤ volume (superlevel_set (fun x ↦ (h x) / (essSup f volume ^ (1 - t)\n * essSup g volume ^ t)) l) := by sorry\n\nlemma prekopa_leindler_dim1_essBdd\n {t : ℝ} (ht1 : 0 < t) (ht2 : t < 1) {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf1 : 0 ≤ f)\n (hf2 : Integrable f) (hg1 : 0 ≤ g) (hg2 : Integrable g) (hh1 : 0 ≤ h) (hh2 : Integrable h)\n (hf3 : IsEssBdd f) (hg3 : IsEssBdd g) (hPL : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := by sorry\n\nopen scoped Topology in\n\nlemma prekopa_leindler_dim1_from_g_essBdd\n {t : ℝ} (h0t : 0 < t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ}\n (hf_nonneg : 0 ≤ f)\n (hg_nonneg : 0 ≤ g) (hg2 : Integrable g)\n (hfgh_pow_le : PL_dim1_cond t f g h)\n (hgg_essBdd_true : {gg : EuclideanSpace ℝ (Fin 1) → ℝ} →\n (hgg_nonneg : 0 ≤ gg) → (hgg_integrable : Integrable gg) →\n (hgg_essBdd : IsEssBdd gg) →\n (hfggh_pow_le : PL_dim1_cond t f gg h) →\n PL_dim1_conclusion t f gg h) :\n PL_dim1_conclusion t f g h := by sorry\n\nlemma prekopa_leindler_dim1_from_f_essBdd {t : ℝ} (ht1 : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf1 : 0 ≤ f) (hf2 : Integrable f) (hg1 : 0 ≤ g)\n (hfgh_pow_le : PL_dim1_cond t f g h) (hff5 : {ff : EuclideanSpace ℝ (Fin 1) → ℝ} →\n (hff_nonneg : 0 ≤ ff) → (hff_integrable : Integrable ff) → (hff_essBdd : IsEssBdd ff) →\n (hffgh_pow_le : PL_dim1_cond t ff g h) → PL_dim1_conclusion t ff g h) :\n PL_dim1_conclusion t f g h := sorry\n\nlemma prekopa_leindler_dim1_f_essBdd\n {t : ℝ} (h0t : 0 < t) (ht1 : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ}\n (hf_nonneg : 0 ≤ f) (hf_integrable : Integrable f)\n (hg_nonneg : 0 ≤ g) (hg_integrable : Integrable g)\n (hh_nonneg : 0 ≤ h) (hh_integrable : Integrable h)\n (hf_essBdd : IsEssBdd f)\n (hfgh_pow_le : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := sorry"} -{"project_name": "PrekopaLeindler", "name": "prekopa_leindler_dim1", "type": "lemma", "code": "import Mathlib\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\nattribute [local grind .] IsCompact.measurableSet in\n\nset_option maxHeartbeats 400000 in\n\nlemma one_dim_BMInequality {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty) (hC : C.Nonempty)\n (mA : MeasurableSet A) (mB : MeasurableSet B) (mC : MeasurableSet C) (h : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n\nlemma one_dim_BMInequality_of_nullmeasurable {A B C : Set ℝ} (hA : A.Nonempty) (hB : B.Nonempty)\n (hA1 : NullMeasurableSet A) (hB1 : NullMeasurableSet B) (hABC : A + B ⊆ C) :\n volume A + volume B ≤ volume C := by sorry\n/-- condition for Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_cond (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (x y : EuclideanSpace ℝ (Fin 1)) → (f x) ^ (1 - t) * (g y) ^ t ≤ h (x + y)\n\nlemma PL_dim1_cond_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_cond t f g h ↔ PL_dim1_cond (1 - t) g f h := by sorry\n/-- theorem content of Prékopa-Leindler in dimension 1-/\n\nabbrev PL_dim1_conclusion (t : ℝ) (f g h : EuclideanSpace ℝ (Fin 1) → ℝ) :=\n (∫ x, f x) ^ (1 - t) * (∫ y, g y) ^ t ≤ (1 - t) ^ (1 - t) * t ^ t * (∫ x, h x)\n\nlemma PL_dim1_conclusion_swap {t : ℝ} {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} :\n PL_dim1_conclusion t f g h ↔ PL_dim1_conclusion (1 - t) g f h := by sorry\n\nlemma superlevel_subset {t : ℝ} (ht1 : 0 < t) (ht3 : 0 < 1 - t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {l : ℝ} (hl_pos : 0 < l) (hPL : PL_dim1_cond t f g h) :\n superlevel_set f l + superlevel_set g l ⊆ superlevel_set h l := by sorry\nattribute [local instance] WithLp.measurableSpace in\n\nlemma fgh_nor_splsets_vol_le {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} {t l : ℝ} (ht1 : 0 < t)\n (hf1 : 0 ≤ f) (ht3 : 0 < 1 - t) (h0l : 0 < l) (hf3 : IsEssBdd f) (hf5 : 0 < essSup f volume)\n (hg1 : 0 ≤ g) (hg3 : IsEssBdd g) (hg5 : 0 < essSup g volume) (hPL : PL_dim1_cond t f g h)\n (hf6 : 0 ≤ fun x ↦ (f x) / essSup f volume) (hg6 : 0 ≤ fun x ↦ (g x) / essSup g volume)\n (hl1 : l < 1) (hf7 : Integrable (fun x ↦ (f x) / essSup f volume))\n (hg7 : Integrable (fun x ↦ (g x) / essSup g volume)) :\n volume (superlevel_set (fun x ↦ (f x) / essSup f volume) l) + volume (superlevel_set (fun x ↦\n (g x) / essSup g volume) l) ≤ volume (superlevel_set (fun x ↦ (h x) / (essSup f volume ^ (1 - t)\n * essSup g volume ^ t)) l) := by sorry\n\nlemma prekopa_leindler_dim1_essBdd\n {t : ℝ} (ht1 : 0 < t) (ht2 : t < 1) {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf1 : 0 ≤ f)\n (hf2 : Integrable f) (hg1 : 0 ≤ g) (hg2 : Integrable g) (hh1 : 0 ≤ h) (hh2 : Integrable h)\n (hf3 : IsEssBdd f) (hg3 : IsEssBdd g) (hPL : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := by sorry\n\nopen scoped Topology in\n\nlemma prekopa_leindler_dim1_from_g_essBdd\n {t : ℝ} (h0t : 0 < t)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ}\n (hf_nonneg : 0 ≤ f)\n (hg_nonneg : 0 ≤ g) (hg2 : Integrable g)\n (hfgh_pow_le : PL_dim1_cond t f g h)\n (hgg_essBdd_true : {gg : EuclideanSpace ℝ (Fin 1) → ℝ} →\n (hgg_nonneg : 0 ≤ gg) → (hgg_integrable : Integrable gg) →\n (hgg_essBdd : IsEssBdd gg) →\n (hfggh_pow_le : PL_dim1_cond t f gg h) →\n PL_dim1_conclusion t f gg h) :\n PL_dim1_conclusion t f g h := by sorry\n\nlemma prekopa_leindler_dim1_from_f_essBdd {t : ℝ} (ht1 : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf1 : 0 ≤ f) (hf2 : Integrable f) (hg1 : 0 ≤ g)\n (hfgh_pow_le : PL_dim1_cond t f g h) (hff5 : {ff : EuclideanSpace ℝ (Fin 1) → ℝ} →\n (hff_nonneg : 0 ≤ ff) → (hff_integrable : Integrable ff) → (hff_essBdd : IsEssBdd ff) →\n (hffgh_pow_le : PL_dim1_cond t ff g h) → PL_dim1_conclusion t ff g h) :\n PL_dim1_conclusion t f g h := sorry\n\nlemma prekopa_leindler_dim1_f_essBdd\n {t : ℝ} (h0t : 0 < t) (ht1 : t < 1)\n {f g h : EuclideanSpace ℝ (Fin 1) → ℝ}\n (hf_nonneg : 0 ≤ f) (hf_integrable : Integrable f)\n (hg_nonneg : 0 ≤ g) (hg_integrable : Integrable g)\n (hh_nonneg : 0 ≤ h) (hh_integrable : Integrable h)\n (hf_essBdd : IsEssBdd f)\n (hfgh_pow_le : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := sorry\n\nlemma prekopa_leindler_dim1\n {t : ℝ} (h0t : 0 < t) (ht1 : t < 1) {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf_nonneg : 0 ≤ f)\n (hf_integrable : Integrable f) (hg_nonneg : 0 ≤ g) (hg_integrable : Integrable g)\n (hh_nonneg : 0 ≤ h) (hh_integrable : Integrable h) (hfgh_pow_le : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := sorry"} -{"project_name": "ProthTheorem", "name": "proth", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n\nuniverse u\n/-- A *proth* number. -/\n\ndef IsProth (n : ℕ) : Prop :=\n ∃ k a : ℕ, Odd k ∧ k < 2 ^ a ∧ n = k * 2 ^ a + 1\n\ntheorem proth {n : ℕ} (h : IsProth n) : n.Prime ↔ ∃ a : ℕ, a ^ ((n - 1) / 2) ≡ -1 [ZMOD n] := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "residue_lt", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "two_mul_residue_lt", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "div_algo_two_mul_residue", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "quotient_le_one", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "two_mul_residue_mod", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "quotient_eq_parity_case_lt", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "quotient_eq_parity_case_ge", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "quotient_eq_parity", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "order_set_nonempty", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "a_pos", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "pow_a_mod_eq_one", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "sum_shift_eq", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "sum_residue_shift", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "sum_parity_shift", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n\nlemma sum_parity_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "sum_two_mul_residue", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n\nlemma sum_parity_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := sorry\n\nlemma sum_two_mul_residue (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "sum_two_mul_residue_lhs", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n\nlemma sum_parity_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := sorry\n\nlemma sum_two_mul_residue (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) := by sorry\n\nlemma sum_two_mul_residue_lhs (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n 2 * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "b_unfold", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n\nlemma sum_parity_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := sorry\n\nlemma sum_two_mul_residue (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) := by sorry\n\nlemma sum_two_mul_residue_lhs (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n 2 * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n/-- `b(n+1)` unfolds to the sum of parities of residues `2^j mod (2n+1)`. -/\n\nlemma b_unfold (n : ℕ) (hn : 0 < n) :\n b (n + 1) = ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "sum_quotient_eq_sum_parity", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n\nlemma sum_parity_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := sorry\n\nlemma sum_two_mul_residue (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) := by sorry\n\nlemma sum_two_mul_residue_lhs (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n 2 * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n/-- `b(n+1)` unfolds to the sum of parities of residues `2^j mod (2n+1)`. -/\n\nlemma b_unfold (n : ℕ) (hn : 0 < n) :\n b (n + 1) = ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := by sorry\n\nlemma sum_quotient_eq_sum_parity (n : ℕ) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 := sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "sum_quotient_eq_b", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n\nlemma sum_parity_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := sorry\n\nlemma sum_two_mul_residue (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) := by sorry\n\nlemma sum_two_mul_residue_lhs (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n 2 * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n/-- `b(n+1)` unfolds to the sum of parities of residues `2^j mod (2n+1)`. -/\n\nlemma b_unfold (n : ℕ) (hn : 0 < n) :\n b (n + 1) = ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := by sorry\n\nlemma sum_quotient_eq_sum_parity (n : ℕ) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 := sorry\n\nlemma sum_quotient_eq_b (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) =\n b (n + 1) := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "sum_two_mul_mod_eq_sum_residue", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n\nlemma sum_parity_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := sorry\n\nlemma sum_two_mul_residue (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) := by sorry\n\nlemma sum_two_mul_residue_lhs (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n 2 * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n/-- `b(n+1)` unfolds to the sum of parities of residues `2^j mod (2n+1)`. -/\n\nlemma b_unfold (n : ℕ) (hn : 0 < n) :\n b (n + 1) = ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := by sorry\n\nlemma sum_quotient_eq_sum_parity (n : ℕ) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 := sorry\n\nlemma sum_quotient_eq_b (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) =\n b (n + 1) := by sorry\n\nlemma sum_two_mul_mod_eq_sum_residue (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "nat_identity", "type": "lemma", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n\nlemma sum_parity_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := sorry\n\nlemma sum_two_mul_residue (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) := by sorry\n\nlemma sum_two_mul_residue_lhs (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n 2 * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n/-- `b(n+1)` unfolds to the sum of parities of residues `2^j mod (2n+1)`. -/\n\nlemma b_unfold (n : ℕ) (hn : 0 < n) :\n b (n + 1) = ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := by sorry\n\nlemma sum_quotient_eq_sum_parity (n : ℕ) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 := sorry\n\nlemma sum_quotient_eq_b (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) =\n b (n + 1) := by sorry\n\nlemma sum_two_mul_mod_eq_sum_residue (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := by sorry\n/-- Core identity: `(2n+1) * b(n+1) = ∑_{j < a(n)} 2^j mod (2n+1)`. -/\n\nlemma nat_identity (n : ℕ) (hn : 0 < n) :\n (2 * n + 1) * b (n + 1) = ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "smallest_period_div", "type": "theorem", "code": "import Mathlib\n/-- OEIS A002326: the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable def A002326 (n : ℕ) : ℕ :=\n sInf {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1}\n/-- Abbreviation for A002326, the multiplicative order of `2` modulo `2n+1`. -/\nnoncomputable abbrev a := A002326\n/-- OEIS A179382: number of odd residues `2^j mod (2n+1)` for `j < a(n)`. -/\nnoncomputable def A179382 : ℕ → ℕ\n | 0 => 0\n | 1 => 1\n | n + 1 => ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2\n/-- Abbreviation for A179382 -/\nnoncomputable abbrev b := A179382\n\nlemma residue_lt (j n : ℕ) : 2 ^ j % (2 * n + 1) < 2 * n + 1 := sorry\n\nlemma two_mul_residue_lt (j n : ℕ) : 2 * (2 ^ j % (2 * n + 1)) < 2 * (2 * n + 1) := by sorry\n\nlemma div_algo_two_mul_residue (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) := sorry\n\nlemma quotient_le_one (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) ≤ 1 := by sorry\n/-- `2 * (2^j mod m) mod m = 2^(j+1) mod m`, since `2^(j+1) = 2 * 2^j`. -/\n\nlemma two_mul_residue_mod (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) = 2 ^ (j + 1) % (2 * n + 1) := by sorry\n\nlemma quotient_eq_parity_case_lt (j n : ℕ)\n (hlt : 2 * (2 ^ j % (2 * n + 1)) < 2 * n + 1) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n\nlemma quotient_eq_parity_case_ge (j n : ℕ)\n (hge : 2 * n + 1 ≤ 2 * (2 ^ j % (2 * n + 1))) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The floor quotient `⌊2 * r_j / m⌋` equals the parity of `r_{j+1}`. -/\n\nlemma quotient_eq_parity (j n : ℕ) :\n 2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1) =\n 2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1) % 2 := by sorry\n/-- The set of periods `{m > 0 | (2n+1) ∣ 2^m - 1}` is nonempty. -/\n\nlemma order_set_nonempty (n : ℕ) (hn : 0 < n) :\n Set.Nonempty {m : ℕ | 0 < m ∧ (2 * n + 1) ∣ 2 ^ m - 1} := by sorry\n/-- `a(n)` is positive for `n > 0`. -/\n\nlemma a_pos (n : ℕ) (hn : 0 < n) : 0 < a n := sorry\n/-- `2^(a n) ≡ 1 (mod 2n+1)`. -/\n\nlemma pow_a_mod_eq_one (n : ℕ) (hn : 0 < n) :\n 2 ^ (a n) % (2 * n + 1) = 1 := by sorry\n/-- If `f(k) = f(0)`, the shifted sum `∑_{j < k} f(j+1)` equals `∑_{j < k} f(j)`. -/\n\nlemma sum_shift_eq {k : ℕ} (f : ℕ → ℕ) (hfk : f k = f 0) :\n ∑ j ∈ Finset.range k, f (j + 1) = ∑ j ∈ Finset.range k, f j := by sorry\n\nlemma sum_residue_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n\nlemma sum_parity_shift (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := sorry\n\nlemma sum_two_mul_residue (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n (2 * n + 1) * ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) +\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) := by sorry\n\nlemma sum_two_mul_residue_lhs (n : ℕ) :\n ∑ j ∈ Finset.range (a n), 2 * (2 ^ j % (2 * n + 1)) =\n 2 * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := sorry\n/-- `b(n+1)` unfolds to the sum of parities of residues `2^j mod (2n+1)`. -/\n\nlemma b_unfold (n : ℕ) (hn : 0 < n) :\n b (n + 1) = ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) % 2 := by sorry\n\nlemma sum_quotient_eq_sum_parity (n : ℕ) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ (j + 1) % (2 * n + 1)) % 2 := sorry\n\nlemma sum_quotient_eq_b (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) / (2 * n + 1)) =\n b (n + 1) := by sorry\n\nlemma sum_two_mul_mod_eq_sum_residue (n : ℕ) (hn : 0 < n) :\n ∑ j ∈ Finset.range (a n), (2 * (2 ^ j % (2 * n + 1)) % (2 * n + 1)) =\n ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := by sorry\n/-- Core identity: `(2n+1) * b(n+1) = ∑_{j < a(n)} 2^j mod (2n+1)`. -/\n\nlemma nat_identity (n : ℕ) (hn : 0 < n) :\n (2 * n + 1) * b (n + 1) = ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := by sorry\n/-- The value `b(n+1)` equals `(2n+1)⁻¹ · ∑ 2^j mod (2n+1)` as real numbers. -/\n\ntheorem smallest_period_div {n : ℕ} (hn : 0 < n) :\n (↑(b (n + 1)) : ℝ) = (2 * n + 1 : ℝ)⁻¹ * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := by sorry"} -{"project_name": "RamanujanNagellEquation", "name": "ramanujan_nagell", "type": "theorem", "code": "import Mathlib\n\nopen Nat Set\n\ntheorem ramanujan_nagell (n : ℕ) (hn : 3 ≤ n):\n (∃ x, 2 ^ n - 7 = x ^ 2) ↔ n ∈ ({3, 4, 5, 7, 15} : Set ℕ) := by sorry"} -{"project_name": "RiemannSeries", "name": "riemann_summation", "type": "theorem", "code": "import Mathlib\n\nuniverse u\n\nopen Filter Function Topology\n/--\nA series ∑ aₙ is convergent if the sequence of its partial sums converges.\n-/\n\ndef convergentSeries {α : Type u} [AddCommMonoid α] [TopologicalSpace α] (f : ℕ → α) : Prop :=\n ∃ l : α, Tendsto (fun n ↦ ∑ k ∈ Finset.range n, f k) atTop (𝓝 l)\n\ntheorem riemann_summation {a : ℕ → ℝ}\n (h : convergentSeries a) (h' : ¬ convergentSeries (fun n ↦ |a n|)) :\n ∀ r : ℝ, ∃ p : ℕ → ℕ,\n Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop (𝓝 r) := sorry"} -{"project_name": "RiemannSeries", "name": "riemann_summation_attop", "type": "theorem", "code": "import Mathlib\n\nuniverse u\n\nopen Filter Function Topology\n/--\nA series ∑ aₙ is convergent if the sequence of its partial sums converges.\n-/\n\ndef convergentSeries {α : Type u} [AddCommMonoid α] [TopologicalSpace α] (f : ℕ → α) : Prop :=\n ∃ l : α, Tendsto (fun n ↦ ∑ k ∈ Finset.range n, f k) atTop (𝓝 l)\n\ntheorem riemann_summation {a : ℕ → ℝ}\n (h : convergentSeries a) (h' : ¬ convergentSeries (fun n ↦ |a n|)) :\n ∀ r : ℝ, ∃ p : ℕ → ℕ,\n Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop (𝓝 r) := sorry\n\ntheorem riemann_summation_attop {a : ℕ → ℝ}\n (h : convergentSeries a) (h' : ¬ convergentSeries (fun n ↦ |a n|)) :\n ∃ p : ℕ → ℕ, Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop atTop := sorry"} -{"project_name": "RiemannSeries", "name": "riemann_summation_atbot", "type": "theorem", "code": "import Mathlib\n\nuniverse u\n\nopen Filter Function Topology\n/--\nA series ∑ aₙ is convergent if the sequence of its partial sums converges.\n-/\n\ndef convergentSeries {α : Type u} [AddCommMonoid α] [TopologicalSpace α] (f : ℕ → α) : Prop :=\n ∃ l : α, Tendsto (fun n ↦ ∑ k ∈ Finset.range n, f k) atTop (𝓝 l)\n\ntheorem riemann_summation {a : ℕ → ℝ}\n (h : convergentSeries a) (h' : ¬ convergentSeries (fun n ↦ |a n|)) :\n ∀ r : ℝ, ∃ p : ℕ → ℕ,\n Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop (𝓝 r) := sorry\n\ntheorem riemann_summation_attop {a : ℕ → ℝ}\n (h : convergentSeries a) (h' : ¬ convergentSeries (fun n ↦ |a n|)) :\n ∃ p : ℕ → ℕ, Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop atTop := sorry\n\ntheorem riemann_summation_atbot {a : ℕ → ℝ}\n (h : convergentSeries a) (h' : ¬ convergentSeries (fun n ↦ |a n|)) :\n ∃ p : ℕ → ℕ, Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop atBot := sorry"} -{"project_name": "RisingSunLemma", "name": "E_subset_Ioo", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry"} -{"project_name": "RisingSunLemma", "name": "E_mem_witness", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry"} -{"project_name": "RisingSunLemma", "name": "E_isOpen", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry"} -{"project_name": "RisingSunLemma", "name": "open_preconnected_subset_Ioo_eq_Ioo", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry"} -{"project_name": "RisingSunLemma", "name": "component_sInf_ge", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry"} -{"project_name": "RisingSunLemma", "name": "component_sSup_le", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry"} -{"project_name": "RisingSunLemma", "name": "component_sInf_lt_sSup", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry"} -{"project_name": "RisingSunLemma", "name": "E_components_countable", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry"} -{"project_name": "RisingSunLemma", "name": "E_eq_iUnion_connectedComponents", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry"} -{"project_name": "RisingSunLemma", "name": "right_endpoint_not_in_E", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry"} -{"project_name": "RisingSunLemma", "name": "right_endpoint_not_in_S", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry"} -{"project_name": "RisingSunLemma", "name": "right_endpoint_dominates", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry"} -{"project_name": "RisingSunLemma", "name": "maximizer_eq_right_endpoint", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry"} -{"project_name": "RisingSunLemma", "name": "g_lt_g_right_endpoint", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry"} -{"project_name": "RisingSunLemma", "name": "left_endpoint_not_in_E", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry"} -{"project_name": "RisingSunLemma", "name": "left_not_in_S_imp_ge", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry"} -{"project_name": "RisingSunLemma", "name": "g_left_ge_g_right", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry\n/-- Sublemma: g(c) >= g(d) when c != a. -/\n\nlemma g_left_ge_g_right {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n g c ≥ g d := by sorry"} -{"project_name": "RisingSunLemma", "name": "g_left_le_g_right", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry\n/-- Sublemma: g(c) >= g(d) when c != a. -/\n\nlemma g_left_ge_g_right {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n g c ≥ g d := by sorry\n/-- Sublemma: g(c) <= g(d) (by continuity + Property 5). -/\n\nlemma g_left_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n g c ≤ g d := by sorry"} -{"project_name": "RisingSunLemma", "name": "left_ne_a_imp_g_eq", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry\n/-- Sublemma: g(c) >= g(d) when c != a. -/\n\nlemma g_left_ge_g_right {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n g c ≥ g d := by sorry\n/-- Sublemma: g(c) <= g(d) (by continuity + Property 5). -/\n\nlemma g_left_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n g c ≤ g d := by sorry\n/-- Property 3: If c != a (so c in (a,b)), then g(c) = g(d). -/\n\nlemma left_ne_a_imp_g_eq {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a) :\n g c = g d := by sorry"} -{"project_name": "RisingSunLemma", "name": "g_a_le_g_right", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry\n/-- Sublemma: g(c) >= g(d) when c != a. -/\n\nlemma g_left_ge_g_right {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n g c ≥ g d := by sorry\n/-- Sublemma: g(c) <= g(d) (by continuity + Property 5). -/\n\nlemma g_left_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n g c ≤ g d := by sorry\n/-- Property 3: If c != a (so c in (a,b)), then g(c) = g(d). -/\n\nlemma left_ne_a_imp_g_eq {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a) :\n g c = g d := by sorry\n/-- Sublemma for Property 4: g(a) <= g(d) by continuity from left. -/\n\nlemma g_a_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hca : c = a)\n (h5 : ∀ x ∈ Ioo c d, g x < g d) :\n g a ≤ g d := by sorry"} -{"project_name": "RisingSunLemma", "name": "left_eq_a_imp_g_lt", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry\n/-- Sublemma: g(c) >= g(d) when c != a. -/\n\nlemma g_left_ge_g_right {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n g c ≥ g d := by sorry\n/-- Sublemma: g(c) <= g(d) (by continuity + Property 5). -/\n\nlemma g_left_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n g c ≤ g d := by sorry\n/-- Property 3: If c != a (so c in (a,b)), then g(c) = g(d). -/\n\nlemma left_ne_a_imp_g_eq {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a) :\n g c = g d := by sorry\n/-- Sublemma for Property 4: g(a) <= g(d) by continuity from left. -/\n\nlemma g_a_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hca : c = a)\n (h5 : ∀ x ∈ Ioo c d, g x < g d) :\n g a ≤ g d := by sorry\n/-- Property 4: If c = a and a ∈ S, then g(a) < g(d). -/\n\nlemma left_eq_a_imp_g_lt {a b : ℝ} (ab : a < b) {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c = a) (haS : a ∈ Shadow a b g) :\n g a < g d := by sorry"} -{"project_name": "RisingSunLemma", "name": "risingsun_of_components", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry\n/-- Sublemma: g(c) >= g(d) when c != a. -/\n\nlemma g_left_ge_g_right {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n g c ≥ g d := by sorry\n/-- Sublemma: g(c) <= g(d) (by continuity + Property 5). -/\n\nlemma g_left_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n g c ≤ g d := by sorry\n/-- Property 3: If c != a (so c in (a,b)), then g(c) = g(d). -/\n\nlemma left_ne_a_imp_g_eq {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a) :\n g c = g d := by sorry\n/-- Sublemma for Property 4: g(a) <= g(d) by continuity from left. -/\n\nlemma g_a_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hca : c = a)\n (h5 : ∀ x ∈ Ioo c d, g x < g d) :\n g a ≤ g d := by sorry\n/-- Property 4: If c = a and a ∈ S, then g(a) < g(d). -/\n\nlemma left_eq_a_imp_g_lt {a b : ℝ} (ab : a < b) {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c = a) (haS : a ∈ Shadow a b g) :\n g a < g d := by sorry\n/-- Construct the sequence k : N -> R x R from the countable collection of components,\nsatisfying all five properties. This is the assembly lemma. -/\n\nlemma risingsun_of_components {a b : ℝ} {g : ℝ → ℝ}\n (I : Set (ℝ × ℝ))\n (hI_disj : I.PairwiseDisjoint (fun p => Ioo p.1 p.2))\n (hI_union : E a b g = ⋃ p ∈ I, Ioo p.1 p.2)\n (hI_prop3 : ∀ p ∈ I, p.1 ≠ a → g p.1 = g p.2)\n (hI_prop4 : ∀ p ∈ I, p.1 = a → a ∈ Shadow a b g → g a < g p.2)\n (hI_prop5 : ∀ p ∈ I, ∀ x ∈ Ioo p.1 p.2, g x < g p.2)\n (hI_count : I.Countable) :\n ∃ k : ℕ → ℝ × ℝ, ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅\n ∧ E a b g = ⋃ n : ℕ, Ioo (k n).1 (k n).2\n ∧ (∀ n : ℕ, (k n).1 ≠ a → g (k n).1 = g (k n).2)\n ∧ (∀ n : ℕ, (k n).1 = a → a ∈ Shadow a b g → g a < g (k n).2)\n ∧ (∀ n : ℕ, ∀ x : ℝ, x ∈ Ioo (k n).1 (k n).2 → g x < g (k n).2) := by sorry"} -{"project_name": "RisingSunLemma", "name": "pairwise_disjoint_of_enum", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry\n/-- Sublemma: g(c) >= g(d) when c != a. -/\n\nlemma g_left_ge_g_right {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n g c ≥ g d := by sorry\n/-- Sublemma: g(c) <= g(d) (by continuity + Property 5). -/\n\nlemma g_left_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n g c ≤ g d := by sorry\n/-- Property 3: If c != a (so c in (a,b)), then g(c) = g(d). -/\n\nlemma left_ne_a_imp_g_eq {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a) :\n g c = g d := by sorry\n/-- Sublemma for Property 4: g(a) <= g(d) by continuity from left. -/\n\nlemma g_a_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hca : c = a)\n (h5 : ∀ x ∈ Ioo c d, g x < g d) :\n g a ≤ g d := by sorry\n/-- Property 4: If c = a and a ∈ S, then g(a) < g(d). -/\n\nlemma left_eq_a_imp_g_lt {a b : ℝ} (ab : a < b) {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c = a) (haS : a ∈ Shadow a b g) :\n g a < g d := by sorry\n/-- Construct the sequence k : N -> R x R from the countable collection of components,\nsatisfying all five properties. This is the assembly lemma. -/\n\nlemma risingsun_of_components {a b : ℝ} {g : ℝ → ℝ}\n (I : Set (ℝ × ℝ))\n (hI_disj : I.PairwiseDisjoint (fun p => Ioo p.1 p.2))\n (hI_union : E a b g = ⋃ p ∈ I, Ioo p.1 p.2)\n (hI_prop3 : ∀ p ∈ I, p.1 ≠ a → g p.1 = g p.2)\n (hI_prop4 : ∀ p ∈ I, p.1 = a → a ∈ Shadow a b g → g a < g p.2)\n (hI_prop5 : ∀ p ∈ I, ∀ x ∈ Ioo p.1 p.2, g x < g p.2)\n (hI_count : I.Countable) :\n ∃ k : ℕ → ℝ × ℝ, ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅\n ∧ E a b g = ⋃ n : ℕ, Ioo (k n).1 (k n).2\n ∧ (∀ n : ℕ, (k n).1 ≠ a → g (k n).1 = g (k n).2)\n ∧ (∀ n : ℕ, (k n).1 = a → a ∈ Shadow a b g → g a < g (k n).2)\n ∧ (∀ n : ℕ, ∀ x : ℝ, x ∈ Ioo (k n).1 (k n).2 → g x < g (k n).2) := by sorry\n/-- Sublemma: extract the pairwise disjointness for a function from N. When we enumerate\ncountable pairwise disjoint intervals via k : N -> R x R with extra indices mapping to\ndegenerate (c, c) = empty, the disjointness extends to all of N. -/\n\nlemma pairwise_disjoint_of_enum {k : ℕ → ℝ × ℝ}\n (hk_disj : ∀ i j : ℕ, i ≠ j → (k i, k j) ∈ ({p : (ℝ × ℝ) × (ℝ × ℝ) |\n Ioo p.1.1 p.1.2 ∩ Ioo p.2.1 p.2.2 = ∅} : Set _) ∨\n Ioo (k i).1 (k i).2 = ∅ ∨ Ioo (k j).1 (k j).2 = ∅) :\n ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅ := by sorry"} -{"project_name": "RisingSunLemma", "name": "build_component_intervals", "type": "lemma", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry\n/-- Sublemma: g(c) >= g(d) when c != a. -/\n\nlemma g_left_ge_g_right {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n g c ≥ g d := by sorry\n/-- Sublemma: g(c) <= g(d) (by continuity + Property 5). -/\n\nlemma g_left_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n g c ≤ g d := by sorry\n/-- Property 3: If c != a (so c in (a,b)), then g(c) = g(d). -/\n\nlemma left_ne_a_imp_g_eq {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a) :\n g c = g d := by sorry\n/-- Sublemma for Property 4: g(a) <= g(d) by continuity from left. -/\n\nlemma g_a_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hca : c = a)\n (h5 : ∀ x ∈ Ioo c d, g x < g d) :\n g a ≤ g d := by sorry\n/-- Property 4: If c = a and a ∈ S, then g(a) < g(d). -/\n\nlemma left_eq_a_imp_g_lt {a b : ℝ} (ab : a < b) {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c = a) (haS : a ∈ Shadow a b g) :\n g a < g d := by sorry\n/-- Construct the sequence k : N -> R x R from the countable collection of components,\nsatisfying all five properties. This is the assembly lemma. -/\n\nlemma risingsun_of_components {a b : ℝ} {g : ℝ → ℝ}\n (I : Set (ℝ × ℝ))\n (hI_disj : I.PairwiseDisjoint (fun p => Ioo p.1 p.2))\n (hI_union : E a b g = ⋃ p ∈ I, Ioo p.1 p.2)\n (hI_prop3 : ∀ p ∈ I, p.1 ≠ a → g p.1 = g p.2)\n (hI_prop4 : ∀ p ∈ I, p.1 = a → a ∈ Shadow a b g → g a < g p.2)\n (hI_prop5 : ∀ p ∈ I, ∀ x ∈ Ioo p.1 p.2, g x < g p.2)\n (hI_count : I.Countable) :\n ∃ k : ℕ → ℝ × ℝ, ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅\n ∧ E a b g = ⋃ n : ℕ, Ioo (k n).1 (k n).2\n ∧ (∀ n : ℕ, (k n).1 ≠ a → g (k n).1 = g (k n).2)\n ∧ (∀ n : ℕ, (k n).1 = a → a ∈ Shadow a b g → g a < g (k n).2)\n ∧ (∀ n : ℕ, ∀ x : ℝ, x ∈ Ioo (k n).1 (k n).2 → g x < g (k n).2) := by sorry\n/-- Sublemma: extract the pairwise disjointness for a function from N. When we enumerate\ncountable pairwise disjoint intervals via k : N -> R x R with extra indices mapping to\ndegenerate (c, c) = empty, the disjointness extends to all of N. -/\n\nlemma pairwise_disjoint_of_enum {k : ℕ → ℝ × ℝ}\n (hk_disj : ∀ i j : ℕ, i ≠ j → (k i, k j) ∈ ({p : (ℝ × ℝ) × (ℝ × ℝ) |\n Ioo p.1.1 p.1.2 ∩ Ioo p.2.1 p.2.2 = ∅} : Set _) ∨\n Ioo (k i).1 (k i).2 = ∅ ∨ Ioo (k j).1 (k j).2 = ∅) :\n ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅ := by sorry\n/-- Build the collection I of component intervals from E. -/\n\nlemma build_component_intervals {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n ∃ I : Set (ℝ × ℝ),\n (∀ p ∈ I, a ≤ p.1 ∧ p.1 < p.2 ∧ p.2 ≤ b) ∧\n I.PairwiseDisjoint (fun p => Ioo p.1 p.2) ∧\n (E a b g = ⋃ p ∈ I, Ioo p.1 p.2) ∧\n (∀ p ∈ I, Ioo p.1 p.2 ⊆ E a b g) ∧\n (∀ p ∈ I, ∀ x ∈ Ioo p.1 p.2,\n connectedComponentIn (E a b g) x = Ioo p.1 p.2) ∧\n I.Countable := by sorry"} -{"project_name": "RisingSunLemma", "name": "risingsun", "type": "theorem", "code": "import Mathlib\n\nopen Set TopologicalSpace Real\n\nvariable {a b : ℝ} {g : ℝ → ℝ}\n/--\nThe \"shadow\", in the sense of the rising sun lemma, is the set of points x in [a,b] for which there is a y > x in the interval with g(x) < g(y)\n-/\n\ndef Shadow (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n {x ∈ Icc a b | ∃ y ∈ Icc a b, x < y ∧ g x < g y}\n/--\nE is the set of points in (a,b) that are in the shadow. That is, E(a,b,g) = (a,b) ∩ Shadow(a,b,g).\n-/\n\ndef E (a b : ℝ) (g : ℝ → ℝ) : Set ℝ :=\n Ioo a b ∩ Shadow a b g\n/-- E is a subset of (a, b). -/\n\nlemma E_subset_Ioo (a b : ℝ) (g : ℝ → ℝ) : E a b g ⊆ Ioo a b := sorry\n/-- Every point of E has a witness y in [a,b] with x < y and g(x) < g(y). -/\n\nlemma E_mem_witness {a b : ℝ} {g : ℝ → ℝ} {x : ℝ} (hx : x ∈ E a b g) :\n ∃ y ∈ Icc a b, x < y ∧ g x < g y := by sorry\n/-- E(a,b,g) is open when g is continuous. -/\n\nlemma E_isOpen {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n IsOpen (E a b g) := by sorry\n/-- A nonempty, open, preconnected, bounded subset of R is an open interval. Specifically, if\nC is such a set and C ⊆ Ioo a b, then C = Ioo (sInf C) (sSup C). -/\n\nlemma open_preconnected_subset_Ioo_eq_Ioo {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C) (hpc : IsPreconnected C)\n (hsub : C ⊆ Ioo a b) :\n C = Ioo (sInf C) (sSup C) := by sorry\n/-- For a nonempty connected component of E, sInf C >= a. -/\n\nlemma component_sInf_ge {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n a ≤ sInf C := sorry\n/-- For a nonempty connected component of E, sSup C <= b. -/\n\nlemma component_sSup_le {a b : ℝ} {g : ℝ → ℝ} {C : Set ℝ}\n (hne : C.Nonempty) (hsub : C ⊆ E a b g) :\n sSup C ≤ b := sorry\n/-- sInf C < sSup C for a nonempty connected component. -/\n\nlemma component_sInf_lt_sSup {C : Set ℝ} {a b : ℝ}\n (hne : C.Nonempty) (hopen : IsOpen C)\n (hsub : C ⊆ Ioo a b) :\n sInf C < sSup C := by sorry\n/-- The set of distinct nonempty connected components of E (as a set of sets) is countable. -/\n\nlemma E_components_countable {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n Set.Countable {C : Set ℝ | ∃ x ∈ E a b g, C = connectedComponentIn (E a b g) x} := by sorry\n/-- E equals the union of its connected components. -/\n\nlemma E_eq_iUnion_connectedComponents (a b : ℝ) (g : ℝ → ℝ) :\n E a b g = ⋃ x ∈ E a b g, connectedComponentIn (E a b g) x := by sorry\n/-- The right endpoint (sSup of a component) is not in E. -/\n\nlemma right_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n d ∉ E a b g := by sorry\n/-- The right endpoint is not in S when d < b. That is, g(d) >= g(y) for all y in [a,b] with y > d. -/\n\nlemma right_endpoint_not_in_S {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hdb : d < b) :\n ∀ y ∈ Icc a b, d < y → g d ≥ g y := by sorry\n/-- g(d) >= g(y) for all y in [d, b] (the right endpoint dominates to the right). -/\n\nlemma right_endpoint_dominates {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n ∀ y ∈ Icc d b, g d ≥ g y := by sorry\n/-- Key sublemma: the maximizer of g on [x, d] for x in a component must be d itself. -/\n\nlemma maximizer_eq_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) {z : ℝ} (hz : z ∈ Icc x d) (hmax : IsMaxOn g (Icc x d) z) :\n z = d := by sorry\n/-- Property 5: For x in a component (c, d), g(x) < g(d). -/\n\nlemma g_lt_g_right_endpoint {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c)\n {x : ℝ} (hx : x ∈ Ioo c d) :\n g x < g d := by sorry\n/-- The left endpoint is not in E (it is at the boundary of a component). -/\n\nlemma left_endpoint_not_in_E {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d) :\n c ∉ E a b g := by sorry\n/-- Sublemma for Property 3: c not in S implies g(c) >= g(y) for all y > c in [a,b]. -/\n\nlemma left_not_in_S_imp_ge {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n ∀ y ∈ Icc a b, c < y → g c ≥ g y := by sorry\n/-- Sublemma: g(c) >= g(d) when c != a. -/\n\nlemma g_left_ge_g_right {a b : ℝ} {g : ℝ → ℝ}\n {c d : ℝ} (hcd : c < d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a)\n (hcE : c ∉ E a b g) :\n g c ≥ g d := by sorry\n/-- Sublemma: g(c) <= g(d) (by continuity + Property 5). -/\n\nlemma g_left_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) :\n g c ≤ g d := by sorry\n/-- Property 3: If c != a (so c in (a,b)), then g(c) = g(d). -/\n\nlemma left_ne_a_imp_g_eq {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c ≠ a) :\n g c = g d := by sorry\n/-- Sublemma for Property 4: g(a) <= g(d) by continuity from left. -/\n\nlemma g_a_le_g_right {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hca : c = a)\n (h5 : ∀ x ∈ Ioo c d, g x < g d) :\n g a ≤ g d := by sorry\n/-- Property 4: If c = a and a ∈ S, then g(a) < g(d). -/\n\nlemma left_eq_a_imp_g_lt {a b : ℝ} (ab : a < b) {g : ℝ → ℝ} (hg : Continuous g)\n {c d : ℝ} (hcd : c < d) (hcomp : Ioo c d ⊆ E a b g)\n (hIsComp : ∀ x ∈ Ioo c d, connectedComponentIn (E a b g) x = Ioo c d)\n (ha : a ≤ c) (hb : d ≤ b) (hca : c = a) (haS : a ∈ Shadow a b g) :\n g a < g d := by sorry\n/-- Construct the sequence k : N -> R x R from the countable collection of components,\nsatisfying all five properties. This is the assembly lemma. -/\n\nlemma risingsun_of_components {a b : ℝ} {g : ℝ → ℝ}\n (I : Set (ℝ × ℝ))\n (hI_disj : I.PairwiseDisjoint (fun p => Ioo p.1 p.2))\n (hI_union : E a b g = ⋃ p ∈ I, Ioo p.1 p.2)\n (hI_prop3 : ∀ p ∈ I, p.1 ≠ a → g p.1 = g p.2)\n (hI_prop4 : ∀ p ∈ I, p.1 = a → a ∈ Shadow a b g → g a < g p.2)\n (hI_prop5 : ∀ p ∈ I, ∀ x ∈ Ioo p.1 p.2, g x < g p.2)\n (hI_count : I.Countable) :\n ∃ k : ℕ → ℝ × ℝ, ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅\n ∧ E a b g = ⋃ n : ℕ, Ioo (k n).1 (k n).2\n ∧ (∀ n : ℕ, (k n).1 ≠ a → g (k n).1 = g (k n).2)\n ∧ (∀ n : ℕ, (k n).1 = a → a ∈ Shadow a b g → g a < g (k n).2)\n ∧ (∀ n : ℕ, ∀ x : ℝ, x ∈ Ioo (k n).1 (k n).2 → g x < g (k n).2) := by sorry\n/-- Sublemma: extract the pairwise disjointness for a function from N. When we enumerate\ncountable pairwise disjoint intervals via k : N -> R x R with extra indices mapping to\ndegenerate (c, c) = empty, the disjointness extends to all of N. -/\n\nlemma pairwise_disjoint_of_enum {k : ℕ → ℝ × ℝ}\n (hk_disj : ∀ i j : ℕ, i ≠ j → (k i, k j) ∈ ({p : (ℝ × ℝ) × (ℝ × ℝ) |\n Ioo p.1.1 p.1.2 ∩ Ioo p.2.1 p.2.2 = ∅} : Set _) ∨\n Ioo (k i).1 (k i).2 = ∅ ∨ Ioo (k j).1 (k j).2 = ∅) :\n ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅ := by sorry\n/-- Build the collection I of component intervals from E. -/\n\nlemma build_component_intervals {a b : ℝ} {g : ℝ → ℝ} (hg : Continuous g) :\n ∃ I : Set (ℝ × ℝ),\n (∀ p ∈ I, a ≤ p.1 ∧ p.1 < p.2 ∧ p.2 ≤ b) ∧\n I.PairwiseDisjoint (fun p => Ioo p.1 p.2) ∧\n (E a b g = ⋃ p ∈ I, Ioo p.1 p.2) ∧\n (∀ p ∈ I, Ioo p.1 p.2 ⊆ E a b g) ∧\n (∀ p ∈ I, ∀ x ∈ Ioo p.1 p.2,\n connectedComponentIn (E a b g) x = Ioo p.1 p.2) ∧\n I.Countable := by sorry\n\ntheorem risingsun {a b : ℝ} (ab : a < b) {g : ℝ → ℝ} (hg : Continuous g) :\n ∃ k : ℕ → ℝ × ℝ, ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅\n ∧ E a b g = ⋃ n : ℕ, Ioo (k n).1 (k n).2\n ∧ (∀ n : ℕ, (k n).1 ≠ a → g (k n).1 = g (k n).2)\n ∧ (∀ n : ℕ, (k n).1 = a → a ∈ Shadow a b g → g a < g (k n).2)\n ∧ (∀ n : ℕ, ∀ x : ℝ, x ∈ Ioo (k n).1 (k n).2 → g x < g (k n).2) := by sorry"} -{"project_name": "RobinTheorem", "name": "robin", "type": "theorem", "code": "import Mathlib\n\nopen ArithmeticFunction.sigma Real\n\ntheorem robin : RiemannHypothesis ↔ ∀ n > 5040,\n σ 1 n < exp (eulerMascheroniConstant) * n * log (log n) := by sorry"} -{"project_name": "RothTheorem", "name": "irrationalityMeasure_of_liouville", "type": "theorem", "code": "import Mathlib\n\nopen ENNReal Set\n/-- The irrationality measure of a real number -/\nnoncomputable def IrrationalityMeasure (x : ℝ) : ℝ≥0∞ :=\n sSup {r : ℝ≥0∞ | LiouvilleWith r.toReal x}\n/-- Sanity check, irrationality measure of a Liouville number if `∞`: -/\n\ntheorem irrationalityMeasure_of_liouville {x : ℝ} (hx : Liouville x) :\n IrrationalityMeasure x = ⊤ := by sorry"} -{"project_name": "RothTheorem", "name": "irrationalityMeasure_ge_one", "type": "theorem", "code": "import Mathlib\n\nopen ENNReal Set\n/-- The irrationality measure of a real number -/\nnoncomputable def IrrationalityMeasure (x : ℝ) : ℝ≥0∞ :=\n sSup {r : ℝ≥0∞ | LiouvilleWith r.toReal x}\n/-- Sanity check, irrationality measure of a Liouville number if `∞`: -/\n\ntheorem irrationalityMeasure_of_liouville {x : ℝ} (hx : Liouville x) :\n IrrationalityMeasure x = ⊤ := by sorry\n/-- irrationalityMeasure is ≥ 1: -/\n\ntheorem irrationalityMeasure_ge_one (x : ℝ) :\n 1 ≤ IrrationalityMeasure x := by sorry"} -{"project_name": "RothTheorem", "name": "roth", "type": "theorem", "code": "import Mathlib\n\nopen ENNReal Set\n/-- The irrationality measure of a real number -/\nnoncomputable def IrrationalityMeasure (x : ℝ) : ℝ≥0∞ :=\n sSup {r : ℝ≥0∞ | LiouvilleWith r.toReal x}\n/-- Sanity check, irrationality measure of a Liouville number if `∞`: -/\n\ntheorem irrationalityMeasure_of_liouville {x : ℝ} (hx : Liouville x) :\n IrrationalityMeasure x = ⊤ := by sorry\n/-- irrationalityMeasure is ≥ 1: -/\n\ntheorem irrationalityMeasure_ge_one (x : ℝ) :\n 1 ≤ IrrationalityMeasure x := by sorry\n/-- https://en.wikipedia.org/wiki/Roth%27s_theorem\nThe approximation exponent of an irrational algebraic real number is 2 -/\n\ntheorem roth {x : ℝ} (hx_irr : Irrational x) (hx_alg : IsAlgebraic ℚ x) :\n IrrationalityMeasure x = 2 := sorry"} -{"project_name": "RoucheCapelli", "name": "AugmentedMatrix_def", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry"} -{"project_name": "RoucheCapelli", "name": "linear_independence_with_external_vector", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry"} -{"project_name": "RoucheCapelli", "name": "subspace_inclusion_from_dimension", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry"} -{"project_name": "RoucheCapelli", "name": "equality_of_spans", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry"} -{"project_name": "RoucheCapelli", "name": "mulVec_as_linear_combination", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry"} -{"project_name": "RoucheCapelli", "name": "solvability_as_column_space_membership", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry"} -{"project_name": "RoucheCapelli", "name": "augmented_transpose_castSucc", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry"} -{"project_name": "RoucheCapelli", "name": "augmented_range_subset", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry"} -{"project_name": "RoucheCapelli", "name": "augmented_range_superset", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry"} -{"project_name": "RoucheCapelli", "name": "augmented_column_space_eq", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry\n/-- The column space of the augmented matrix equals the span of\n the columns of A together with b. -/\n\nlemma augmented_column_space_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace (AugmentedMatrix sys) =\n Submodule.span K (Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b}) := by sorry"} -{"project_name": "RoucheCapelli", "name": "column_space_le_augmented", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry\n/-- The column space of the augmented matrix equals the span of\n the columns of A together with b. -/\n\nlemma augmented_column_space_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace (AugmentedMatrix sys) =\n Submodule.span K (Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b}) := by sorry\n/-- The column space of A is contained in the column space of the augmented matrix. -/\n\nlemma column_space_le_augmented {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace sys.A ≤ ColumnSpace (AugmentedMatrix sys) := by sorry"} -{"project_name": "RoucheCapelli", "name": "b_mem_augmented_column_space", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry\n/-- The column space of the augmented matrix equals the span of\n the columns of A together with b. -/\n\nlemma augmented_column_space_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace (AugmentedMatrix sys) =\n Submodule.span K (Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b}) := by sorry\n/-- The column space of A is contained in the column space of the augmented matrix. -/\n\nlemma column_space_le_augmented {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace sys.A ≤ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- The vector b is in the column space of the augmented matrix. -/\n\nlemma b_mem_augmented_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n sys.b ∈ ColumnSpace (AugmentedMatrix sys) := by sorry"} -{"project_name": "RoucheCapelli", "name": "column_space_augmented_of_mem", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry\n/-- The column space of the augmented matrix equals the span of\n the columns of A together with b. -/\n\nlemma augmented_column_space_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace (AugmentedMatrix sys) =\n Submodule.span K (Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b}) := by sorry\n/-- The column space of A is contained in the column space of the augmented matrix. -/\n\nlemma column_space_le_augmented {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace sys.A ≤ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- The vector b is in the column space of the augmented matrix. -/\n\nlemma b_mem_augmented_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n sys.b ∈ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- Forward direction: if b is in the column space of A, then\n the column space of [A|b] equals the column space of A. -/\n\nlemma column_space_augmented_of_mem {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n ColumnSpace (AugmentedMatrix sys) = ColumnSpace sys.A := by sorry"} -{"project_name": "RoucheCapelli", "name": "rank_eq_of_mem_column_space", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry\n/-- The column space of the augmented matrix equals the span of\n the columns of A together with b. -/\n\nlemma augmented_column_space_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace (AugmentedMatrix sys) =\n Submodule.span K (Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b}) := by sorry\n/-- The column space of A is contained in the column space of the augmented matrix. -/\n\nlemma column_space_le_augmented {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace sys.A ≤ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- The vector b is in the column space of the augmented matrix. -/\n\nlemma b_mem_augmented_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n sys.b ∈ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- Forward direction: if b is in the column space of A, then\n the column space of [A|b] equals the column space of A. -/\n\nlemma column_space_augmented_of_mem {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n ColumnSpace (AugmentedMatrix sys) = ColumnSpace sys.A := by sorry\n/-- Forward direction: if b is in the column space of A,\n then MatrixRank A = MatrixRank [A|b]. -/\n\nlemma rank_eq_of_mem_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := by sorry"} -{"project_name": "RoucheCapelli", "name": "column_space_eq_of_rank_eq", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry\n/-- The column space of the augmented matrix equals the span of\n the columns of A together with b. -/\n\nlemma augmented_column_space_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace (AugmentedMatrix sys) =\n Submodule.span K (Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b}) := by sorry\n/-- The column space of A is contained in the column space of the augmented matrix. -/\n\nlemma column_space_le_augmented {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace sys.A ≤ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- The vector b is in the column space of the augmented matrix. -/\n\nlemma b_mem_augmented_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n sys.b ∈ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- Forward direction: if b is in the column space of A, then\n the column space of [A|b] equals the column space of A. -/\n\nlemma column_space_augmented_of_mem {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n ColumnSpace (AugmentedMatrix sys) = ColumnSpace sys.A := by sorry\n/-- Forward direction: if b is in the column space of A,\n then MatrixRank A = MatrixRank [A|b]. -/\n\nlemma rank_eq_of_mem_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := by sorry\n/-- Backward direction: if MatrixRank A = MatrixRank [A|b],\n then ColumnSpace A = ColumnSpace [A|b]. -/\n\nlemma column_space_eq_of_rank_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (h : MatrixRank sys.A = MatrixRank (AugmentedMatrix sys)) :\n ColumnSpace sys.A = ColumnSpace (AugmentedMatrix sys) := by sorry"} -{"project_name": "RoucheCapelli", "name": "mem_column_space_of_rank_eq", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry\n/-- The column space of the augmented matrix equals the span of\n the columns of A together with b. -/\n\nlemma augmented_column_space_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace (AugmentedMatrix sys) =\n Submodule.span K (Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b}) := by sorry\n/-- The column space of A is contained in the column space of the augmented matrix. -/\n\nlemma column_space_le_augmented {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace sys.A ≤ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- The vector b is in the column space of the augmented matrix. -/\n\nlemma b_mem_augmented_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n sys.b ∈ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- Forward direction: if b is in the column space of A, then\n the column space of [A|b] equals the column space of A. -/\n\nlemma column_space_augmented_of_mem {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n ColumnSpace (AugmentedMatrix sys) = ColumnSpace sys.A := by sorry\n/-- Forward direction: if b is in the column space of A,\n then MatrixRank A = MatrixRank [A|b]. -/\n\nlemma rank_eq_of_mem_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := by sorry\n/-- Backward direction: if MatrixRank A = MatrixRank [A|b],\n then ColumnSpace A = ColumnSpace [A|b]. -/\n\nlemma column_space_eq_of_rank_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (h : MatrixRank sys.A = MatrixRank (AugmentedMatrix sys)) :\n ColumnSpace sys.A = ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- Backward direction: if MatrixRank A = MatrixRank [A|b],\n then b is in the column space of A. -/\n\nlemma mem_column_space_of_rank_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (h : MatrixRank sys.A = MatrixRank (AugmentedMatrix sys)) :\n sys.b ∈ ColumnSpace sys.A := by sorry"} -{"project_name": "RoucheCapelli", "name": "rank_equality_condition", "type": "lemma", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry\n/-- The column space of the augmented matrix equals the span of\n the columns of A together with b. -/\n\nlemma augmented_column_space_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace (AugmentedMatrix sys) =\n Submodule.span K (Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b}) := by sorry\n/-- The column space of A is contained in the column space of the augmented matrix. -/\n\nlemma column_space_le_augmented {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace sys.A ≤ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- The vector b is in the column space of the augmented matrix. -/\n\nlemma b_mem_augmented_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n sys.b ∈ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- Forward direction: if b is in the column space of A, then\n the column space of [A|b] equals the column space of A. -/\n\nlemma column_space_augmented_of_mem {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n ColumnSpace (AugmentedMatrix sys) = ColumnSpace sys.A := by sorry\n/-- Forward direction: if b is in the column space of A,\n then MatrixRank A = MatrixRank [A|b]. -/\n\nlemma rank_eq_of_mem_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := by sorry\n/-- Backward direction: if MatrixRank A = MatrixRank [A|b],\n then ColumnSpace A = ColumnSpace [A|b]. -/\n\nlemma column_space_eq_of_rank_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (h : MatrixRank sys.A = MatrixRank (AugmentedMatrix sys)) :\n ColumnSpace sys.A = ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- Backward direction: if MatrixRank A = MatrixRank [A|b],\n then b is in the column space of A. -/\n\nlemma mem_column_space_of_rank_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (h : MatrixRank sys.A = MatrixRank (AugmentedMatrix sys)) :\n sys.b ∈ ColumnSpace sys.A := by sorry\n/-- A vector b is in the column space of A iff rank(A) = rank([A|b]). -/\n\nlemma rank_equality_condition {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n sys.b ∈ ColumnSpace sys.A ↔ MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := sorry"} -{"project_name": "RoucheCapelli", "name": "rouche_capelli", "type": "theorem", "code": "import Mathlib\n\nopen Matrix\n\nopen Submodule\n\nvariable {K : Type*} [Field K]\n\nvariable {m n : ℕ}\n/-- A system of linear equations Ax = b, where A is an m × n coefficient matrix,\n x is an n × 1 column vector of unknowns, and b is an m × 1 column vector of constants. -/\n\nstructure SystemOfLinearEquations (K : Type*) [Field K] (m n : ℕ) where\n /-- coefficient matrix -/\n A : Matrix (Fin m) (Fin n) K\n /-- constant vector -/\n b : Fin m → K\n/-- The augmented matrix [A|b] is the matrix obtained by appending the column vector b\n to the coefficient matrix A. -/\n\ndef AugmentedMatrix {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) : Matrix (Fin m) (Fin (n + 1)) K :=\n Matrix.of (fun i j => if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i)\n\nlemma AugmentedMatrix_def {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (i : Fin m) (j : Fin (n + 1)) :\n AugmentedMatrix sys i j = if h : j.val < n then sys.A i ⟨j.val, h⟩ else sys.b i := sorry\n/-- The column space of a matrix A is the set of all possible linear combinations\n of its column vectors. -/\n\ndef ColumnSpace {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) :\n Submodule K (Fin m → K) :=\n Submodule.span K (Set.range (fun j : Fin n => A.transpose j))\n/-- The rank of a matrix A is the dimension of its column space. -/\nnoncomputable def MatrixRank {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K) : ℕ :=\n Module.finrank K (ColumnSpace A)\n/-- If a linearly independent set S doesn't contain a vector v in its span,\n then S ∪ {v} is linearly independent. -/\n\nlemma linear_independence_with_external_vector {V : Type*} [AddCommGroup V] [Module K V]\n {S : Set V} (hS : LinearIndependent K (fun i : S => (i : V)))\n {v : V} (hv : v ∉ Submodule.span K S) :\n LinearIndependent K (fun i : (S ∪ {v} : Set V) => (i : V)) := by sorry\n/-- If U is a finite-dimensional subspace and dim(span(U ∪ {v})) = dim(U), then v ∈ U. -/\n\nlemma subspace_inclusion_from_dimension {V : Type*} [AddCommGroup V] [Module K V]\n {U : Submodule K V} [Module.Finite K U] (v : V)\n (h : Module.finrank K ↥(Submodule.span K ((U : Set V) ∪ {v})) = Module.finrank K U) :\n v ∈ U := by sorry\n/-- span(S ∪ {v}) = span(span(S) ∪ {v}) -/\n\nlemma equality_of_spans {V : Type*} [AddCommGroup V] [Module K V]\n (S : Set V) (v : V) :\n Submodule.span K (S ∪ {v}) = Submodule.span K ((Submodule.span K S : Set V) ∪ {v}) := by sorry\n/-- Helper: mulVec expressed as a linear combination of columns equals\n a linear combination with plain scalar multiplication (no MulOpposite). -/\n\nlemma mulVec_as_linear_combination {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (x : Fin n → K) :\n A.mulVec x = ∑ j : Fin n, x j • Aᵀ j := by sorry\n/-- The system Ax = b has a solution iff b is in the column space of A. -/\n\nlemma solvability_as_column_space_membership {K : Type*} [Field K] {m n : ℕ}\n (A : Matrix (Fin m) (Fin n) K) (b : Fin m → K) :\n (∃ x : Fin n → K, A.mulVec x = b) ↔ b ∈ ColumnSpace A := by sorry\n/-- The transpose of the augmented matrix at an index cast from Fin n\n equals the corresponding transpose column of A. -/\n\nlemma augmented_transpose_castSucc {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) (j : Fin n) :\n (AugmentedMatrix sys)ᵀ (Fin.castSucc j) = sys.Aᵀ j := by sorry\n/-- The range of augmented matrix transpose columns is contained in\n the range of A's transpose columns union {b}. -/\n\nlemma augmented_range_subset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) ⊆\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} := by sorry\n/-- The range of A's transpose columns union {b} is contained in the\n range of augmented matrix transpose columns. -/\n\nlemma augmented_range_superset {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b} ⊆\n Set.range (fun j : Fin (n + 1) => (AugmentedMatrix sys)ᵀ j) := by sorry\n/-- The column space of the augmented matrix equals the span of\n the columns of A together with b. -/\n\nlemma augmented_column_space_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace (AugmentedMatrix sys) =\n Submodule.span K (Set.range (fun j : Fin n => sys.Aᵀ j) ∪ {sys.b}) := by sorry\n/-- The column space of A is contained in the column space of the augmented matrix. -/\n\nlemma column_space_le_augmented {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n ColumnSpace sys.A ≤ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- The vector b is in the column space of the augmented matrix. -/\n\nlemma b_mem_augmented_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n sys.b ∈ ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- Forward direction: if b is in the column space of A, then\n the column space of [A|b] equals the column space of A. -/\n\nlemma column_space_augmented_of_mem {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n ColumnSpace (AugmentedMatrix sys) = ColumnSpace sys.A := by sorry\n/-- Forward direction: if b is in the column space of A,\n then MatrixRank A = MatrixRank [A|b]. -/\n\nlemma rank_eq_of_mem_column_space {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (hb : sys.b ∈ ColumnSpace sys.A) :\n MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := by sorry\n/-- Backward direction: if MatrixRank A = MatrixRank [A|b],\n then ColumnSpace A = ColumnSpace [A|b]. -/\n\nlemma column_space_eq_of_rank_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (h : MatrixRank sys.A = MatrixRank (AugmentedMatrix sys)) :\n ColumnSpace sys.A = ColumnSpace (AugmentedMatrix sys) := by sorry\n/-- Backward direction: if MatrixRank A = MatrixRank [A|b],\n then b is in the column space of A. -/\n\nlemma mem_column_space_of_rank_eq {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n)\n (h : MatrixRank sys.A = MatrixRank (AugmentedMatrix sys)) :\n sys.b ∈ ColumnSpace sys.A := by sorry\n/-- A vector b is in the column space of A iff rank(A) = rank([A|b]). -/\n\nlemma rank_equality_condition {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n sys.b ∈ ColumnSpace sys.A ↔ MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := sorry\n/-- Rouche--Capelli Theorem: A system of linear equations Ax = b is consistent\n (has at least one solution) iff rank(A) = rank([A|b]). -/\n\ntheorem rouche_capelli {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n (∃ x : Fin n → K, sys.A.mulVec x = sys.b) ↔\n MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := sorry"} -{"project_name": "SchanuelLemma", "name": "a_exists", "type": "lemma", "code": "import Mathlib\n\nopen LinearMap CategoryTheory\n\nuniverse w u v\n\nvariable {R : Type u} [Ring R] {K P1 L P2 N M : ModuleCat.{v} R} {c1 : K ⟶ P1} {p1 : P1 ⟶ M}\n {c2 : L ⟶ P2} {p2 : P2 ⟶ M} (h1 : c1 ≫ p1 = 0) (h2 : c2 ≫ p2 = 0)\n (hS1 : (ShortComplex.mk c1 p1 h1).ShortExact) (hS2 : (ShortComplex.mk c2 p2 h2).ShortExact)\n [Module.Projective R P1] [Module.Projective R P2]\n\nvariable (P1 P2)\n/-- The augmented short complex\n$0 \\to K \\times P_2 \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the first short exact sequence by appending $P_2$. -/\n\nabbrev S1' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (K × P2)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (c1.hom.prodMap .id)\n g := ModuleCat.ofHom (LinearMap.fst R _ _) ≫ p1\n zero := by\n ext k\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_fst,\n coe_inl, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h1, ModuleCat.hom_zero]\n .\n simp\n/-- The augmented short complex\n$0 \\to P_1 \\times L \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the second short exact sequence by appending $P_1$. -/\n\nabbrev S2' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (P1 × L)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.id.prodMap c2.hom)\n g := ModuleCat.ofHom (LinearMap.snd R _ _) ≫ p2\n zero := by\n ext l\n .\n simp\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_snd,\n coe_inr, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h2, ModuleCat.hom_zero]\n\nvariable {P1 P2} (p1 p2) in\n/-- The pullback (kernel) short complex\n$0 \\to \\ker(f_1 \\oplus f_2) \\to P_1 \\times P_2 \\to M \\to 0$. -/\n\nabbrev S3 : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (LinearMap.coprod p1.hom p2.hom).ker\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.coprod p1.hom p2.hom).ker.subtype\n g := ModuleCat.ofHom <| LinearMap.coprod p1.hom p2.hom\nomit [Module.Projective R ↑P2] in\n\nlemma a_exists (h22 : (S2' P1 P2 h2).ShortExact) :\n ∃ a, a ≫ p2 = p1 := by sorry"} -{"project_name": "SchanuelLemma", "name": "surj_p2", "type": "lemma", "code": "import Mathlib\n\nopen LinearMap CategoryTheory\n\nuniverse w u v\n\nvariable {R : Type u} [Ring R] {K P1 L P2 N M : ModuleCat.{v} R} {c1 : K ⟶ P1} {p1 : P1 ⟶ M}\n {c2 : L ⟶ P2} {p2 : P2 ⟶ M} (h1 : c1 ≫ p1 = 0) (h2 : c2 ≫ p2 = 0)\n (hS1 : (ShortComplex.mk c1 p1 h1).ShortExact) (hS2 : (ShortComplex.mk c2 p2 h2).ShortExact)\n [Module.Projective R P1] [Module.Projective R P2]\n\nvariable (P1 P2)\n/-- The augmented short complex\n$0 \\to K \\times P_2 \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the first short exact sequence by appending $P_2$. -/\n\nabbrev S1' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (K × P2)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (c1.hom.prodMap .id)\n g := ModuleCat.ofHom (LinearMap.fst R _ _) ≫ p1\n zero := by\n ext k\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_fst,\n coe_inl, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h1, ModuleCat.hom_zero]\n .\n simp\n/-- The augmented short complex\n$0 \\to P_1 \\times L \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the second short exact sequence by appending $P_1$. -/\n\nabbrev S2' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (P1 × L)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.id.prodMap c2.hom)\n g := ModuleCat.ofHom (LinearMap.snd R _ _) ≫ p2\n zero := by\n ext l\n .\n simp\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_snd,\n coe_inr, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h2, ModuleCat.hom_zero]\n\nvariable {P1 P2} (p1 p2) in\n/-- The pullback (kernel) short complex\n$0 \\to \\ker(f_1 \\oplus f_2) \\to P_1 \\times P_2 \\to M \\to 0$. -/\n\nabbrev S3 : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (LinearMap.coprod p1.hom p2.hom).ker\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.coprod p1.hom p2.hom).ker.subtype\n g := ModuleCat.ofHom <| LinearMap.coprod p1.hom p2.hom\nomit [Module.Projective R ↑P2] in\n\nlemma a_exists (h22 : (S2' P1 P2 h2).ShortExact) :\n ∃ a, a ≫ p2 = p1 := by sorry\n\nsection prerequisites\nomit [Module.Projective R ↑P1] [Module.Projective R ↑P2]\n\nvariable {P1 P2 h1 h2}\n\nlemma surj_p2 (hS2 : (S2' P1 P2 h2).ShortExact) : Function.Surjective p2.hom := by sorry"} -{"project_name": "SchanuelLemma", "name": "surj_p1", "type": "lemma", "code": "import Mathlib\n\nopen LinearMap CategoryTheory\n\nuniverse w u v\n\nvariable {R : Type u} [Ring R] {K P1 L P2 N M : ModuleCat.{v} R} {c1 : K ⟶ P1} {p1 : P1 ⟶ M}\n {c2 : L ⟶ P2} {p2 : P2 ⟶ M} (h1 : c1 ≫ p1 = 0) (h2 : c2 ≫ p2 = 0)\n (hS1 : (ShortComplex.mk c1 p1 h1).ShortExact) (hS2 : (ShortComplex.mk c2 p2 h2).ShortExact)\n [Module.Projective R P1] [Module.Projective R P2]\n\nvariable (P1 P2)\n/-- The augmented short complex\n$0 \\to K \\times P_2 \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the first short exact sequence by appending $P_2$. -/\n\nabbrev S1' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (K × P2)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (c1.hom.prodMap .id)\n g := ModuleCat.ofHom (LinearMap.fst R _ _) ≫ p1\n zero := by\n ext k\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_fst,\n coe_inl, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h1, ModuleCat.hom_zero]\n .\n simp\n/-- The augmented short complex\n$0 \\to P_1 \\times L \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the second short exact sequence by appending $P_1$. -/\n\nabbrev S2' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (P1 × L)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.id.prodMap c2.hom)\n g := ModuleCat.ofHom (LinearMap.snd R _ _) ≫ p2\n zero := by\n ext l\n .\n simp\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_snd,\n coe_inr, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h2, ModuleCat.hom_zero]\n\nvariable {P1 P2} (p1 p2) in\n/-- The pullback (kernel) short complex\n$0 \\to \\ker(f_1 \\oplus f_2) \\to P_1 \\times P_2 \\to M \\to 0$. -/\n\nabbrev S3 : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (LinearMap.coprod p1.hom p2.hom).ker\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.coprod p1.hom p2.hom).ker.subtype\n g := ModuleCat.ofHom <| LinearMap.coprod p1.hom p2.hom\nomit [Module.Projective R ↑P2] in\n\nlemma a_exists (h22 : (S2' P1 P2 h2).ShortExact) :\n ∃ a, a ≫ p2 = p1 := by sorry\n\nsection prerequisites\nomit [Module.Projective R ↑P1] [Module.Projective R ↑P2]\n\nvariable {P1 P2 h1 h2}\n\nlemma surj_p2 (hS2 : (S2' P1 P2 h2).ShortExact) : Function.Surjective p2.hom := by sorry\n\nlemma surj_p1 (hS1 : (S1' P1 P2 h1).ShortExact) : Function.Surjective p1.hom := by sorry"} -{"project_name": "SchanuelLemma", "name": "inj_c1", "type": "lemma", "code": "import Mathlib\n\nopen LinearMap CategoryTheory\n\nuniverse w u v\n\nvariable {R : Type u} [Ring R] {K P1 L P2 N M : ModuleCat.{v} R} {c1 : K ⟶ P1} {p1 : P1 ⟶ M}\n {c2 : L ⟶ P2} {p2 : P2 ⟶ M} (h1 : c1 ≫ p1 = 0) (h2 : c2 ≫ p2 = 0)\n (hS1 : (ShortComplex.mk c1 p1 h1).ShortExact) (hS2 : (ShortComplex.mk c2 p2 h2).ShortExact)\n [Module.Projective R P1] [Module.Projective R P2]\n\nvariable (P1 P2)\n/-- The augmented short complex\n$0 \\to K \\times P_2 \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the first short exact sequence by appending $P_2$. -/\n\nabbrev S1' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (K × P2)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (c1.hom.prodMap .id)\n g := ModuleCat.ofHom (LinearMap.fst R _ _) ≫ p1\n zero := by\n ext k\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_fst,\n coe_inl, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h1, ModuleCat.hom_zero]\n .\n simp\n/-- The augmented short complex\n$0 \\to P_1 \\times L \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the second short exact sequence by appending $P_1$. -/\n\nabbrev S2' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (P1 × L)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.id.prodMap c2.hom)\n g := ModuleCat.ofHom (LinearMap.snd R _ _) ≫ p2\n zero := by\n ext l\n .\n simp\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_snd,\n coe_inr, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h2, ModuleCat.hom_zero]\n\nvariable {P1 P2} (p1 p2) in\n/-- The pullback (kernel) short complex\n$0 \\to \\ker(f_1 \\oplus f_2) \\to P_1 \\times P_2 \\to M \\to 0$. -/\n\nabbrev S3 : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (LinearMap.coprod p1.hom p2.hom).ker\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.coprod p1.hom p2.hom).ker.subtype\n g := ModuleCat.ofHom <| LinearMap.coprod p1.hom p2.hom\nomit [Module.Projective R ↑P2] in\n\nlemma a_exists (h22 : (S2' P1 P2 h2).ShortExact) :\n ∃ a, a ≫ p2 = p1 := by sorry\n\nsection prerequisites\nomit [Module.Projective R ↑P1] [Module.Projective R ↑P2]\n\nvariable {P1 P2 h1 h2}\n\nlemma surj_p2 (hS2 : (S2' P1 P2 h2).ShortExact) : Function.Surjective p2.hom := by sorry\n\nlemma surj_p1 (hS1 : (S1' P1 P2 h1).ShortExact) : Function.Surjective p1.hom := by sorry\n\nlemma inj_c1 (hS1 : (S1' P1 P2 h1).ShortExact) : Function.Injective c1.hom := sorry"} -{"project_name": "SchanuelLemma", "name": "inj_c2", "type": "lemma", "code": "import Mathlib\n\nopen LinearMap CategoryTheory\n\nuniverse w u v\n\nvariable {R : Type u} [Ring R] {K P1 L P2 N M : ModuleCat.{v} R} {c1 : K ⟶ P1} {p1 : P1 ⟶ M}\n {c2 : L ⟶ P2} {p2 : P2 ⟶ M} (h1 : c1 ≫ p1 = 0) (h2 : c2 ≫ p2 = 0)\n (hS1 : (ShortComplex.mk c1 p1 h1).ShortExact) (hS2 : (ShortComplex.mk c2 p2 h2).ShortExact)\n [Module.Projective R P1] [Module.Projective R P2]\n\nvariable (P1 P2)\n/-- The augmented short complex\n$0 \\to K \\times P_2 \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the first short exact sequence by appending $P_2$. -/\n\nabbrev S1' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (K × P2)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (c1.hom.prodMap .id)\n g := ModuleCat.ofHom (LinearMap.fst R _ _) ≫ p1\n zero := by\n ext k\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_fst,\n coe_inl, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h1, ModuleCat.hom_zero]\n .\n simp\n/-- The augmented short complex\n$0 \\to P_1 \\times L \\to P_1 \\times P_2 \\to M \\to 0$\nobtained from the second short exact sequence by appending $P_1$. -/\n\nabbrev S2' : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (P1 × L)\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.id.prodMap c2.hom)\n g := ModuleCat.ofHom (LinearMap.snd R _ _) ≫ p2\n zero := by\n ext l\n .\n simp\n .\n simp only [ModuleCat.of_coe, ModuleCat.hom_comp, ModuleCat.hom_ofHom, coe_comp, coe_snd,\n coe_inr, Function.comp_apply, prodMap_apply, id_coe, id_eq, ModuleCat.hom_zero, zero_comp]\n rw [← LinearMap.comp_apply, ← ModuleCat.hom_comp, h2, ModuleCat.hom_zero]\n\nvariable {P1 P2} (p1 p2) in\n/-- The pullback (kernel) short complex\n$0 \\to \\ker(f_1 \\oplus f_2) \\to P_1 \\times P_2 \\to M \\to 0$. -/\n\nabbrev S3 : ShortComplex (ModuleCat R) where\n X₁ := ModuleCat.of R (LinearMap.coprod p1.hom p2.hom).ker\n X₂ := ModuleCat.of R (P1 × P2)\n X₃ := ModuleCat.of R M\n f := ModuleCat.ofHom (LinearMap.coprod p1.hom p2.hom).ker.subtype\n g := ModuleCat.ofHom <| LinearMap.coprod p1.hom p2.hom\nomit [Module.Projective R ↑P2] in\n\nlemma a_exists (h22 : (S2' P1 P2 h2).ShortExact) :\n ∃ a, a ≫ p2 = p1 := by sorry\n\nsection prerequisites\nomit [Module.Projective R ↑P1] [Module.Projective R ↑P2]\n\nvariable {P1 P2 h1 h2}\n\nlemma surj_p2 (hS2 : (S2' P1 P2 h2).ShortExact) : Function.Surjective p2.hom := by sorry\n\nlemma surj_p1 (hS1 : (S1' P1 P2 h1).ShortExact) : Function.Surjective p1.hom := by sorry\n\nlemma inj_c1 (hS1 : (S1' P1 P2 h1).ShortExact) : Function.Injective c1.hom := sorry\n\nlemma inj_c2 (hS2 : (S2' P1 P2 h2).ShortExact) : Function.Injective c2.hom := sorry"} -{"project_name": "SchauderFixedPointTheorem", "name": "brouwer_fixed_point_of_finite_dimensional", "type": "lemma", "code": "import Mathlib\n\nopen Set Filter Topology\nprivate lemma brouwer_fixed_point_of_finite_dimensional\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]\n [T2Space E] [LocallyConvexSpace ℝ E]\n {K : Set E} (hK_ne : K.Nonempty) (hK_conv : Convex ℝ K) (hK_cpt : IsCompact K)\n (hK_fd : ∃ (W : Submodule ℝ E), FiniteDimensional ℝ W ∧ K ⊆ W)\n {g : E → E} (hg_cont : ContinuousOn g K) (hg_maps : MapsTo g K K) :\n ∃ x ∈ K, g x = x := by sorry"} -{"project_name": "SchauderFixedPointTheorem", "name": "centerMass_sub_const", "type": "lemma", "code": "import Mathlib\n\nopen Set Filter Topology\nprivate lemma brouwer_fixed_point_of_finite_dimensional\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]\n [T2Space E] [LocallyConvexSpace ℝ E]\n {K : Set E} (hK_ne : K.Nonempty) (hK_conv : Convex ℝ K) (hK_cpt : IsCompact K)\n (hK_fd : ∃ (W : Submodule ℝ E), FiniteDimensional ℝ W ∧ K ⊆ W)\n {g : E → E} (hg_cont : ContinuousOn g K) (hg_maps : MapsTo g K K) :\n ∃ x ∈ K, g x = x := by sorry\nprivate lemma centerMass_sub_const {E : Type*} [AddCommGroup E] [Module ℝ E]\n (S : Finset E) {w : E → ℝ} (hw : (∑ x ∈ S, w x) ≠ 0) (z : E) :\n S.centerMass w id - z = S.centerMass w (fun x => x - z) := by sorry"} -{"project_name": "SchauderFixedPointTheorem", "name": "approx_fixed_point_in_closure", "type": "lemma", "code": "import Mathlib\n\nopen Set Filter Topology\nprivate lemma brouwer_fixed_point_of_finite_dimensional\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]\n [T2Space E] [LocallyConvexSpace ℝ E]\n {K : Set E} (hK_ne : K.Nonempty) (hK_conv : Convex ℝ K) (hK_cpt : IsCompact K)\n (hK_fd : ∃ (W : Submodule ℝ E), FiniteDimensional ℝ W ∧ K ⊆ W)\n {g : E → E} (hg_cont : ContinuousOn g K) (hg_maps : MapsTo g K K) :\n ∃ x ∈ K, g x = x := by sorry\nprivate lemma centerMass_sub_const {E : Type*} [AddCommGroup E] [Module ℝ E]\n (S : Finset E) {w : E → ℝ} (hw : (∑ x ∈ S, w x) ≠ 0) (z : E) :\n S.centerMass w id - z = S.centerMass w (fun x => x - z) := by sorry\nprivate lemma approx_fixed_point_in_closure\n {E : Type*}\n [AddCommGroup E] [Module ℝ E]\n [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]\n [T2Space E] [LocallyConvexSpace ℝ E]\n {C : Set E} (hne : C.Nonempty) (hconv : Convex ℝ C) (hcpt : IsCompact C)\n {f : E → E} (hf : Continuous f) (hfc : MapsTo f C C)\n {V : Set E} (hVopen : IsOpen V) (hVconv : Convex ℝ V) (hV0 : (0 : E) ∈ V) :\n ∃ y ∈ C, y - f y ∈ closure V := by sorry"} -{"project_name": "SchauderFixedPointTheorem", "name": "SchauderFixedPointTheorem", "type": "theorem", "code": "import Mathlib\n\nopen Set Filter Topology\nprivate lemma brouwer_fixed_point_of_finite_dimensional\n {E : Type*} [AddCommGroup E] [Module ℝ E]\n [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]\n [T2Space E] [LocallyConvexSpace ℝ E]\n {K : Set E} (hK_ne : K.Nonempty) (hK_conv : Convex ℝ K) (hK_cpt : IsCompact K)\n (hK_fd : ∃ (W : Submodule ℝ E), FiniteDimensional ℝ W ∧ K ⊆ W)\n {g : E → E} (hg_cont : ContinuousOn g K) (hg_maps : MapsTo g K K) :\n ∃ x ∈ K, g x = x := by sorry\nprivate lemma centerMass_sub_const {E : Type*} [AddCommGroup E] [Module ℝ E]\n (S : Finset E) {w : E → ℝ} (hw : (∑ x ∈ S, w x) ≠ 0) (z : E) :\n S.centerMass w id - z = S.centerMass w (fun x => x - z) := by sorry\nprivate lemma approx_fixed_point_in_closure\n {E : Type*}\n [AddCommGroup E] [Module ℝ E]\n [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]\n [T2Space E] [LocallyConvexSpace ℝ E]\n {C : Set E} (hne : C.Nonempty) (hconv : Convex ℝ C) (hcpt : IsCompact C)\n {f : E → E} (hf : Continuous f) (hfc : MapsTo f C C)\n {V : Set E} (hVopen : IsOpen V) (hVconv : Convex ℝ V) (hV0 : (0 : E) ∈ V) :\n ∃ y ∈ C, y - f y ∈ closure V := by sorry\n\nopen Set in\n/-- **Schauder Fixed-Point Theorem**: If `C` is a nonempty convex compact subset of a locally\nconvex Hausdorff topological vector space `E` over `ℝ`, and `f : E → E` is continuous with\n`f(C) ⊆ C`, then `f` has a fixed point in `C`. -/\n\ntheorem SchauderFixedPointTheorem\n {E : Type*}\n [AddCommGroup E] [Module ℝ E]\n [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]\n [T2Space E] [LocallyConvexSpace ℝ E]\n {C : Set E} (hne : C.Nonempty) (hconv : Convex ℝ C) (hcpt : IsCompact C)\n {f : E → E} (hf : Continuous f) (hfc : MapsTo f C C) :\n ∃ x ∈ C, f x = x := by sorry"} -{"project_name": "SchurRamsey", "name": "ramsey", "type": "theorem", "code": "import Mathlib\n\nopen Setoid Set\n/--\nFor any n, there exists a positive integer S\nsuch that for any n-coloring of the complete graph on S vertices,\nthere exists a monochromatic triangle.\n-/\n\ntheorem ramsey (n : ℕ) : ∃ S : ℕ, ∀ coloring : (SimpleGraph.completeGraph (Fin S)).edgeSet → Fin n,\n ∃ u : Fin n,\n ∃ x y z : (SimpleGraph.completeGraph (Fin S)).edgeSet,\n coloring x = u ∧ coloring y = u ∧ coloring z = u ∧\n (∃ a b c : Fin S, (x : Sym2 (Fin S)) = s(a, b) ∧ (y : Sym2 (Fin S)) = s(b, c) ∧ (z : Sym2 (Fin S)) = s(a, c)) := by sorry"} -{"project_name": "SchurRamsey", "name": "schur", "type": "theorem", "code": "import Mathlib\n\nopen Setoid Set\n/--\nFor any n, there exists a positive integer S\nsuch that for any n-coloring of the complete graph on S vertices,\nthere exists a monochromatic triangle.\n-/\n\ntheorem ramsey (n : ℕ) : ∃ S : ℕ, ∀ coloring : (SimpleGraph.completeGraph (Fin S)).edgeSet → Fin n,\n ∃ u : Fin n,\n ∃ x y z : (SimpleGraph.completeGraph (Fin S)).edgeSet,\n coloring x = u ∧ coloring y = u ∧ coloring z = u ∧\n (∃ a b c : Fin S, (x : Sym2 (Fin S)) = s(a, b) ∧ (y : Sym2 (Fin S)) = s(b, c) ∧ (z : Sym2 (Fin S)) = s(a, c)) := by sorry\n/--\nFor any n, there exists a positive integer S\nsuch that for any partition of the integers {1, 2, ..., S} into n parts,\nthere exist three integers x, y, z in the same part such that x + y = z.\n-/\n\ntheorem schur (n : ℕ) : ∃ S : ℕ, ∀ r : (Icc 1 S) → Fin n,\n ∃ u : Fin n,\n ∃ x y z : Icc 1 S,\n r x = u ∧ r y = u ∧ r z = u ∧ (x : ℕ) + y = z := by sorry"} -{"project_name": "SinkhornTheorem", "name": "RCseq_pos", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "colSum_one", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rowSum_one", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry"} -{"project_name": "SinkhornTheorem", "name": "colOne_to_rowOne", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rowOne_to_colOne", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "nonEmptyFin", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sum_rowSums_eq", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sum_colSums_eq", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry"} -{"project_name": "SinkhornTheorem", "name": "inf'_le_one_of_sum_eq", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry"} -{"project_name": "SinkhornTheorem", "name": "one_le_sup'_of_sum_eq", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rowSums_colSums_bound", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "colOneSeq_entry", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry"} -{"project_name": "SinkhornTheorem", "name": "colOneSeq_pos", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry"} -{"project_name": "SinkhornTheorem", "name": "colSums_convex", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rowSums_pos", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry"} -{"project_name": "SinkhornTheorem", "name": "colSums_pos", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rowOneSeq_pos", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rowSums_convex", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry"} -{"project_name": "SinkhornTheorem", "name": "colOneSeq_col_sum_one", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rowOneSeq_row_sum_one", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry"} -{"project_name": "SinkhornTheorem", "name": "inf'_rowSums_le_succ", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sup'_rowSums_ge_succ", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "inf'_colSums_le_succ", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sup'_colSums_ge_succ", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry\nprivate lemma sup'_colSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rowSums_colSums_min_max_monotone_antitone", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry\nprivate lemma sup'_colSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\n\nlemma rowSums_colSums_min_max_monotone_antitone (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n)) := sorry"} -{"project_name": "SinkhornTheorem", "name": "entry_lower_bound", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry\nprivate lemma sup'_colSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\n\nlemma rowSums_colSums_min_max_monotone_antitone (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n)) := sorry\n\nset_option maxHeartbeats 800000 in\n\nlemma entry_lower_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n ∃ μ > 0, ∀ n i j, μ ≤ colOneSeq A n i j := by sorry"} -{"project_name": "SinkhornTheorem", "name": "colSums_tendsTo_one", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry\nprivate lemma sup'_colSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\n\nlemma rowSums_colSums_min_max_monotone_antitone (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n)) := sorry\n\nset_option maxHeartbeats 800000 in\n\nlemma entry_lower_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n ∃ μ > 0, ∀ n i j, μ ≤ colOneSeq A n i j := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma colSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (colSums A) atTop (𝓝 1) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "tendsto_of_tendsto_succ", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry\nprivate lemma sup'_colSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\n\nlemma rowSums_colSums_min_max_monotone_antitone (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n)) := sorry\n\nset_option maxHeartbeats 800000 in\n\nlemma entry_lower_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n ∃ μ > 0, ∀ n i j, μ ≤ colOneSeq A n i j := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma colSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (colSums A) atTop (𝓝 1) := by sorry\nprivate lemma tendsto_of_tendsto_succ {α : Type*} [TopologicalSpace α] {f : ℕ → α} {L : α}\n (h : Tendsto (fun n => f (n + 1)) atTop (𝓝 L)) : Tendsto f atTop (𝓝 L) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rowSums_tendsTo_one", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry\nprivate lemma sup'_colSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\n\nlemma rowSums_colSums_min_max_monotone_antitone (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n)) := sorry\n\nset_option maxHeartbeats 800000 in\n\nlemma entry_lower_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n ∃ μ > 0, ∀ n i j, μ ≤ colOneSeq A n i j := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma colSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (colSums A) atTop (𝓝 1) := by sorry\nprivate lemma tendsto_of_tendsto_succ {α : Type*} [TopologicalSpace α] {f : ℕ → α} {L : α}\n (h : Tendsto (fun n => f (n + 1)) atTop (𝓝 L)) : Tendsto f atTop (𝓝 L) := by sorry\n\nlemma rowSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (rowSums A) atTop (𝓝 1) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "rescale", "type": "lemma", "code": "import Mathlib\n\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\n\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\n\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\n\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\n\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\n\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\n\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\n\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\n\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry\nprivate lemma sup'_colSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\n\nlemma rowSums_colSums_min_max_monotone_antitone (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n)) := sorry\n\nset_option maxHeartbeats 800000 in\n\nlemma entry_lower_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n ∃ μ > 0, ∀ n i j, μ ≤ colOneSeq A n i j := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma colSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (colSums A) atTop (𝓝 1) := by sorry\nprivate lemma tendsto_of_tendsto_succ {α : Type*} [TopologicalSpace α] {f : ℕ → α} {L : α}\n (h : Tendsto (fun n => f (n + 1)) atTop (𝓝 L)) : Tendsto f atTop (𝓝 L) := by sorry\n\nlemma rowSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (rowSums A) atTop (𝓝 1) := by sorry\n\nlemma rescale (hN : 0 < N) (x y : ℕ → RVec N)\n (hx : ∀ n, ∀ i, 0 < x n i) (hy : ∀ n, ∀ i, 0 < y n i)\n (B : RSMatrix N) (hB : ∀ i, ∀ j, 0 < B i j)\n (h : ∀ i, ∀ j, Tendsto (fun n ↦ x n i * y n j) atTop (𝓝 (B i j))) :\n ∃ x' y' : ℕ → RVec N, ∃ xlim ylim : RVec N, (∀ n, ∀ i, 0 < x' n i ∧ 0 < y' n i) ∧\n (∀ n, ∀ i, ∀ j, x' n i * y' n j = x n i * y n j) ∧\n Tendsto x' atTop (𝓝 xlim) ∧ Tendsto y' atTop (𝓝 ylim)\n := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sinkhorn_existence", "type": "theorem", "code": "import Mathlib\n\nopen Matrix Finset Filter Topology\n/-- **Sinkhorn's Theorem (Existence):** If `A` is an `n x n` matrix with strictly positive real\nentries, then there exist diagonal matrices `D₁` and `D₂` with strictly positive diagonal entries\nsuch that `D₁ A D₂` is doubly stochastic. -/\n\ntheorem sinkhorn_existence {n : ℕ} (hn : 0 < n)\n (A : Matrix (Fin n) (Fin n) ℝ)\n (hA : ∀ i j, 0 < A i j) :\n ∃ d₁ d₂ : Fin n → ℝ,\n (∀ i, 0 < d₁ i) ∧\n (∀ i, 0 < d₂ i) ∧\n diagonal d₁ * A * diagonal d₂ ∈ doublyStochastic ℝ (Fin n) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.SinkhornTheorem.BackgroundLemmas\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry\nprivate lemma sup'_colSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nlemma rowSums_colSums_min_max_monotone_antitone (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n)) := sorry\nset_option maxHeartbeats 800000 in\nlemma entry_lower_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n ∃ μ > 0, ∀ n i j, μ ≤ colOneSeq A n i j := by sorry\nset_option maxHeartbeats 1600000 in\nlemma colSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (colSums A) atTop (𝓝 1) := by sorry\nprivate lemma tendsto_of_tendsto_succ {α : Type*} [TopologicalSpace α] {f : ℕ → α} {L : α}\n (h : Tendsto (fun n => f (n + 1)) atTop (𝓝 L)) : Tendsto f atTop (𝓝 L) := by sorry\nlemma rowSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (rowSums A) atTop (𝓝 1) := by sorry\nlemma rescale (hN : 0 < N) (x y : ℕ → RVec N)\n (hx : ∀ n, ∀ i, 0 < x n i) (hy : ∀ n, ∀ i, 0 < y n i)\n (B : RSMatrix N) (hB : ∀ i, ∀ j, 0 < B i j)\n (h : ∀ i, ∀ j, Tendsto (fun n ↦ x n i * y n j) atTop (𝓝 (B i j))) :\n ∃ x' y' : ℕ → RVec N, ∃ xlim ylim : RVec N, (∀ n, ∀ i, 0 < x' n i ∧ 0 < y' n i) ∧\n (∀ n, ∀ i, ∀ j, x' n i * y' n j = x n i * y n j) ∧\n Tendsto x' atTop (𝓝 xlim) ∧ Tendsto y' atTop (𝓝 ylim)\n := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sinkhorn_uniqueness", "type": "theorem", "code": "import Mathlib\n\nopen Matrix Finset Filter Topology\n/-- **Sinkhorn's Theorem (Existence):** If `A` is an `n x n` matrix with strictly positive real\nentries, then there exist diagonal matrices `D₁` and `D₂` with strictly positive diagonal entries\nsuch that `D₁ A D₂` is doubly stochastic. -/\n\ntheorem sinkhorn_existence {n : ℕ} (hn : 0 < n)\n (A : Matrix (Fin n) (Fin n) ℝ)\n (hA : ∀ i j, 0 < A i j) :\n ∃ d₁ d₂ : Fin n → ℝ,\n (∀ i, 0 < d₁ i) ∧\n (∀ i, 0 < d₂ i) ∧\n diagonal d₁ * A * diagonal d₂ ∈ doublyStochastic ℝ (Fin n) := by sorry\n/-- **Sinkhorn's Theorem (Uniqueness):** The diagonal factors `D₁` and `D₂` are unique up to\nreplacing `(D₁, D₂)` by `(c D₁, c⁻¹ D₂)` for a positive scalar `c`. -/\n\ntheorem sinkhorn_uniqueness {n : ℕ} (hn : 0 < n)\n (A : Matrix (Fin n) (Fin n) ℝ)\n (hA : ∀ i j, 0 < A i j)\n (d₁ d₂ d₁' d₂' : Fin n → ℝ)\n (hd₁ : ∀ i, 0 < d₁ i)\n (hd₂ : ∀ i, 0 < d₂ i)\n (hd₁' : ∀ i, 0 < d₁' i)\n (hd₂' : ∀ i, 0 < d₂' i)\n (hDS : diagonal d₁ * A * diagonal d₂ ∈ doublyStochastic ℝ (Fin n))\n (hDS' : diagonal d₁' * A * diagonal d₂' ∈ doublyStochastic ℝ (Fin n)) :\n ∃ c : ℝ, 0 < c ∧\n (∀ i, d₁' i = c * d₁ i) ∧\n (∀ i, d₂' i = d₂ i / c) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.SinkhornTheorem.BackgroundLemmas\nopen Matrix Filter Topology\n/-- The `N`-dim vector space of reals -/\nabbrev RVec (N : ℕ) := Fin N → ℝ\n/-- The space of `N × N` real square matrices -/\nabbrev RSMatrix (N : ℕ) := Matrix (Fin N) (Fin N) ℝ\nvariable {N : ℕ}\n/-- The sequence of pairs of vectors used to normalize rows and columns alternately -/\nnoncomputable def RCseq (A : RSMatrix N) (n : ℕ) : (RVec N × RVec N) :=\n match n with\n | 0 => (1, (1 ᵥ* A)⁻¹)\n | n + 1 =>\n let (d, e) := RCseq A n;\n let A' := (diagonal d) * A * (diagonal e);\n let d' := (A' *ᵥ 1)⁻¹;\n let e' := (1 ᵥ* ((diagonal d') * A'))⁻¹;\n (d' * d, e * e')\n/-- The left component of `RCSeq` -/\nnoncomputable def RCseqLeft (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).1\n/-- The right component of `RCSeq` -/\nnoncomputable def RCseqRight (A : RSMatrix N) (n : ℕ) : RVec N := (RCseq A n).2\n/-- The intermediate results of applying `RCSeq` to `A` with column sums all one -/\nnoncomputable def colOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A n)) * A * (diagonal (RCseqRight A n))\nprivate lemma RCseq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n (∀ i, 0 < (RCseq A n).1 i) ∧ (∀ j, 0 < (RCseq A n).2 j) := by sorry\nlemma colSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n 1 ᵥ* colOneSeq A n = 1 := by sorry\n/-- The intermediate results of applying `RCSeq` to `A` with row sums all one -/\nnoncomputable def rowOneSeq (A : RSMatrix N) (n : ℕ) : RSMatrix N :=\n (diagonal (RCseqLeft A (n + 1))) * A * (diagonal (RCseqRight A n))\nlemma rowSum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n rowOneSeq A n *ᵥ 1 = 1 := by sorry\n/-- The row sums of column-sum-one intermediate results -/\nnoncomputable def rowSums (A : RSMatrix N) (n : ℕ) : RVec N := colOneSeq A n *ᵥ 1\nlemma colOne_to_rowOne (A : RSMatrix N) (n : ℕ) :\n rowOneSeq A n = (diagonal (rowSums A n)⁻¹) * colOneSeq A n := by sorry\n/-- The column sums of row-sum-one intermediate results -/\nnoncomputable def colSums (A : RSMatrix N) (n : ℕ) : RVec N := 1 ᵥ* rowOneSeq A n\nlemma rowOne_to_colOne (A : RSMatrix N) (n : ℕ) :\n colOneSeq A (n + 1) = rowOneSeq A n * (diagonal (colSums A n)⁻¹) := by sorry\nlemma nonEmptyFin (hN : 0 < N) : Finset.Nonempty (Finset.univ (α := Fin N)) := by sorry\nprivate lemma sum_rowSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ i : Fin N, rowSums A n i = ↑N := by sorry\nprivate lemma sum_colSums_eq (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n ∑ j : Fin N, colSums A n j = ↑N := by sorry\nprivate lemma inf'_le_one_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n Finset.inf' Finset.univ (nonEmptyFin hN) f ≤ 1 := by sorry\nprivate lemma one_le_sup'_of_sum_eq\n (f : Fin N → ℝ) (hN : 0 < N) (hsum : ∑ i, f i = ↑N) :\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) f := by sorry\nlemma rowSums_colSums_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) ∧\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤ 1 ∧\n 1 ≤ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nprivate lemma colOneSeq_entry (A : RSMatrix N) (n : ℕ) (i j : Fin N) :\n colOneSeq A n i j = (RCseqLeft A n) i * A i j * (RCseqRight A n) j := by sorry\nprivate lemma colOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < colOneSeq A n i j := by sorry\nprivate lemma colSums_convex (A : RSMatrix N) (n : ℕ) (j : Fin N) :\n colSums A n j = ∑ i, colOneSeq A n i j * (rowSums A n i)⁻¹ := by sorry\nprivate lemma rowSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i : Fin N) : 0 < rowSums A n i := by sorry\nprivate lemma colSums_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (j : Fin N) : 0 < colSums A n j := by sorry\nprivate lemma rowOneSeq_pos (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) (n : ℕ)\n (i j : Fin N) : 0 < rowOneSeq A n i j := by sorry\nprivate lemma rowSums_convex (A : RSMatrix N)\n (n : ℕ) (i : Fin N) :\n rowSums A (n + 1) i = ∑ j, rowOneSeq A n i j * (colSums A n j)⁻¹ := by sorry\nprivate lemma colOneSeq_col_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (j : Fin N) : ∑ i, colOneSeq A n i j = 1 := by sorry\nprivate lemma rowOneSeq_row_sum_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) (i : Fin N) : ∑ j, rowOneSeq A n i j = 1 := by sorry\nprivate lemma inf'_rowSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) := by sorry\nprivate lemma sup'_rowSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n) := by sorry\nprivate lemma inf'_colSums_le_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n) ≤\n Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) := by sorry\nprivate lemma sup'_colSums_ge_succ (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j)\n (n : ℕ) :\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A (n + 1)) ≤\n Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n) := by sorry\nlemma rowSums_colSums_min_max_monotone_antitone (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (rowSums A n)) ∧\n (Monotone fun n ↦ Finset.inf' Finset.univ (nonEmptyFin hN) (colSums A n)) ∧\n (Antitone fun n ↦ Finset.sup' Finset.univ (nonEmptyFin hN) (colSums A n)) := sorry\nset_option maxHeartbeats 800000 in\nlemma entry_lower_bound (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n ∃ μ > 0, ∀ n i j, μ ≤ colOneSeq A n i j := by sorry\nset_option maxHeartbeats 1600000 in\nlemma colSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (colSums A) atTop (𝓝 1) := by sorry\nprivate lemma tendsto_of_tendsto_succ {α : Type*} [TopologicalSpace α] {f : ℕ → α} {L : α}\n (h : Tendsto (fun n => f (n + 1)) atTop (𝓝 L)) : Tendsto f atTop (𝓝 L) := by sorry\nlemma rowSums_tendsTo_one (hN : 0 < N) (A : RSMatrix N) (hA : ∀ i j, 0 < A i j) :\n Tendsto (rowSums A) atTop (𝓝 1) := by sorry\nlemma rescale (hN : 0 < N) (x y : ℕ → RVec N)\n (hx : ∀ n, ∀ i, 0 < x n i) (hy : ∀ n, ∀ i, 0 < y n i)\n (B : RSMatrix N) (hB : ∀ i, ∀ j, 0 < B i j)\n (h : ∀ i, ∀ j, Tendsto (fun n ↦ x n i * y n j) atTop (𝓝 (B i j))) :\n ∃ x' y' : ℕ → RVec N, ∃ xlim ylim : RVec N, (∀ n, ∀ i, 0 < x' n i ∧ 0 < y' n i) ∧\n (∀ n, ∀ i, ∀ j, x' n i * y' n j = x n i * y n j) ∧\n Tendsto x' atTop (𝓝 xlim) ∧ Tendsto y' atTop (𝓝 ylim)\n := by sorry"} -{"project_name": "StarOfDavid", "name": "starofdavid_n_zero", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry"} -{"project_name": "StarOfDavid", "name": "starofdavid_k_zero", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry"} -{"project_name": "StarOfDavid", "name": "product_identity_of_le", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry"} -{"project_name": "StarOfDavid", "name": "product_identity_of_gt", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry"} -{"project_name": "StarOfDavid", "name": "product_identity", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_a", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_b", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_c", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_a_plus_b", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_d_plus_e", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_f_iff_d", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_e_iff_d", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_d_of_a_eq_zero", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_d_of_d_eq_zero", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry"} -{"project_name": "StarOfDavid", "name": "choose_pos_implies_ge", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry"} -{"project_name": "StarOfDavid", "name": "absorption_relation", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_cubed_dvd_product", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_d", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_center", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry"} -{"project_name": "StarOfDavid", "name": "absorption_column", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_def_dvd_a", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_e", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_f", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_abc_dvd_gcd_def", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_def_dvd_d", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n/-- h divides d (left of inner gcd). -/\n\nlemma gcd_def_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m (j + 1) := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_def_dvd_e", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n/-- h divides d (left of inner gcd). -/\n\nlemma gcd_def_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m (j + 1) := sorry\n/-- h divides e (right of inner gcd). -/\n\nlemma gcd_def_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) j := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_def_dvd_f", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n/-- h divides d (left of inner gcd). -/\n\nlemma gcd_def_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m (j + 1) := sorry\n/-- h divides e (right of inner gcd). -/\n\nlemma gcd_def_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) j := sorry\n/-- h divides f (outer). -/\n\nlemma gcd_def_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 2) := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_def_dvd_a_plus_b", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n/-- h divides d (left of inner gcd). -/\n\nlemma gcd_def_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m (j + 1) := sorry\n/-- h divides e (right of inner gcd). -/\n\nlemma gcd_def_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) j := sorry\n/-- h divides f (outer). -/\n\nlemma gcd_def_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- h divides a + b (since f = a + b + d and h | f, h | d). -/\n\nlemma gcd_def_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ (choose m j + choose (m + 1) (j + 2)) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_def_dvd_b", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n/-- h divides d (left of inner gcd). -/\n\nlemma gcd_def_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m (j + 1) := sorry\n/-- h divides e (right of inner gcd). -/\n\nlemma gcd_def_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) j := sorry\n/-- h divides f (outer). -/\n\nlemma gcd_def_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- h divides a + b (since f = a + b + d and h | f, h | d). -/\n\nlemma gcd_def_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ (choose m j + choose (m + 1) (j + 2)) := by sorry\n/-- h divides b (combining gcd_def_dvd_a and the a+b divisibility). -/\n\nlemma gcd_def_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) (j + 2) := sorry"} -{"project_name": "StarOfDavid", "name": "gcd_def_dvd_c", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n/-- h divides d (left of inner gcd). -/\n\nlemma gcd_def_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m (j + 1) := sorry\n/-- h divides e (right of inner gcd). -/\n\nlemma gcd_def_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) j := sorry\n/-- h divides f (outer). -/\n\nlemma gcd_def_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- h divides a + b (since f = a + b + d and h | f, h | d). -/\n\nlemma gcd_def_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ (choose m j + choose (m + 1) (j + 2)) := by sorry\n/-- h divides b (combining gcd_def_dvd_a and the a+b divisibility). -/\n\nlemma gcd_def_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- h divides c (since c = e + a + d). -/\n\nlemma gcd_def_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 1) := by sorry"} -{"project_name": "StarOfDavid", "name": "gcd_def_dvd_gcd_abc", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n/-- h divides d (left of inner gcd). -/\n\nlemma gcd_def_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m (j + 1) := sorry\n/-- h divides e (right of inner gcd). -/\n\nlemma gcd_def_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) j := sorry\n/-- h divides f (outer). -/\n\nlemma gcd_def_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- h divides a + b (since f = a + b + d and h | f, h | d). -/\n\nlemma gcd_def_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ (choose m j + choose (m + 1) (j + 2)) := by sorry\n/-- h divides b (combining gcd_def_dvd_a and the a+b divisibility). -/\n\nlemma gcd_def_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- h divides c (since c = e + a + d). -/\n\nlemma gcd_def_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 1) := by sorry\n/-- h divides g = gcd(a, b, c). -/\n\nlemma gcd_def_dvd_gcd_abc (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1)) := sorry"} -{"project_name": "StarOfDavid", "name": "starofdavid_main", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n/-- h divides d (left of inner gcd). -/\n\nlemma gcd_def_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m (j + 1) := sorry\n/-- h divides e (right of inner gcd). -/\n\nlemma gcd_def_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) j := sorry\n/-- h divides f (outer). -/\n\nlemma gcd_def_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- h divides a + b (since f = a + b + d and h | f, h | d). -/\n\nlemma gcd_def_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ (choose m j + choose (m + 1) (j + 2)) := by sorry\n/-- h divides b (combining gcd_def_dvd_a and the a+b divisibility). -/\n\nlemma gcd_def_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- h divides c (since c = e + a + d). -/\n\nlemma gcd_def_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 1) := by sorry\n/-- h divides g = gcd(a, b, c). -/\n\nlemma gcd_def_dvd_gcd_abc (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1)) := sorry\n/-- Main case: gcd(a,b,c) = gcd(d,e,f) for all m, j. -/\n\nlemma starofdavid_main (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n = Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry"} -{"project_name": "StarOfDavid", "name": "starofdavid", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n/-- Edge case n=0: for all k, the Star of David identity holds when n=0. -/\n\nlemma starofdavid_n_zero (k : ℕ) :\n (((0 - 1).choose (k - 1)).gcd ((0 : ℕ).choose (k + 1))).gcd ((1 : ℕ).choose k)\n = (((0 - 1).choose k).gcd ((0 : ℕ).choose (k - 1))).gcd ((1 : ℕ).choose (k + 1)) := by sorry\n/-- Edge case k=0: for all n, the Star of David identity holds when k=0. -/\n\nlemma starofdavid_k_zero (n : ℕ) :\n (((n - 1).choose (0 - 1)).gcd (n.choose 1)).gcd ((n + 1).choose 0)\n = (((n - 1).choose 0).gcd (n.choose (0 - 1))).gcd ((n + 1).choose 1) := by sorry\n/-- When j + 2 <= m + 1 (i.e., j + 1 <= m), both products equal the same factorial expression. -/\n\nlemma product_identity_of_le (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- When j + 1 > m, at least one factor on each side is zero so both products are 0. -/\n\nlemma product_identity_of_gt (m j : ℕ) (h : m < j + 1) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- The product identity: a * b * c = d * e * f. -/\n\nlemma product_identity (m j : ℕ) :\n choose m j * choose (m + 1) (j + 2) * choose (m + 2) (j + 1) =\n choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- g divides a (left component of inner gcd). -/\n\nlemma gcd_abc_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m j := sorry\n/-- g divides b (right component of inner gcd). -/\n\nlemma gcd_abc_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- g divides c (outer component). -/\n\nlemma gcd_abc_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 1) := sorry\n/-- g divides a + b. -/\n\nlemma gcd_abc_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m j + choose (m + 1) (j + 2)) := sorry\n/-- g divides d + e (since c = a + d + e via Pascal and g | c, g | a). -/\n\nlemma gcd_abc_dvd_d_plus_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ (choose m (j + 1) + choose (m + 1) j) := by sorry\n/-- g divides f iff g divides d (since f = a + d + b and g | a, g | b). -/\n\nlemma gcd_abc_dvd_f_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2)) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- g divides e iff g divides d (since g | d+e). -/\n\nlemma gcd_abc_dvd_e_iff_d (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j) ↔\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1)) := by sorry\n/-- Zero case: if a = 0, then g | d because d = 0 too (j > m implies j+1 > m). -/\n\nlemma gcd_abc_dvd_d_of_a_eq_zero (m j : ℕ) (ha : choose m j = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n\nlemma gcd_abc_dvd_d_of_d_eq_zero (m j : ℕ) (hd : choose m (j + 1) = 0) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- Positivity setup: if a > 0 and d > 0, then m >= j + 1. -/\n\nlemma choose_pos_implies_ge (m j : ℕ)\n (hd : 0 < choose m (j + 1)) :\n j + 1 ≤ m := by sorry\n/-- Key absorption relation: (m - j) * C(m, j) = (j + 1) * C(m, j+1). -/\n\nlemma absorption_relation (m j : ℕ) :\n (m - j) * choose m j = (j + 1) * choose m (j + 1) := by sorry\n/-- Helper: abc = def implies that if g = gcd(a,b,c) and g^3 | abc, then g^3 | def.\n The product identity plus gcd divisibility gives us g^3 | def. -/\n\nlemma gcd_cubed_dvd_product (m j : ℕ) :\n (Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))) ^ 3\n ∣ choose m (j + 1) * choose (m + 1) j * choose (m + 2) (j + 2) := by sorry\n/-- Key lemma: gcd(a, b, c) divides d = C(m, j+1). -/\n\nlemma gcd_abc_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose m (j + 1) := by sorry\n/-- g divides M = a + d = C(m+1, j+1) (via a + d = M and Pascal). -/\n\nlemma gcd_abc_dvd_center (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) (j + 1) := by sorry\n/-- Auxiliary absorption: (m+1-j) * C(m+1, j) = (m+1) * C(m, j). -/\n\nlemma absorption_column (m j : ℕ) :\n (m + 1 - j) * choose (m + 1) j = (m + 1) * choose m j := by sorry\n/-- Symmetric: gcd(d, e, f) divides a = C(m, j). -/\n\nlemma gcd_def_dvd_a (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m j := by sorry\n/-- g divides e (combining gcd_abc_dvd_d and gcd_abc_dvd_e_iff_d). -/\n\nlemma gcd_abc_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 1) j := sorry\n/-- g divides f (combining gcd_abc_dvd_d and gcd_abc_dvd_f_iff_d). -/\n\nlemma gcd_abc_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- g divides h = gcd(d, e, f). -/\n\nlemma gcd_abc_dvd_gcd_def (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n ∣ Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n/-- h divides d (left of inner gcd). -/\n\nlemma gcd_def_dvd_d (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose m (j + 1) := sorry\n/-- h divides e (right of inner gcd). -/\n\nlemma gcd_def_dvd_e (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) j := sorry\n/-- h divides f (outer). -/\n\nlemma gcd_def_dvd_f (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 2) := sorry\n/-- h divides a + b (since f = a + b + d and h | f, h | d). -/\n\nlemma gcd_def_dvd_a_plus_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ (choose m j + choose (m + 1) (j + 2)) := by sorry\n/-- h divides b (combining gcd_def_dvd_a and the a+b divisibility). -/\n\nlemma gcd_def_dvd_b (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 1) (j + 2) := sorry\n/-- h divides c (since c = e + a + d). -/\n\nlemma gcd_def_dvd_c (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ choose (m + 2) (j + 1) := by sorry\n/-- h divides g = gcd(a, b, c). -/\n\nlemma gcd_def_dvd_gcd_abc (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2))\n ∣ Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1)) := sorry\n/-- Main case: gcd(a,b,c) = gcd(d,e,f) for all m, j. -/\n\nlemma starofdavid_main (m j : ℕ) :\n Nat.gcd (Nat.gcd (choose m j) (choose (m + 1) (j + 2)))\n (choose (m + 2) (j + 1))\n = Nat.gcd (Nat.gcd (choose m (j + 1)) (choose (m + 1) j))\n (choose (m + 2) (j + 2)) := sorry\n\ntheorem starofdavid (n k : ℕ) :\n (((n - 1).choose (k - 1)).gcd (n.choose (k + 1))).gcd ((n + 1).choose k)\n = (((n - 1).choose k).gcd (n.choose (k - 1))).gcd ((n + 1).choose (k + 1)) := by sorry"} -{"project_name": "SzemerediTheorem", "name": "szemeredi", "type": "theorem", "code": "import Mathlib\n\nopen Nat Filter Set\n/-- Upper density of a set of natural numbers -/\nnoncomputable def upperDensity (A : Set ℕ) : ℝ :=\n limsup (fun (n : ℕ) ↦ (A ∩ Icc 0 n).ncard / (↑n : ℝ)) atTop\n/-- Szemerédi's theorem\nhttps://en.wikipedia.org/wiki/Szemer%C3%A9di%27s_theorem -/\n\ntheorem szemeredi {A : Set ℕ} (h : 0 < upperDensity A) (n : ℕ) :\n ∃ a b : ℕ, b > 0 ∧ {a + k * b | k < n} ⊆ A := sorry"} -{"project_name": "SzemerediTrotterTheorem", "name": "szemeredi_trotter", "type": "theorem", "code": "import Mathlib\n\nopen scoped EuclideanGeometry\n/-- A line in the Euclidean plane: a nonempty one-dimensional affine subspace of R^2. -/\n\nstructure Line2 where\n /-- It's underlying affine subset-/\n toAffineSubspace : AffineSubspace ℝ (EuclideanSpace ℝ (Fin 2))\n /-- A line is nonempty -/\n nonempty : (toAffineSubspace : Set (EuclideanSpace ℝ (Fin 2))).Nonempty\n /-- A line is 1 dimensional -/\n dim_one : Module.finrank ℝ toAffineSubspace.direction = 1\n\ninstance : Membership (EuclideanSpace ℝ (Fin 2)) Line2 where\n mem (l : Line2) (p : EuclideanSpace ℝ (Fin 2)) := p ∈ l.toAffineSubspace\n\nopen Classical in\n/-- The number of incidences between a finite set of points and a finite set of lines\nin the Euclidean plane. -/\nnoncomputable def incidenceCount\n (P : Finset (EuclideanSpace ℝ (Fin 2)))\n (L : Finset Line2) : ℕ :=\n ((P ×ˢ L).filter fun pl => pl.1 ∈ pl.2.toAffineSubspace).card\n/-- **Szemeredi-Trotter theorem.** There exists an absolute constant C > 0 such that for any\nfinite set of points P and any finite set of lines L in the Euclidean plane R^2,\nthe number of incidences satisfies\n I(P, L) <= C * (|P|^{2/3} * |L|^{2/3} + |P| + |L|). -/\n\ntheorem szemeredi_trotter :\n ∃ C : ℝ, 0 < C ∧ ∀ (P : Finset (EuclideanSpace ℝ (Fin 2)))\n (L : Finset Line2),\n (incidenceCount P L : ℝ) ≤\n C * ((P.card : ℝ) ^ ((2 : ℝ) / 3) *\n (L.card : ℝ) ^ ((2 : ℝ) / 3) +\n (P.card : ℝ) + (L.card : ℝ)) := by sorry"} -{"project_name": "TotientGrowthRate", "name": "totient_lower_bound", "type": "theorem", "code": "import Mathlib\n\nopen ENNReal NNReal\n\nopen Filter Set Topology Nat Real\n\ntheorem totient_lower_bound {n : ℕ} (hn : 2 < n) :\n ↑n / (rexp eulerMascheroniConstant * Real.log (Real.log ↑n) + 3 / Real.log (Real.log ↑n))\n < (↑(φ n) : ℝ) := by sorry"} -{"project_name": "TverbergTheorem", "name": "tverberg", "type": "theorem", "code": "import Mathlib\n/--\nTverberg's theorem states that given a set of points of size (d + 1)(r - 1) + 1 in ℝ^d,\nthere exists a point and a partition of the set into r parts\nsuch that the point is in the convex hull of each part.\n-/\n\ntheorem tverberg (d r : ℕ) (d_pos : 0 < d) (r_pos : 0 < r)\n (S : Finset (EuclideanSpace ℝ (Fin d))) (hS : S.card = (d + 1) * (r - 1) + 1) :\n ∃ (x : EuclideanSpace ℝ (Fin d)) (partition : Finpartition S),\n partition.parts.card = r ∧\n ∀ part ∈ partition.parts, x ∈ convexHull ℝ part := by sorry"} -{"project_name": "TwoFactorTheorem", "name": "two_factor_theorem", "type": "theorem", "code": "import Mathlib\n/--\nA locally finite simple graph is regular of degree `d` if every vertex has degree `d`.\nThis modified definition is used to avoid the need for the input graph to be known to be\nlocally finite.\n-/\n\ndef SimpleGraph.IsRegularOfDegree'.{u} {V : Type u} (G : SimpleGraph V)\n (d : ℕ) : Prop :=\n ∃ _ : G.LocallyFinite, G.IsRegularOfDegree d\n\ntheorem two_factor_theorem {V : Type} (G : SimpleGraph V) {k : ℕ}\n (h : G.IsRegularOfDegree' (2 * k)) :\n ∃ (factors : Fin k → SimpleGraph V),\n (∀ i, factors i ≤ G) ∧\n (∀ i, (factors i).IsRegularOfDegree' 2) ∧\n (∀ i j, i ≠ j → Disjoint (factors i).edgeSet (factors j).edgeSet) ∧\n (⋃ i, (factors i).edgeSet) = G.edgeSet := sorry"} -{"project_name": "TwoNinety", "name": "two_ninety_theorem", "type": "theorem", "code": "import Mathlib\nnoncomputable section\n/-- The list of 29 critical numbers for the 290 theorem. -/\n\ndef critical_290_numbers : Finset ℕ :=\n {1, 2, 3, 5, 6, 7, 10, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 31,\n 34, 35, 37, 42, 58, 93, 110, 145, 203, 290}\n/-- The **290 Theorem** (Bhargava-Hanke): An positive-definite integral quadratic form\nthat represents all 29 critical numbers (including 290) represents all positive integers.\nWe can alternately view such forms as\n* symmetric positive definite matrices with interger diagonal and half-integer off-diagonal entries, or\n* not-necessarily-symmetric positive definite matrices with integer entries\n-/\n\ntheorem two_ninety_theorem {n : ℕ} (M : Matrix (Fin n) (Fin n) ℤ)\n (hpos : M.PosDef)\n (hrep : ∀ m ∈ critical_290_numbers, M.represents m) :\n M.Universal := by sorry"} -{"project_name": "ValuationRingInterSubfield", "name": "Subfield.mem_of_mul_eq", "type": "lemma", "code": "import Mathlib\n\nopen Subring Subfield\n\nvariable {L : Type*} [Field L]\n/-- If `a * x = b` with `a, b ∈ K` and `a ≠ 0`, then `x ∈ K`. -/\n\nlemma Subfield.mem_of_mul_eq (K : Subfield L) {a b x : L}\n (ha : a ∈ K) (hb : b ∈ K) (ha0 : a ≠ 0) (h : a * x = b) :\n x ∈ (K : Set L) := by sorry"} -{"project_name": "ValuationRingInterSubfield", "name": "dvd_inf_of_dvd_in_subring", "type": "lemma", "code": "import Mathlib\n\nopen Subring Subfield\n\nvariable {L : Type*} [Field L]\n/-- If `a * x = b` with `a, b ∈ K` and `a ≠ 0`, then `x ∈ K`. -/\n\nlemma Subfield.mem_of_mul_eq (K : Subfield L) {a b x : L}\n (ha : a ∈ K) (hb : b ∈ K) (ha0 : a ≠ 0) (h : a * x = b) :\n x ∈ (K : Set L) := by sorry\n/-- If `a ∣ b` in `B` and both lie in `K`, then `a ∣ b` in `K ⊓ B`. The witness\n`c ∈ B` also lies in `K` since `c = a⁻¹ * b` when `a ≠ 0`. -/\n\nlemma dvd_inf_of_dvd_in_subring (K : Subfield L) (B : Subring L)\n (a b : ↥(K.toSubring ⊓ B))\n (h : (Subring.inclusion inf_le_right a) ∣ (Subring.inclusion inf_le_right b)) :\n a ∣ b := by sorry"} -{"project_name": "ValuationRingInterSubfield", "name": "ValuationRing.inter_subfield", "type": "theorem", "code": "import Mathlib\n\nopen Subring Subfield\n\nvariable {L : Type*} [Field L]\n/-- **Stacks 052L** (Lemma 10.50.7). If `B` is a valuation subring of a field `L`\nand `K` is a subfield, then `K ∩ B` is a valuation ring. -/\n\ntheorem ValuationRing.inter_subfield\n (B : Subring L) [ValuationRing B] (K : Subfield L) :\n ValuationRing ↥(K.toSubring ⊓ B) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.ValuationRingInterSubfield.BackgroundLemmas\nopen Subring Subfield\nvariable {L : Type*} [Field L]\n/-- If `a * x = b` with `a, b ∈ K` and `a ≠ 0`, then `x ∈ K`. -/\nlemma Subfield.mem_of_mul_eq (K : Subfield L) {a b x : L}\n (ha : a ∈ K) (hb : b ∈ K) (ha0 : a ≠ 0) (h : a * x = b) :\n x ∈ (K : Set L) := by sorry\n/-- If `a ∣ b` in `B` and both lie in `K`, then `a ∣ b` in `K ⊓ B`. The witness\n`c ∈ B` also lies in `K` since `c = a⁻¹ * b` when `a ≠ 0`. -/\nlemma dvd_inf_of_dvd_in_subring (K : Subfield L) (B : Subring L)\n (a b : ↥(K.toSubring ⊓ B))\n (h : (Subring.inclusion inf_le_right a) ∣ (Subring.inclusion inf_le_right b)) :\n a ∣ b := by sorry"} -{"project_name": "Vantieghem", "name": "sq_lt_pow_of_ge_five", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry"} -{"project_name": "Vantieghem", "name": "prod_ge_n", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry"} -{"project_name": "Vantieghem", "name": "gcd_mersenne_prime", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry"} -{"project_name": "Vantieghem", "name": "sign_correction_int", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry"} -{"project_name": "Vantieghem", "name": "neg_one_pow_even_sub_one", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry"} -{"project_name": "Vantieghem", "name": "two_pow_eq_one_zmod", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry"} -{"project_name": "Vantieghem", "name": "powers_of_two_distinct_zmod", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry"} -{"project_name": "Vantieghem", "name": "root_of_xn_sub_one", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry"} -{"project_name": "Vantieghem", "name": "divByMonic_root_of_root'", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry"} -{"project_name": "Vantieghem", "name": "poly_eq_zero_of_eval_zero_units'", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry"} -{"project_name": "Vantieghem", "name": "pow_two_diff_isUnit", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry"} -{"project_name": "Vantieghem", "name": "key_int_congruence", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry"} -{"project_name": "Vantieghem", "name": "forward_int_dvd", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry"} -{"project_name": "Vantieghem", "name": "forward_direction", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry"} -{"project_name": "Vantieghem", "name": "factor_dvd_prod", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry"} -{"project_name": "Vantieghem", "name": "divisor_divides_n", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry"} -{"project_name": "Vantieghem", "name": "not_dvd_of_small_composite", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry"} -{"project_name": "Vantieghem", "name": "backward_small", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry"} -{"project_name": "Vantieghem", "name": "minFac_le_sqrt", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- For composite n, minFac n <= n / minFac n, i.e., (minFac n)^2 <= n.\n Uses Nat.minFac_le_div. -/\n\nlemma minFac_le_sqrt {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n.minFac ≤ n / n.minFac := sorry"} -{"project_name": "Vantieghem", "name": "div_minFac_ge_six", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- For composite n, minFac n <= n / minFac n, i.e., (minFac n)^2 <= n.\n Uses Nat.minFac_le_div. -/\n\nlemma minFac_le_sqrt {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n.minFac ≤ n / n.minFac := sorry\n/-- n / minFac n >= 6 when n >= 32 and n is composite. -/\n\nlemma div_minFac_ge_six {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n 6 ≤ n / n.minFac := by sorry"} -{"project_name": "Vantieghem", "name": "div_minFac_dvd", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- For composite n, minFac n <= n / minFac n, i.e., (minFac n)^2 <= n.\n Uses Nat.minFac_le_div. -/\n\nlemma minFac_le_sqrt {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n.minFac ≤ n / n.minFac := sorry\n/-- n / minFac n >= 6 when n >= 32 and n is composite. -/\n\nlemma div_minFac_ge_six {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n 6 ≤ n / n.minFac := by sorry\n/-- n / minFac n divides n. -/\n\nlemma div_minFac_dvd {n : ℕ} : (n / n.minFac) ∣ n := sorry"} -{"project_name": "Vantieghem", "name": "div_minFac_le_pred", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- For composite n, minFac n <= n / minFac n, i.e., (minFac n)^2 <= n.\n Uses Nat.minFac_le_div. -/\n\nlemma minFac_le_sqrt {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n.minFac ≤ n / n.minFac := sorry\n/-- n / minFac n >= 6 when n >= 32 and n is composite. -/\n\nlemma div_minFac_ge_six {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n 6 ≤ n / n.minFac := by sorry\n/-- n / minFac n divides n. -/\n\nlemma div_minFac_dvd {n : ℕ} : (n / n.minFac) ∣ n := sorry\n/-- n / minFac n <= n - 1 when minFac n >= 2. -/\n\nlemma div_minFac_le_pred {n : ℕ} (hn : 2 ≤ n) : n / n.minFac ≤ n - 1 := by sorry"} -{"project_name": "Vantieghem", "name": "n_le_sq_div_minFac", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- For composite n, minFac n <= n / minFac n, i.e., (minFac n)^2 <= n.\n Uses Nat.minFac_le_div. -/\n\nlemma minFac_le_sqrt {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n.minFac ≤ n / n.minFac := sorry\n/-- n / minFac n >= 6 when n >= 32 and n is composite. -/\n\nlemma div_minFac_ge_six {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n 6 ≤ n / n.minFac := by sorry\n/-- n / minFac n divides n. -/\n\nlemma div_minFac_dvd {n : ℕ} : (n / n.minFac) ∣ n := sorry\n/-- n / minFac n <= n - 1 when minFac n >= 2. -/\n\nlemma div_minFac_le_pred {n : ℕ} (hn : 2 ≤ n) : n / n.minFac ≤ n - 1 := by sorry\n/-- n <= (n/minFac n)^2 when n is composite (since minFac n <= n/minFac n). -/\n\nlemma n_le_sq_div_minFac {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n ≤ (n / n.minFac) ^ 2 := by sorry"} -{"project_name": "Vantieghem", "name": "backward_large_aux", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- For composite n, minFac n <= n / minFac n, i.e., (minFac n)^2 <= n.\n Uses Nat.minFac_le_div. -/\n\nlemma minFac_le_sqrt {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n.minFac ≤ n / n.minFac := sorry\n/-- n / minFac n >= 6 when n >= 32 and n is composite. -/\n\nlemma div_minFac_ge_six {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n 6 ≤ n / n.minFac := by sorry\n/-- n / minFac n divides n. -/\n\nlemma div_minFac_dvd {n : ℕ} : (n / n.minFac) ∣ n := sorry\n/-- n / minFac n <= n - 1 when minFac n >= 2. -/\n\nlemma div_minFac_le_pred {n : ℕ} (hn : 2 ≤ n) : n / n.minFac ≤ n - 1 := by sorry\n/-- n <= (n/minFac n)^2 when n is composite (since minFac n <= n/minFac n). -/\n\nlemma n_le_sq_div_minFac {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n ≤ (n / n.minFac) ^ 2 := by sorry\n/-- For composite n >= 32, there exists d | n with 2 <= d <= n-1 and n < 2^d - 1.\n Take d = n / minFac(n). Then d >= 6, d | n, d <= n-1,\n and n <= d^2 < 2^d (by sq_lt_pow_of_ge_five), so n < 2^d, giving n < 2^d - 1. -/\n\nlemma backward_large_aux {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ n < 2 ^ d - 1 := by sorry"} -{"project_name": "Vantieghem", "name": "backward_large", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- For composite n, minFac n <= n / minFac n, i.e., (minFac n)^2 <= n.\n Uses Nat.minFac_le_div. -/\n\nlemma minFac_le_sqrt {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n.minFac ≤ n / n.minFac := sorry\n/-- n / minFac n >= 6 when n >= 32 and n is composite. -/\n\nlemma div_minFac_ge_six {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n 6 ≤ n / n.minFac := by sorry\n/-- n / minFac n divides n. -/\n\nlemma div_minFac_dvd {n : ℕ} : (n / n.minFac) ∣ n := sorry\n/-- n / minFac n <= n - 1 when minFac n >= 2. -/\n\nlemma div_minFac_le_pred {n : ℕ} (hn : 2 ≤ n) : n / n.minFac ≤ n - 1 := by sorry\n/-- n <= (n/minFac n)^2 when n is composite (since minFac n <= n/minFac n). -/\n\nlemma n_le_sq_div_minFac {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n ≤ (n / n.minFac) ^ 2 := by sorry\n/-- For composite n >= 32, there exists d | n with 2 <= d <= n-1 and n < 2^d - 1.\n Take d = n / minFac(n). Then d >= 6, d | n, d <= n-1,\n and n <= d^2 < 2^d (by sq_lt_pow_of_ge_five), so n < 2^d, giving n < 2^d - 1. -/\n\nlemma backward_large_aux {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ n < 2 ^ d - 1 := by sorry\n/-- For composite n >= 32, the congruence fails:\n backward_large_aux gives d with (2^d-1) > n, so (2^d-1) cannot divide n,\n but divisor_divides_n says it must. -/\n\nlemma backward_large {n : ℕ} (hn3 : 3 ≤ n) (hn : 32 ≤ n) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry"} -{"project_name": "Vantieghem", "name": "backward_direction", "type": "lemma", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- For composite n, minFac n <= n / minFac n, i.e., (minFac n)^2 <= n.\n Uses Nat.minFac_le_div. -/\n\nlemma minFac_le_sqrt {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n.minFac ≤ n / n.minFac := sorry\n/-- n / minFac n >= 6 when n >= 32 and n is composite. -/\n\nlemma div_minFac_ge_six {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n 6 ≤ n / n.minFac := by sorry\n/-- n / minFac n divides n. -/\n\nlemma div_minFac_dvd {n : ℕ} : (n / n.minFac) ∣ n := sorry\n/-- n / minFac n <= n - 1 when minFac n >= 2. -/\n\nlemma div_minFac_le_pred {n : ℕ} (hn : 2 ≤ n) : n / n.minFac ≤ n - 1 := by sorry\n/-- n <= (n/minFac n)^2 when n is composite (since minFac n <= n/minFac n). -/\n\nlemma n_le_sq_div_minFac {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n ≤ (n / n.minFac) ^ 2 := by sorry\n/-- For composite n >= 32, there exists d | n with 2 <= d <= n-1 and n < 2^d - 1.\n Take d = n / minFac(n). Then d >= 6, d | n, d <= n-1,\n and n <= d^2 < 2^d (by sq_lt_pow_of_ge_five), so n < 2^d, giving n < 2^d - 1. -/\n\nlemma backward_large_aux {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ n < 2 ^ d - 1 := by sorry\n/-- For composite n >= 32, the congruence fails:\n backward_large_aux gives d with (2^d-1) > n, so (2^d-1) cannot divide n,\n but divisor_divides_n says it must. -/\n\nlemma backward_large {n : ℕ} (hn3 : 3 ≤ n) (hn : 32 ≤ n) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- Backward direction: if the congruence holds and n >= 3, then n is prime.\n Split into small (n <= 31) and large (n >= 32) cases. -/\n\nlemma backward_direction {n : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n n.Prime := by sorry"} -{"project_name": "Vantieghem", "name": "vantieghem", "type": "theorem", "code": "import Mathlib\n\nuniverse u\n\nopen Nat Finset BigOperators\n\nnamespace Vantieghem\n/-- For d >= 5, d^2 < 2^d. Base case d=5: 25 < 32. Inductive step uses (d+1)^2 <= 2*d^2. -/\n\nlemma sq_lt_pow_of_ge_five : ∀ d : ℕ, 5 ≤ d → d ^ 2 < 2 ^ d := by sorry\n/-- prod_{k=1}^{n-1} (2^k - 1) >= n for n >= 3. (The first factor alone is 2^1-1 = 1,\n the second is 3, and additional factors are >= 7.) -/\n\nlemma prod_ge_n {n : ℕ} (hn : 3 ≤ n) :\n n ≤ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := by sorry\n\nsection Forward\n/-- GCD of Mersenne-like numbers: if n is prime and 1 <= r < n, then gcd(2^r - 1, 2^n - 1) = 1.\n Uses `Nat.pow_sub_one_gcd_pow_sub_one` and `Nat.coprime_of_lt_prime`. -/\n\nlemma gcd_mersenne_prime {n r : ℕ} (hp : n.Prime) (hr1 : 1 ≤ r) (hr2 : r < n) :\n Nat.gcd (2 ^ r - 1) (2 ^ n - 1) = 1 := by sorry\n/-- Sign correction in ℤ: each factor satisfies 2^k - 1 = -(1 - 2^k),\n so the product picks up (-1)^{n-1}. -/\n\nlemma sign_correction_int {n : ℕ} :\n ∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1) =\n (-1) ^ (n - 1) * ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) := by sorry\n/-- When n >= 3 is prime (hence odd), (-1)^(n-1) = 1.\n Uses Nat.Prime.even_sub_one. -/\n\nlemma neg_one_pow_even_sub_one {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (-1 : ℤ) ^ (n - 1) = 1 := sorry\n/-- In ZMod (2^n-1), we have 2^n = 1 (i.e., 2^n ≡ 1 mod M). -/\n\nlemma two_pow_eq_one_zmod {n : ℕ} (hn : 1 ≤ n) :\n (2 : ZMod (2 ^ n - 1)) ^ n = 1 := by sorry\n/-- The elements 2^0, 2^1, ..., 2^{n-1} are pairwise distinct in ZMod (2^n-1) when n is prime.\n This uses gcd_mersenne_prime: if 2^a = 2^b in ZMod M with 0 <= a < b < n,\n then M | 2^a(2^{b-a} - 1), and gcd(2^a, M) = 1 (since M is odd), so M | (2^{b-a}-1),\n but gcd(2^{b-a}-1, M) = 1 since 1 <= b-a < n, contradiction. -/\n\nlemma powers_of_two_distinct_zmod {n : ℕ} (hp : n.Prime) (a b : ℕ)\n (ha : a < n) (hb : b < n) (hab : (2 : ZMod (2 ^ n - 1)) ^ a = (2 : ZMod (2 ^ n - 1)) ^ b) :\n a = b := by sorry\n/-- The polynomial X^n - 1 evaluated at 2^k gives 0 in ZMod (2^n-1) for 0 <= k < n.\n I.e., each 2^k is a root of X^n - 1 in ZMod M. -/\n\nlemma root_of_xn_sub_one {n k : ℕ} (hn : 1 ≤ n) :\n ((2 : ZMod (2 ^ n - 1)) ^ k) ^ n = 1 := by sorry\n/-- Key congruence in ℤ: (2^n - 1) | (prod_{k=1}^{n-1} (1 - 2^k) - n).\n This is proved by working in ZMod M where the identity holds exactly,\n then lifting to ℤ divisibility.\n In ZMod M, X^n - 1 has the n distinct roots 2^0, ..., 2^{n-1},\n so X^n - 1 = prod_{k=0}^{n-1} (X - 2^k).\n Taking the formal derivative: n*X^{n-1} = sum_j prod_{k≠j} (X - 2^k).\n Evaluating at X = 1 = 2^0: only the j=0 term survives (others have factor 1-1=0 from k=0),\n giving n = prod_{k=1}^{n-1} (1 - 2^k). -/\nprivate lemma divByMonic_root_of_root' {R : Type*} [CommRing R]\n {p : Polynomial R} {a b : R} (ha : p.IsRoot a) (hb : p.IsRoot b) (hu : IsUnit (b - a)) :\n (p /ₘ (Polynomial.X - Polynomial.C a)).IsRoot b := by sorry\nprivate lemma poly_eq_zero_of_eval_zero_units' {R : Type*} [CommRing R] [DecidableEq R]\n {p : Polynomial R} {s : Finset R}\n (hroots : ∀ i ∈ s, p.IsRoot i)\n (hdeg : p.natDegree < s.card)\n (hunits : ∀ i ∈ s, ∀ j ∈ s, i ≠ j → IsUnit (i - j)) :\n p = 0 := by sorry\nprivate lemma pow_two_diff_isUnit {n : ℕ} (hp : n.Prime) {a b : ℕ}\n (ha : a < n) (hb : b < n) (hab : a ≠ b) :\n IsUnit ((2 : ZMod (2 ^ n - 1)) ^ a - (2 : ZMod (2 ^ n - 1)) ^ b) := by sorry\n\nset_option maxHeartbeats 1600000 in\n\nlemma key_int_congruence {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n ∏ k ∈ Finset.Ico 1 n, (1 - (2 : ℤ) ^ k) - ↑n := by sorry\n/-- Combining sign correction with key congruence in ℤ. -/\n\nlemma forward_int_dvd {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (↑(2 ^ n - 1) : ℤ) ∣\n (∏ k ∈ Finset.Ico 1 n, ((2 : ℤ) ^ k - 1)) - ↑n := by sorry\n/-- Forward direction: if n >= 3 is prime then\n prod_{k=1}^{n-1} (2^k - 1) ≡ n [MOD 2^n - 1].\n Proof: we have the ℤ divisibility, and both sides are natural numbers\n with the product >= n, so this lifts to Nat.ModEq. -/\n\nlemma forward_direction {n : ℕ} (hp : n.Prime) (hn : 3 ≤ n) :\n (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := by sorry\n\nend Forward\n\nsection Backward\n/-- (2^d - 1) divides the product when 1 <= d < n. -/\n\nlemma factor_dvd_prod {d n : ℕ} (hd1 : 1 ≤ d) (hdn : d < n) :\n (2 ^ d - 1) ∣ ∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1) := sorry\n/-- If the congruence holds and d | n with 2 <= d <= n-1, then (2^d - 1) | n.\n Proof: (2^d-1) | M | (prod - n), and (2^d-1) | prod, so (2^d-1) | n. -/\n\nlemma divisor_divides_n {n d : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)])\n (hd_dvd : d ∣ n) (hd_lb : 2 ≤ d) (hd_ub : d ≤ n - 1) :\n (2 ^ d - 1) ∣ n := by sorry\n/-- Helper for backward_small: for each composite n in [4..31],\n we find a divisor d with 2 <= d <= n-1 such that (2^d - 1) does not divide n.\n This is verified by omega/decide for each concrete n. -/\n\nlemma not_dvd_of_small_composite {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ ¬((2 ^ d - 1) ∣ n) := by sorry\n/-- For composite n in [4, 31], the congruence fails. -/\n\nlemma backward_small {n : ℕ} (hn3 : 3 ≤ n) (hn31 : n ≤ 31) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- For composite n, minFac n <= n / minFac n, i.e., (minFac n)^2 <= n.\n Uses Nat.minFac_le_div. -/\n\nlemma minFac_le_sqrt {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n.minFac ≤ n / n.minFac := sorry\n/-- n / minFac n >= 6 when n >= 32 and n is composite. -/\n\nlemma div_minFac_ge_six {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n 6 ≤ n / n.minFac := by sorry\n/-- n / minFac n divides n. -/\n\nlemma div_minFac_dvd {n : ℕ} : (n / n.minFac) ∣ n := sorry\n/-- n / minFac n <= n - 1 when minFac n >= 2. -/\n\nlemma div_minFac_le_pred {n : ℕ} (hn : 2 ≤ n) : n / n.minFac ≤ n - 1 := by sorry\n/-- n <= (n/minFac n)^2 when n is composite (since minFac n <= n/minFac n). -/\n\nlemma n_le_sq_div_minFac {n : ℕ} (hn : 2 ≤ n) (hnp : ¬n.Prime) :\n n ≤ (n / n.minFac) ^ 2 := by sorry\n/-- For composite n >= 32, there exists d | n with 2 <= d <= n-1 and n < 2^d - 1.\n Take d = n / minFac(n). Then d >= 6, d | n, d <= n-1,\n and n <= d^2 < 2^d (by sq_lt_pow_of_ge_five), so n < 2^d, giving n < 2^d - 1. -/\n\nlemma backward_large_aux {n : ℕ} (hn : 32 ≤ n) (hnp : ¬n.Prime) :\n ∃ d, d ∣ n ∧ 2 ≤ d ∧ d ≤ n - 1 ∧ n < 2 ^ d - 1 := by sorry\n/-- For composite n >= 32, the congruence fails:\n backward_large_aux gives d with (2^d-1) > n, so (2^d-1) cannot divide n,\n but divisor_divides_n says it must. -/\n\nlemma backward_large {n : ℕ} (hn3 : 3 ≤ n) (hn : 32 ≤ n) (hnp : ¬n.Prime)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n False := by sorry\n/-- Backward direction: if the congruence holds and n >= 3, then n is prime.\n Split into small (n <= 31) and large (n >= 32) cases. -/\n\nlemma backward_direction {n : ℕ} (hn : 3 ≤ n)\n (hcong : (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)]) :\n n.Prime := by sorry\n\nend Backward\n\nend Vantieghem\n\ntheorem vantieghem {n : ℕ} (hn : 3 ≤ n) :\n n.Prime ↔ (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := sorry"} -{"project_name": "VonStaudtClausen", "name": "alternating_binomial_pow_sum_eq_zero", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry"} -{"project_name": "VonStaudtClausen", "name": "Finset.card_filter_add_card_filter_not'", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry"} -{"project_name": "VonStaudtClausen", "name": "factorial_mul_stirlingSecond_eq_card_surjection", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry"} -{"project_name": "VonStaudtClausen", "name": "factorial_mul_stirlingSecond_eq_sum", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry"} -{"project_name": "VonStaudtClausen", "name": "inner_sum_eq_zero_of_lt", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry"} -{"project_name": "VonStaudtClausen", "name": "stirling_binomial_convolution", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry"} -{"project_name": "VonStaudtClausen", "name": "stirling_telescoping", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry"} -{"project_name": "VonStaudtClausen", "name": "f_satisfies_recurrence", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry"} -{"project_name": "VonStaudtClausen", "name": "bernoulli_stirling_formula", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry"} -{"project_name": "VonStaudtClausen", "name": "stirlingSecond_kind_explicit_formula", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry"} -{"project_name": "VonStaudtClausen", "name": "Polynomial.fwdDiff_X_pow", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\n\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry"} -{"project_name": "VonStaudtClausen", "name": "stirlingSecond_kind_eq_fwdDiff_X_pow", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\n\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\n\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry"} -{"project_name": "VonStaudtClausen", "name": "Polynomial.bernoulli_eq_sum_fwdDiff", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\n\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\n\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry\n\nlemma Polynomial.bernoulli_eq_sum_fwdDiff (n : ℕ) (x) :\n (bernoulli n).eval x\n = ∑ k ∈ range (n + 1), (-1)^k / (k + 1) * (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x := by sorry"} -{"project_name": "VonStaudtClausen", "name": "bernoulli_number_formula_stirling", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\n\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\n\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry\n\nlemma Polynomial.bernoulli_eq_sum_fwdDiff (n : ℕ) (x) :\n (bernoulli n).eval x\n = ∑ k ∈ range (n + 1), (-1)^k / (k + 1) * (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x := by sorry\n\nlemma bernoulli_number_formula_stirling (n : ℕ) :\n bernoulli (2 * n) = ∑ j ∈ range (2 * n + 1), ((j ! : ℚ) / (j + 1)) * (-1)^j * (stirlingSecond (2 * n) j : ℚ) := by sorry"} -{"project_name": "VonStaudtClausen", "name": "factorial_div_succ_stirlingSecond_eq", "type": "theorem", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\n\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\n\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry\n\nlemma Polynomial.bernoulli_eq_sum_fwdDiff (n : ℕ) (x) :\n (bernoulli n).eval x\n = ∑ k ∈ range (n + 1), (-1)^k / (k + 1) * (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x := by sorry\n\nlemma bernoulli_number_formula_stirling (n : ℕ) :\n bernoulli (2 * n) = ∑ j ∈ range (2 * n + 1), ((j ! : ℚ) / (j + 1)) * (-1)^j * (stirlingSecond (2 * n) j : ℚ) := by sorry\n\ntheorem factorial_div_succ_stirlingSecond_eq (n : ℕ) (j : ℕ) :\n ↑j ! / (↑j + 1) * (-1 : ℚ) ^ j * ↑((2 * n).stirlingSecond j) =\n 1 / (↑j + 1) * ∑ m ∈ range (j + 1), (-1 :ℚ) ^ m * ↑(j.choose m) * ↑m ^ (2 * n) := by sorry"} -{"project_name": "VonStaudtClausen", "name": "bernoulli_two_mul_eq_sum", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\n\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\n\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry\n\nlemma Polynomial.bernoulli_eq_sum_fwdDiff (n : ℕ) (x) :\n (bernoulli n).eval x\n = ∑ k ∈ range (n + 1), (-1)^k / (k + 1) * (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x := by sorry\n\nlemma bernoulli_number_formula_stirling (n : ℕ) :\n bernoulli (2 * n) = ∑ j ∈ range (2 * n + 1), ((j ! : ℚ) / (j + 1)) * (-1)^j * (stirlingSecond (2 * n) j : ℚ) := by sorry\n\ntheorem factorial_div_succ_stirlingSecond_eq (n : ℕ) (j : ℕ) :\n ↑j ! / (↑j + 1) * (-1 : ℚ) ^ j * ↑((2 * n).stirlingSecond j) =\n 1 / (↑j + 1) * ∑ m ∈ range (j + 1), (-1 :ℚ) ^ m * ↑(j.choose m) * ↑m ^ (2 * n) := by sorry\n\nlemma bernoulli_two_mul_eq_sum (n : ℕ) :\n bernoulli (2 * n) =\n ∑ j ∈ Finset.range (2 * n + 1), (1 : ℚ) / (j + 1) *\n ∑ m ∈ Finset.range (j + 1), (-1 : ℚ)^m * Nat.choose j m * (m : ℚ)^(2 * n) := by sorry"} -{"project_name": "VonStaudtClausen", "name": "sum_neg_one_pow_mul_choose_mul_pow_two_mul", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\n\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\n\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry\n\nlemma Polynomial.bernoulli_eq_sum_fwdDiff (n : ℕ) (x) :\n (bernoulli n).eval x\n = ∑ k ∈ range (n + 1), (-1)^k / (k + 1) * (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x := by sorry\n\nlemma bernoulli_number_formula_stirling (n : ℕ) :\n bernoulli (2 * n) = ∑ j ∈ range (2 * n + 1), ((j ! : ℚ) / (j + 1)) * (-1)^j * (stirlingSecond (2 * n) j : ℚ) := by sorry\n\ntheorem factorial_div_succ_stirlingSecond_eq (n : ℕ) (j : ℕ) :\n ↑j ! / (↑j + 1) * (-1 : ℚ) ^ j * ↑((2 * n).stirlingSecond j) =\n 1 / (↑j + 1) * ∑ m ∈ range (j + 1), (-1 :ℚ) ^ m * ↑(j.choose m) * ↑m ^ (2 * n) := by sorry\n\nlemma bernoulli_two_mul_eq_sum (n : ℕ) :\n bernoulli (2 * n) =\n ∑ j ∈ Finset.range (2 * n + 1), (1 : ℚ) / (j + 1) *\n ∑ m ∈ Finset.range (j + 1), (-1 : ℚ)^m * Nat.choose j m * (m : ℚ)^(2 * n) := by sorry\n\nlemma sum_neg_one_pow_mul_choose_mul_pow_two_mul (n p : ℕ) (hp : Nat.Prime p) (hn : 1 ≤ n) :\n ∑ m ∈ Finset.range p, (-1 : ZMod p)^m * Nat.choose (p - 1) m * (m)^(2 * n)\n = if p-1 ∣ 2 * n then -1 else 0 := by sorry"} -{"project_name": "VonStaudtClausen", "name": "dvd_factorial_of_distinct", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\n\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\n\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry\n\nlemma Polynomial.bernoulli_eq_sum_fwdDiff (n : ℕ) (x) :\n (bernoulli n).eval x\n = ∑ k ∈ range (n + 1), (-1)^k / (k + 1) * (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x := by sorry\n\nlemma bernoulli_number_formula_stirling (n : ℕ) :\n bernoulli (2 * n) = ∑ j ∈ range (2 * n + 1), ((j ! : ℚ) / (j + 1)) * (-1)^j * (stirlingSecond (2 * n) j : ℚ) := by sorry\n\ntheorem factorial_div_succ_stirlingSecond_eq (n : ℕ) (j : ℕ) :\n ↑j ! / (↑j + 1) * (-1 : ℚ) ^ j * ↑((2 * n).stirlingSecond j) =\n 1 / (↑j + 1) * ∑ m ∈ range (j + 1), (-1 :ℚ) ^ m * ↑(j.choose m) * ↑m ^ (2 * n) := by sorry\n\nlemma bernoulli_two_mul_eq_sum (n : ℕ) :\n bernoulli (2 * n) =\n ∑ j ∈ Finset.range (2 * n + 1), (1 : ℚ) / (j + 1) *\n ∑ m ∈ Finset.range (j + 1), (-1 : ℚ)^m * Nat.choose j m * (m : ℚ)^(2 * n) := by sorry\n\nlemma sum_neg_one_pow_mul_choose_mul_pow_two_mul (n p : ℕ) (hp : Nat.Prime p) (hn : 1 ≤ n) :\n ∑ m ∈ Finset.range p, (-1 : ZMod p)^m * Nat.choose (p - 1) m * (m)^(2 * n)\n = if p-1 ∣ 2 * n then -1 else 0 := by sorry\n\nlemma dvd_factorial_of_distinct {a b n : ℕ} (ha : a ≤ n) (hb : b ≤ n) (hab : a ≠ b)\n (ha_pos : 0 < a) (hb_pos : 0 < b) : a * b ∣ n ! := by sorry"} -{"project_name": "VonStaudtClausen", "name": "composite_dvd_factorial", "type": "lemma", "code": "import Mathlib\n\nopen Nat\n\nopen Finset\n\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\n\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\n\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\n\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\n\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\n\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry\n\nlemma Polynomial.bernoulli_eq_sum_fwdDiff (n : ℕ) (x) :\n (bernoulli n).eval x\n = ∑ k ∈ range (n + 1), (-1)^k / (k + 1) * (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x := by sorry\n\nlemma bernoulli_number_formula_stirling (n : ℕ) :\n bernoulli (2 * n) = ∑ j ∈ range (2 * n + 1), ((j ! : ℚ) / (j + 1)) * (-1)^j * (stirlingSecond (2 * n) j : ℚ) := by sorry\n\ntheorem factorial_div_succ_stirlingSecond_eq (n : ℕ) (j : ℕ) :\n ↑j ! / (↑j + 1) * (-1 : ℚ) ^ j * ↑((2 * n).stirlingSecond j) =\n 1 / (↑j + 1) * ∑ m ∈ range (j + 1), (-1 :ℚ) ^ m * ↑(j.choose m) * ↑m ^ (2 * n) := by sorry\n\nlemma bernoulli_two_mul_eq_sum (n : ℕ) :\n bernoulli (2 * n) =\n ∑ j ∈ Finset.range (2 * n + 1), (1 : ℚ) / (j + 1) *\n ∑ m ∈ Finset.range (j + 1), (-1 : ℚ)^m * Nat.choose j m * (m : ℚ)^(2 * n) := by sorry\n\nlemma sum_neg_one_pow_mul_choose_mul_pow_two_mul (n p : ℕ) (hp : Nat.Prime p) (hn : 1 ≤ n) :\n ∑ m ∈ Finset.range p, (-1 : ZMod p)^m * Nat.choose (p - 1) m * (m)^(2 * n)\n = if p-1 ∣ 2 * n then -1 else 0 := by sorry\n\nlemma dvd_factorial_of_distinct {a b n : ℕ} (ha : a ≤ n) (hb : b ≤ n) (hab : a ≠ b)\n (ha_pos : 0 < a) (hb_pos : 0 < b) : a * b ∣ n ! := by sorry\n\nlemma composite_dvd_factorial (j : ℕ) (hlt : 3 < j) (hj : ¬ Nat.Prime (j+1)) :\n j + 1 ∣ j ! := by sorry"} -{"project_name": "VonStaudtClausen", "name": "von_staudt_clausen.IsInteger_div_prime_sum", "type": "theorem", "code": "import Mathlib\n\ntheorem von_staudt_clausen.IsInteger_div_prime_sum (n : ℕ) (hn : 1 ≤ n) (i : ℕ)\n (hi_add_one_prime : Nat.Prime (i + 1)) (hi : i ∣ 2 * n) :\n IsLocalization.IsInteger ℤ (1 / (↑i + 1) * ∑ m ∈ Finset.range (i + 1),\n (-1 : ℚ) ^ m * ↑(i.choose m) * ↑m ^ (2 * n) + 1 / (↑i + 1)) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.VonStaudtClausen.BackgroundLemmas\nopen Nat\nopen Finset\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry\nlemma Polynomial.bernoulli_eq_sum_fwdDiff (n : ℕ) (x) :\n (bernoulli n).eval x\n = ∑ k ∈ range (n + 1), (-1)^k / (k + 1) * (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x := by sorry\nlemma bernoulli_number_formula_stirling (n : ℕ) :\n bernoulli (2 * n) = ∑ j ∈ range (2 * n + 1), ((j ! : ℚ) / (j + 1)) * (-1)^j * (stirlingSecond (2 * n) j : ℚ) := by sorry\ntheorem factorial_div_succ_stirlingSecond_eq (n : ℕ) (j : ℕ) :\n ↑j ! / (↑j + 1) * (-1 : ℚ) ^ j * ↑((2 * n).stirlingSecond j) =\n 1 / (↑j + 1) * ∑ m ∈ range (j + 1), (-1 :ℚ) ^ m * ↑(j.choose m) * ↑m ^ (2 * n) := by sorry\nlemma bernoulli_two_mul_eq_sum (n : ℕ) :\n bernoulli (2 * n) =\n ∑ j ∈ Finset.range (2 * n + 1), (1 : ℚ) / (j + 1) *\n ∑ m ∈ Finset.range (j + 1), (-1 : ℚ)^m * Nat.choose j m * (m : ℚ)^(2 * n) := by sorry\nlemma sum_neg_one_pow_mul_choose_mul_pow_two_mul (n p : ℕ) (hp : Nat.Prime p) (hn : 1 ≤ n) :\n ∑ m ∈ Finset.range p, (-1 : ZMod p)^m * Nat.choose (p - 1) m * (m)^(2 * n)\n = if p-1 ∣ 2 * n then -1 else 0 := by sorry\nlemma dvd_factorial_of_distinct {a b n : ℕ} (ha : a ≤ n) (hb : b ≤ n) (hab : a ≠ b)\n (ha_pos : 0 < a) (hb_pos : 0 < b) : a * b ∣ n ! := by sorry\nlemma composite_dvd_factorial (j : ℕ) (hlt : 3 < j) (hj : ¬ Nat.Prime (j+1)) :\n j + 1 ∣ j ! := by sorry"} -{"project_name": "VonStaudtClausen", "name": "von_staudt_clausen", "type": "theorem", "code": "import Mathlib\n\ntheorem von_staudt_clausen.IsInteger_div_prime_sum (n : ℕ) (hn : 1 ≤ n) (i : ℕ)\n (hi_add_one_prime : Nat.Prime (i + 1)) (hi : i ∣ 2 * n) :\n IsLocalization.IsInteger ℤ (1 / (↑i + 1) * ∑ m ∈ Finset.range (i + 1),\n (-1 : ℚ) ^ m * ↑(i.choose m) * ↑m ^ (2 * n) + 1 / (↑i + 1)) := by sorry\n/--\nVon Staudt–Clausen Theorem\n-/\n\ntheorem von_staudt_clausen (n : ℕ) (hn : 1 ≤ n) :\n IsLocalization.IsInteger ℤ (bernoulli (2 * n) + ∑ j ∈ (Finset.range (2 * n + 1)).filter\n (fun j => (j + 1).Prime) , if j ∣ (2 * n) then (1 : ℚ) / (j+1) else 0) := by sorry", "imported_file": "-- File: LiveLeanTriathlon.VonStaudtClausen.BackgroundLemmas\nopen Nat\nopen Finset\nlemma alternating_binomial_pow_sum_eq_zero (n r : ℕ) (hr_lt : r < n) :\n ∑ k ∈ range (n + 1), ((-1 : ℤ) ^ k * n.choose k * (k : ℤ) ^ r : ℤ) = 0 := by sorry\nlemma Finset.card_filter_add_card_filter_not' {α : Type*} [DecidableEq α]\n (s : Finset α) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :\n #{x ∈ s | p x} = #{x ∈ s | p x ∧ q x} + #{x ∈ s | p x ∧ ¬q x} := by sorry\nlemma factorial_mul_stirlingSecond_eq_card_surjection (n k : ℕ) :\n k ! * (stirlingSecond n k) = Finset.card { f : Fin n → Fin k | Function.Surjective f } := by sorry\nlemma factorial_mul_stirlingSecond_eq_sum (n k : ℕ) :\n (k ! : ℤ) * (stirlingSecond n k : ℤ) = ∑ j ∈ range (k + 1),\n (-1 : ℤ) ^ (k - j) * (k.choose j) * (j : ℤ) ^ n := by sorry\nprivate lemma inner_sum_eq_zero_of_lt (m k : ℕ) (hk : m < k) :\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m = 0 := by sorry\nprivate lemma stirling_binomial_convolution (n j : ℕ) :\n ∑ i ∈ range (n + 1), (n.choose i : ℤ) * (stirlingSecond i j : ℤ) =\n (stirlingSecond (n + 1) (j + 1) : ℤ) := by sorry\nprivate lemma stirling_telescoping (n : ℕ) :\n ∑ k ∈ range n, (-1 : ℤ) ^ k * (k ! : ℤ) * (stirlingSecond n (k + 1) : ℤ) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma f_satisfies_recurrence (n : ℕ) :\n ∑ k ∈ range n, ((n.choose k : ℚ)) *\n (∑ l ∈ range (k + 1), (-1 : ℚ) ^ l / ((l : ℚ) + 1) *\n ∑ j ∈ range (l + 1), (-1 : ℚ) ^ (l - j) * (l.choose j : ℚ) * (j : ℚ) ^ k) =\n if n = 1 then 1 else 0 := by sorry\nprivate lemma bernoulli_stirling_formula (m : ℕ) :\n _root_.bernoulli m = ∑ k ∈ range (m + 1), (-1 : ℚ) ^ k / ((k : ℚ) + 1) *\n ∑ j ∈ range (k + 1), (-1 : ℚ) ^ (k - j) * (k.choose j : ℚ) * (j : ℚ) ^ m := by sorry\nlemma stirlingSecond_kind_explicit_formula (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * ∑ j ∈ range (k + 1),\n (-1 : ℚ)^(k - j) * (k.choose j) * (j : ℚ)^n := by sorry\nlemma Polynomial.fwdDiff_X_pow (n k : ℕ) (x) :\n (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x\n = ∑ j ∈ range (k + 1), (-1) ^ (k - j) * (k.choose j : ℚ) * ((X + j) ^ n).eval x := by sorry\nlemma stirlingSecond_kind_eq_fwdDiff_X_pow (n k : ℕ) :\n (stirlingSecond n k : ℚ) = (1 / k !) * (fwdDiff 1)^[k] ((Polynomial.X : Polynomial ℚ) ^ n).eval 0 := by sorry\nlemma Polynomial.bernoulli_eq_sum_fwdDiff (n : ℕ) (x) :\n (bernoulli n).eval x\n = ∑ k ∈ range (n + 1), (-1)^k / (k + 1) * (fwdDiff 1)^[k] ((X : Polynomial ℚ) ^ n).eval x := by sorry\nlemma bernoulli_number_formula_stirling (n : ℕ) :\n bernoulli (2 * n) = ∑ j ∈ range (2 * n + 1), ((j ! : ℚ) / (j + 1)) * (-1)^j * (stirlingSecond (2 * n) j : ℚ) := by sorry\ntheorem factorial_div_succ_stirlingSecond_eq (n : ℕ) (j : ℕ) :\n ↑j ! / (↑j + 1) * (-1 : ℚ) ^ j * ↑((2 * n).stirlingSecond j) =\n 1 / (↑j + 1) * ∑ m ∈ range (j + 1), (-1 :ℚ) ^ m * ↑(j.choose m) * ↑m ^ (2 * n) := by sorry\nlemma bernoulli_two_mul_eq_sum (n : ℕ) :\n bernoulli (2 * n) =\n ∑ j ∈ Finset.range (2 * n + 1), (1 : ℚ) / (j + 1) *\n ∑ m ∈ Finset.range (j + 1), (-1 : ℚ)^m * Nat.choose j m * (m : ℚ)^(2 * n) := by sorry\nlemma sum_neg_one_pow_mul_choose_mul_pow_two_mul (n p : ℕ) (hp : Nat.Prime p) (hn : 1 ≤ n) :\n ∑ m ∈ Finset.range p, (-1 : ZMod p)^m * Nat.choose (p - 1) m * (m)^(2 * n)\n = if p-1 ∣ 2 * n then -1 else 0 := by sorry\nlemma dvd_factorial_of_distinct {a b n : ℕ} (ha : a ≤ n) (hb : b ≤ n) (hab : a ≠ b)\n (ha_pos : 0 < a) (hb_pos : 0 < b) : a * b ∣ n ! := by sorry\nlemma composite_dvd_factorial (j : ℕ) (hlt : 3 < j) (hj : ¬ Nat.Prime (j+1)) :\n j + 1 ∣ j ! := by sorry"} -{"project_name": "WaringProblem", "name": "waring", "type": "theorem", "code": "import Mathlib\n/-- https://en.wikipedia.org/wiki/Waring%27s_problem -/\n\ntheorem waring (n : ℕ) : ∃ t : ℕ,\n ∀ k, ∃ s : Finset ℕ, s.card ≤ t ∧ k = ∑ i ∈ s, i ^ n := by sorry"} -{"project_name": "Wolstenholme", "name": "choose_mul_factorial_eq_prod", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry"} -{"project_name": "Wolstenholme", "name": "factorial_coprime_prime_cube", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry"} -{"project_name": "Wolstenholme", "name": "cancel_factorial", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry"} -{"project_name": "Wolstenholme", "name": "sum_inv_eq_zero_zmod", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry"} -{"project_name": "Wolstenholme", "name": "sum_sq_eq_zero_zmod", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry"} -{"project_name": "Wolstenholme", "name": "sum_inv_sq_eq_sum_sq", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry"} -{"project_name": "Wolstenholme", "name": "sum_inv_sq_eq_zero_zmod", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry"} -{"project_name": "Wolstenholme", "name": "sum_inv_zero_mod_p", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry"} -{"project_name": "Wolstenholme", "name": "prod_erase_pair", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry"} -{"project_name": "Wolstenholme", "name": "two_mul_sum_eq", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry"} -{"project_name": "Wolstenholme", "name": "p_dvd_sum_h", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry"} -{"project_name": "Wolstenholme", "name": "sum_inv_zero_mod_p_sq", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry"} -{"project_name": "Wolstenholme", "name": "sq_sum_eq", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry"} -{"project_name": "Wolstenholme", "name": "sum_cross_inv_eq_zero_zmod", "type": "lemma", "code": "import Mathlib\n\nopen Nat Finset BigOperators\n\nnamespace Wolstenholme\n/-- The product `(p+1)(p+2)...(p+(p-1))` equals `C(2p-1, p-1) * (p-1)!`. -/\n\nlemma choose_mul_factorial_eq_prod {p : ℕ} (hp : 1 ≤ p) :\n (2 * p - 1).choose (p - 1) * (p - 1)! = ∏ k ∈ range (p - 1), (p + (k + 1)) := by sorry\n/-- `(p-1)!` is coprime to `p^3` when `p` is prime. -/\n\nlemma factorial_coprime_prime_cube {p : ℕ} (hp : p.Prime) :\n Nat.Coprime ((p - 1)!) (p ^ 3) := by sorry\n/-- Cancelling `(p-1)!` from a Nat.ModEq: the binomial coefficient is 1 mod p^3\n iff the product equals `(p-1)!` mod p^3. -/\n\nlemma cancel_factorial {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n ((2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]) ↔\n (∏ k ∈ range (p - 1), (p + (k + 1)) ≡ (p - 1)! [MOD p ^ 3]) := by sorry\n/-- In `ZMod p`, the sum of inverses `sum_{k=1}^{p-1} k⁻¹` is zero.\n Uses the pairing `k <-> p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i p - k`. -/\n\nlemma sum_inv_eq_zero_zmod (p : ℕ) [Fact p.Prime] (hodd : Odd p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ = 0 := by sorry\n/-- The sum `sum_{k=1}^{p-1} k²` is divisible by `p` for primes `p >= 5`.\n Uses the formula `sum k² = (p-1)*p*(2p-1)/6`. -/\n\nlemma sum_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 = 0 := by sorry\n/-- The sum of inverse squares equals the sum of squares in ZMod p,\n via the bijection k -> k⁻¹ on {1, ..., p-1}. -/\n\nlemma sum_inv_sq_eq_sum_sq {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 =\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p)) ^ 2 := by sorry\n/-- In `ZMod p`, the sum of inverse squares `sum_{k=1}^{p-1} k⁻²` is zero.\n Uses the bijection `k -> k⁻¹` to convert to `sum k²`, then the closed form. -/\n\nlemma sum_inv_sq_eq_zero_zmod {p : ℕ} [Fact p.Prime] (hp5 : 5 ≤ p) :\n ∑ k ∈ Finset.range (p - 1), ((↑(k + 1) : ZMod p))⁻¹ ^ 2 = 0 := by sorry\n/-- `sum_{k=1}^{p-1} k⁻¹ = 0` in ZMod p implies the Nat statement:\n `p | sum_{k=1}^{p-1} prod_{j≠k} j` (the \"numerator\" form). -/\n\nlemma sum_inv_zero_mod_p {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\nprivate lemma prod_erase_pair {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) {k : ℕ} (hk : k < p - 1) :\n (∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ))) +\n (∏ j ∈ (range (p - 1)).erase (p - 2 - k), ((↑j + 1 : ℤ))) =\n (p : ℤ) * ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma two_mul_sum_eq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n 2 * ∑ k ∈ range (p - 1), ∏ j ∈ (range (p - 1)).erase k, ((↑j + 1 : ℤ)) =\n (p : ℤ) * ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\nprivate lemma p_dvd_sum_h {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ ((range (p - 1)).erase k).erase (p - 2 - k), ((↑j + 1 : ℤ)) := by sorry\n\nlemma sum_inv_zero_mod_p_sq {p : ℕ} (hp : p.Prime) (hp5 : 5 ≤ p) :\n (p ^ 2 : ℤ) ∣ ∑ k ∈ range (p - 1),\n ∏ j ∈ (range (p - 1)).erase k, ((j + 1 : ℤ)) := by sorry\n/-- The square-of-sum identity in a commutative ring:\n (sum a_i)^2 = sum a_i^2 + 2 * sum_{i < j} a_i * a_j -/\n\nlemma sq_sum_eq {α : Type*} [CommRing α] {n : ℕ} (a : ℕ → α) :\n (∑ i ∈ range n, a i) ^ 2 =\n ∑ i ∈ range n, a i ^ 2 +\n 2 * ∑ ij ∈ (range n).product (range n),\n if ij.1 < ij.2 then a ij.1 * a ij.2 else 0 := by sorry\n/-- The cross term `sum_{i= 5`,\n `C(2p-1, p-1) = 1 (mod p^3)`. -/\n\ntheorem wolstenholme {p : ℕ} (hp : p.Prime) (hp' : 5 ≤ p) :\n (2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3] := by sorry"} -{"project_name": "Worpitzky", "name": "eulerianNumber_zero", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry"} -{"project_name": "Worpitzky", "name": "s_finite", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry"} -{"project_name": "Worpitzky", "name": "count_bump_le", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry"} -{"project_name": "Worpitzky", "name": "s_alt", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry"} -{"project_name": "Worpitzky", "name": "eulerianNumber_eq_zero", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry"} -{"project_name": "Worpitzky", "name": "eulerianNumber_eq_zero'", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry"} -{"project_name": "Worpitzky", "name": "eulerianNumber_sum", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry"} -{"project_name": "Worpitzky", "name": "perm_le_of_neq_lt", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry"} -{"project_name": "Worpitzky", "name": "perm_mono_iff", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry"} -{"project_name": "Worpitzky", "name": "s_end", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry"} -{"project_name": "Worpitzky", "name": "fun_back_twice", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry"} -{"project_name": "Worpitzky", "name": "perm_back_involutive", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry"} -{"project_name": "Worpitzky", "name": "perm_back_bijective", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry"} -{"project_name": "Worpitzky", "name": "ncard_compl", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry"} -{"project_name": "Worpitzky", "name": "count_bump_perm_back", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry"} -{"project_name": "Worpitzky", "name": "eulerianNumber_symm", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry"} -{"project_name": "Worpitzky", "name": "eulerianNumber_zero'", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry"} -{"project_name": "Worpitzky", "name": "fun_down_ne_left", "type": "lemma", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry"} -{"project_name": "Worpitzky", "name": "fun_down_ne_right", "type": "lemma", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry"} -{"project_name": "Worpitzky", "name": "fun_down_bij", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry"} -{"project_name": "Worpitzky", "name": "perm_down_bij", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry"} -{"project_name": "Worpitzky", "name": "decomposeEnd_lt_left", "type": "lemma", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry"} -{"project_name": "Worpitzky", "name": "decomposeEnd_lt_right", "type": "lemma", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry"} -{"project_name": "Worpitzky", "name": "decompose_end_lt'", "type": "lemma", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry"} -{"project_name": "Worpitzky", "name": "decompose_end_lt''", "type": "lemma", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry"} -{"project_name": "Worpitzky", "name": "equiv_invperm", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry"} -{"project_name": "Worpitzky", "name": "decomposeEnd_symm_def", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry"} -{"project_name": "Worpitzky", "name": "decomposeEnd_eq", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry"} -{"project_name": "Worpitzky", "name": "val_le", "type": "lemma", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry"} -{"project_name": "Worpitzky", "name": "val_lt", "type": "lemma", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry"} -{"project_name": "Worpitzky", "name": "decomposeEnd", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry"} -{"project_name": "Worpitzky", "name": "decomposeEnd'", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry"} -{"project_name": "Worpitzky", "name": "ncard_decomposeEnd_image", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry"} -{"project_name": "Worpitzky", "name": "ncard_subset_prod", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry"} -{"project_name": "Worpitzky", "name": "decomposeEnd_set_eq", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry\n\ntheorem decomposeEnd_set_eq {n : ℕ} (s : Perm (Fin (n + 1))) :\n {k : Fin (n + 1 + 1) | count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) = count_bump s}\n = {k : Fin (n + 1 + 1) | k = n + 1 ∨ ∃ h1 : k ≠ n + 1, ∃ h0 : k ≠ 0,\n s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩} := by sorry"} -{"project_name": "Worpitzky", "name": "eulerianNumber_rec'", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry\n\ntheorem decomposeEnd_set_eq {n : ℕ} (s : Perm (Fin (n + 1))) :\n {k : Fin (n + 1 + 1) | count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) = count_bump s}\n = {k : Fin (n + 1 + 1) | k = n + 1 ∨ ∃ h1 : k ≠ n + 1, ∃ h0 : k ≠ 0,\n s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩} := by sorry\n\ntheorem eulerianNumber_rec'\n (m k : ℕ) : EulerianNumber (m + 1 + 1) (k + 1) =\n (m + 1 - k) * EulerianNumber (m + 1) k + (k + 2) * EulerianNumber (m + 1) (k + 1) := by sorry"} -{"project_name": "Worpitzky", "name": "eulerianNumber_rec", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry\n\ntheorem decomposeEnd_set_eq {n : ℕ} (s : Perm (Fin (n + 1))) :\n {k : Fin (n + 1 + 1) | count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) = count_bump s}\n = {k : Fin (n + 1 + 1) | k = n + 1 ∨ ∃ h1 : k ≠ n + 1, ∃ h0 : k ≠ 0,\n s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩} := by sorry\n\ntheorem eulerianNumber_rec'\n (m k : ℕ) : EulerianNumber (m + 1 + 1) (k + 1) =\n (m + 1 - k) * EulerianNumber (m + 1) k + (k + 2) * EulerianNumber (m + 1) (k + 1) := by sorry\n\ntheorem eulerianNumber_rec (n k : ℕ) :\n EulerianNumber (n + 1) (k + 1)\n = (n - k) * EulerianNumber n k + (k + 2) * EulerianNumber n (k + 1) := by sorry"} -{"project_name": "Worpitzky", "name": "choose_succ_right_eq'", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry\n\ntheorem decomposeEnd_set_eq {n : ℕ} (s : Perm (Fin (n + 1))) :\n {k : Fin (n + 1 + 1) | count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) = count_bump s}\n = {k : Fin (n + 1 + 1) | k = n + 1 ∨ ∃ h1 : k ≠ n + 1, ∃ h0 : k ≠ 0,\n s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩} := by sorry\n\ntheorem eulerianNumber_rec'\n (m k : ℕ) : EulerianNumber (m + 1 + 1) (k + 1) =\n (m + 1 - k) * EulerianNumber (m + 1) k + (k + 2) * EulerianNumber (m + 1) (k + 1) := by sorry\n\ntheorem eulerianNumber_rec (n k : ℕ) :\n EulerianNumber (n + 1) (k + 1)\n = (n - k) * EulerianNumber n k + (k + 2) * EulerianNumber n (k + 1) := by sorry\n\nvariable {R : Type u} [Ring R] [BinomialRing R]\n\nsection\n\ntheorem choose_succ_right_eq' (n k : ℕ) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := by sorry"} -{"project_name": "Worpitzky", "name": "sum_pull_front", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry\n\ntheorem decomposeEnd_set_eq {n : ℕ} (s : Perm (Fin (n + 1))) :\n {k : Fin (n + 1 + 1) | count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) = count_bump s}\n = {k : Fin (n + 1 + 1) | k = n + 1 ∨ ∃ h1 : k ≠ n + 1, ∃ h0 : k ≠ 0,\n s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩} := by sorry\n\ntheorem eulerianNumber_rec'\n (m k : ℕ) : EulerianNumber (m + 1 + 1) (k + 1) =\n (m + 1 - k) * EulerianNumber (m + 1) k + (k + 2) * EulerianNumber (m + 1) (k + 1) := by sorry\n\ntheorem eulerianNumber_rec (n k : ℕ) :\n EulerianNumber (n + 1) (k + 1)\n = (n - k) * EulerianNumber n k + (k + 2) * EulerianNumber n (k + 1) := by sorry\n\nvariable {R : Type u} [Ring R] [BinomialRing R]\n\nsection\n\ntheorem choose_succ_right_eq' (n k : ℕ) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := by sorry\n\nend\n\ntheorem sum_pull_front {S : Type u} [AddCommGroup S] (f : ℕ → S) {n : ℕ} (hn : 0 < n) :\n ∑ k ∈ Finset.range n, f k = f 0 + ∑ k ∈ Finset.Ico 1 n, f k := by sorry"} -{"project_name": "Worpitzky", "name": "worpitzky3", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry\n\ntheorem decomposeEnd_set_eq {n : ℕ} (s : Perm (Fin (n + 1))) :\n {k : Fin (n + 1 + 1) | count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) = count_bump s}\n = {k : Fin (n + 1 + 1) | k = n + 1 ∨ ∃ h1 : k ≠ n + 1, ∃ h0 : k ≠ 0,\n s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩} := by sorry\n\ntheorem eulerianNumber_rec'\n (m k : ℕ) : EulerianNumber (m + 1 + 1) (k + 1) =\n (m + 1 - k) * EulerianNumber (m + 1) k + (k + 2) * EulerianNumber (m + 1) (k + 1) := by sorry\n\ntheorem eulerianNumber_rec (n k : ℕ) :\n EulerianNumber (n + 1) (k + 1)\n = (n - k) * EulerianNumber n k + (k + 2) * EulerianNumber n (k + 1) := by sorry\n\nvariable {R : Type u} [Ring R] [BinomialRing R]\n\nsection\n\ntheorem choose_succ_right_eq' (n k : ℕ) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := by sorry\n\nend\n\ntheorem sum_pull_front {S : Type u} [AddCommGroup S] (f : ℕ → S) {n : ℕ} (hn : 0 < n) :\n ∑ k ∈ Finset.range n, f k = f 0 + ∑ k ∈ Finset.Ico 1 n, f k := by sorry\n\ntheorem worpitzky3 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n ∑ k ∈ Finset.range (n + 1),\n EulerianNumber n k * ((n - k) * (Ring.choose (x + k) (n + 1) + Ring.choose (x + k) n)\n + (k + 1) * Ring.choose (x + k) (n + 1)) = x ^ (n + 1) := by sorry"} -{"project_name": "Worpitzky", "name": "worpitzky2", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry\n\ntheorem decomposeEnd_set_eq {n : ℕ} (s : Perm (Fin (n + 1))) :\n {k : Fin (n + 1 + 1) | count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) = count_bump s}\n = {k : Fin (n + 1 + 1) | k = n + 1 ∨ ∃ h1 : k ≠ n + 1, ∃ h0 : k ≠ 0,\n s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩} := by sorry\n\ntheorem eulerianNumber_rec'\n (m k : ℕ) : EulerianNumber (m + 1 + 1) (k + 1) =\n (m + 1 - k) * EulerianNumber (m + 1) k + (k + 2) * EulerianNumber (m + 1) (k + 1) := by sorry\n\ntheorem eulerianNumber_rec (n k : ℕ) :\n EulerianNumber (n + 1) (k + 1)\n = (n - k) * EulerianNumber n k + (k + 2) * EulerianNumber n (k + 1) := by sorry\n\nvariable {R : Type u} [Ring R] [BinomialRing R]\n\nsection\n\ntheorem choose_succ_right_eq' (n k : ℕ) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := by sorry\n\nend\n\ntheorem sum_pull_front {S : Type u} [AddCommGroup S] (f : ℕ → S) {n : ℕ} (hn : 0 < n) :\n ∑ k ∈ Finset.range n, f k = f 0 + ∑ k ∈ Finset.Ico 1 n, f k := by sorry\n\ntheorem worpitzky3 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n ∑ k ∈ Finset.range (n + 1),\n EulerianNumber n k * ((n - k) * (Ring.choose (x + k) (n + 1) + Ring.choose (x + k) n)\n + (k + 1) * Ring.choose (x + k) (n + 1)) = x ^ (n + 1) := by sorry\n\ntheorem worpitzky2 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n ∑ k ∈ Finset.range (n + 1),\n (n - k) * EulerianNumber n k * Ring.choose (x + ↑(k + 1)) (n + 1)\n + ∑ k ∈ Finset.range (n + 1),\n (k + 1) * EulerianNumber n k * Ring.choose (x + k) (n + 1)= x ^ (n + 1) := by sorry"} -{"project_name": "Worpitzky", "name": "worpitzky1", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry\n\ntheorem decomposeEnd_set_eq {n : ℕ} (s : Perm (Fin (n + 1))) :\n {k : Fin (n + 1 + 1) | count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) = count_bump s}\n = {k : Fin (n + 1 + 1) | k = n + 1 ∨ ∃ h1 : k ≠ n + 1, ∃ h0 : k ≠ 0,\n s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩} := by sorry\n\ntheorem eulerianNumber_rec'\n (m k : ℕ) : EulerianNumber (m + 1 + 1) (k + 1) =\n (m + 1 - k) * EulerianNumber (m + 1) k + (k + 2) * EulerianNumber (m + 1) (k + 1) := by sorry\n\ntheorem eulerianNumber_rec (n k : ℕ) :\n EulerianNumber (n + 1) (k + 1)\n = (n - k) * EulerianNumber n k + (k + 2) * EulerianNumber n (k + 1) := by sorry\n\nvariable {R : Type u} [Ring R] [BinomialRing R]\n\nsection\n\ntheorem choose_succ_right_eq' (n k : ℕ) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := by sorry\n\nend\n\ntheorem sum_pull_front {S : Type u} [AddCommGroup S] (f : ℕ → S) {n : ℕ} (hn : 0 < n) :\n ∑ k ∈ Finset.range n, f k = f 0 + ∑ k ∈ Finset.Ico 1 n, f k := by sorry\n\ntheorem worpitzky3 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n ∑ k ∈ Finset.range (n + 1),\n EulerianNumber n k * ((n - k) * (Ring.choose (x + k) (n + 1) + Ring.choose (x + k) n)\n + (k + 1) * Ring.choose (x + k) (n + 1)) = x ^ (n + 1) := by sorry\n\ntheorem worpitzky2 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n ∑ k ∈ Finset.range (n + 1),\n (n - k) * EulerianNumber n k * Ring.choose (x + ↑(k + 1)) (n + 1)\n + ∑ k ∈ Finset.range (n + 1),\n (k + 1) * EulerianNumber n k * Ring.choose (x + k) (n + 1)= x ^ (n + 1) := by sorry\n\ntheorem worpitzky1 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n Ring.choose x (n + 1) + ∑ k ∈ Finset.Ico 0 (n + 1),\n (n - k) * EulerianNumber n k * Ring.choose (x + ↑(k + 1)) (n + 1)\n + ∑ k ∈ Finset.Ico 0 (n + 1),\n (k + 2) * EulerianNumber n (k + 1) * Ring.choose (x + ↑(k + 1)) (n + 1) = x ^ (n + 1) := by sorry"} -{"project_name": "Worpitzky", "name": "worpitzky", "type": "theorem", "code": "import Mathlib\n\nuniverse u v\nnoncomputable section\n\nopen Nat Function Set Equiv Fin\n/-- Set of n-permutations with `k` \"ascents\" -/\n\ndef S : (n : ℕ) → ℕ → Set (Perm (Fin n))\n | zero => fun k ↦ if k = 0 then univ else ∅\n | (Nat.succ n) =>\n fun k ↦\n {p : Perm (Fin (n + 1)) | {s : (Fin n) | p s.castSucc < p s.succ}.ncard = k}\n/-- This is the definition of Eulerian numbers. -/\n\ndef EulerianNumber : ℕ → ℕ → ℕ :=\n fun n k ↦ (S n k).ncard\n\ntheorem eulerianNumber_zero : EulerianNumber 0 = Function.update (fun _ ↦ 0) 0 1 := by sorry\n\ntheorem s_finite (n k : ℕ) : Finite (S n k) := sorry\n/-- The number of ascents in a permutation -/\n\ndef count_bump {n : ℕ} (p : Perm (Fin (n + 1))) := {s : (Fin n) | p s.castSucc < p s.succ}.ncard\n\ntheorem count_bump_le {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump p ≤ n := by sorry\n\ntheorem s_alt (n k : ℕ) : S (n + 1) k = (count_bump)⁻¹' {k} := by sorry\n\ntheorem eulerianNumber_eq_zero {n k : ℕ} (h : n < k) : EulerianNumber (n + 1) k = 0 := by sorry\n\ntheorem eulerianNumber_eq_zero' {n k : ℕ} (h : n < k) : EulerianNumber n k = 0 := by sorry\n\ntheorem eulerianNumber_sum (n : ℕ) :\n ∑ i ∈ Finset.range (n + 1), EulerianNumber n i = n.factorial := by sorry\n\ntheorem perm_le_of_neq_lt {n : ℕ} {p : Perm (Fin n)} {a b : Fin n} (ab : a ≠ b) (h : p a ≤ p b) :\n p a < p b := by sorry\n\ntheorem perm_mono_iff {n : ℕ} (p : Perm (Fin (n + 1))) :\n p = 1 ↔ ∀ s : Fin n, p s.castSucc < p s.succ := by sorry\n\ntheorem s_end (n : ℕ) : S (n + 1) n = {1} := by sorry\n/--\nFunction that reverses the order of the elements in a permutation, i.e. sends `p` to the function `k ↦ n - p k`.\n-/\n\ndef fun_back {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) : Fin (n + 1) → Fin (n + 1) :=\n fun ⟨k, kh⟩ ↦ ⟨n - f ⟨k, kh⟩, sub_lt_succ n ↑(f ⟨k, kh⟩)⟩\n\ntheorem fun_back_twice {n : ℕ} (f : Fin (n + 1) → Fin (n + 1)) :\n (fun_back (fun_back f)) = f := by sorry\n/--\nfun_back as a permutation, i.e. the function that sends `p` to the permutation `k ↦ n - p k`.\n-/\n\ndef perm_back {n : ℕ} (p : Perm (Fin (n + 1))) : Perm (Fin (n + 1)) where\n toFun := fun_back p.toFun\n invFun := p.invFun ∘ (fun_back (n := n) (id (α := Fin (n + 1))))\n left_inv := by\n intro x\n have : fun_back id (fun_back p.toFun x) = fun_back (fun_back (⇑p)) x := by rfl\n unfold comp\n rw [this, fun_back_twice]\n exact p.left_inv x\n right_inv := by\n intro x\n unfold comp fun_back\n ext\n simp only [invFun_as_coe, Fin.eta, id_eq, toFun_as_coe, apply_symm_apply]\n refine Nat.sub_sub_self (is_le x)\n\ntheorem perm_back_involutive (n : ℕ) : Involutive (perm_back (n := n)) := by sorry\n\ntheorem perm_back_bijective (n : ℕ) : Bijective (perm_back (n := n)) := by sorry\n\ntheorem ncard_compl {X : Type u} [Fintype X] (s : Set X) :\n sᶜ.ncard = Fintype.card X - s.ncard := by sorry\n\ntheorem count_bump_perm_back {n : ℕ} (p : Perm (Fin (n + 1))) :\n count_bump (perm_back p) = n - count_bump p := by sorry\n\ntheorem eulerianNumber_symm {n k : ℕ} (h : k < n) :\n EulerianNumber n k = EulerianNumber n (n - k - 1) := by sorry\n@[simp]\n\ntheorem eulerianNumber_zero' (n : ℕ) : EulerianNumber n 0 = 1 := by sorry\n\nsection\nexample (n : ℕ) (k i : Fin (n + 1)) (h : k < i) : i ≠ 0 := by exact Fin.ne_zero_of_lt h\n\nlemma fun_down_ne_left {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : i.castSucc < s⁻¹ 0) :\n (s i.castSucc) ≠ 0 := by sorry\n\nlemma fun_down_ne_right {n : ℕ} {s : Perm (Fin (n + 1))} {i : Fin n} (h : ¬ i.castSucc < s⁻¹ 0) :\n (s i.succ) ≠ 0 := by sorry\n/--\nThe nonzero elements of a permutation `s`, reduced to a permutation of `Fin n`\n-/\n\ndef fun_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin n → Fin n :=\n fun i ↦ if hi : i.castSucc < s⁻¹ 0\n then (s i.castSucc).pred (fun_down_ne_left hi) else (s i.succ).pred (fun_down_ne_right hi)\n\ntheorem fun_down_bij {n : ℕ} (s : Perm (Fin (n + 1))) : Bijective (fun_down s) := by sorry\n/--\n`fun_down` as a pair consisting of\nthe preimage of the permutation at `0` and the reduced permutation on `Fin n`.\n-/\n\ndef perm_down {n : ℕ} (s : Perm (Fin (n + 1))) : Fin (n + 1) × Perm (Fin n) :=\n (s⁻¹ 0, {\n toFun := fun_down s\n invFun := Fintype.bijInv (fun_down_bij s)\n left_inv := Fintype.leftInverse_bijInv (fun_down_bij s)\n right_inv := Fintype.rightInverse_bijInv (fun_down_bij s)\n })\n\ntheorem perm_down_bij {n : ℕ} : Bijective (perm_down (n := n)) := by sorry\n/--\nperm_down as an equivalence\n-/\n\ndef Equiv.Perm.decomposeEnd {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) where\n toFun := perm_down\n invFun := Fintype.bijInv (perm_down_bij (n := n))\n left_inv := Fintype.leftInverse_bijInv perm_down_bij\n right_inv := Fintype.rightInverse_bijInv perm_down_bij\n\nlemma decomposeEnd_lt_left {n : ℕ} (a : Fin n) : a.val - 1 < n := by sorry\n\nlemma decomposeEnd_lt_right {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a.val + 1 < n + 1 := by sorry\n\nlemma decompose_end_lt' {n : ℕ} {a b : Fin (n + 1)} (h : a < b) : a < n := by sorry\n\nlemma decompose_end_lt'' {n : ℕ} {a : Fin (n + 1)} (h : a ≠ n) : a < n := by sorry\n/--\nConstruct a permutation from a bijection,\ni.e. the function that sends a bijection `f` to the permutation `k ↦ f k`.\n-/\n\ndef mkPermBij {α : Type u} [Fintype α] [DecidableEq α]\n {f : α → α} (f_bij : Bijective f) : Perm α where\n toFun := f\n invFun := Fintype.bijInv f_bij\n left_inv := Fintype.leftInverse_bijInv f_bij\n right_inv := Fintype.rightInverse_bijInv f_bij\n\ntheorem equiv_invperm {n : ℕ} {α : Type u}\n (e : Perm (Fin n.succ) ≃ α) (i : α)\n {f : Fin n.succ → Fin n.succ} {f_bij : Bijective f} (h : e (mkPermBij f_bij) = i) :\n e.symm i = f := by sorry\n\ntheorem decomposeEnd_symm_def {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) =\n fun i ↦ if h0 : i < k then (s ⟨i.val, decompose_end_lt' h0⟩).succ else\n if h1 : k < i then (s (i.pred (Fin.ne_zero_of_lt h1))).succ else 0 := by sorry\n@[simp]\n\ntheorem decomposeEnd_eq {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 2)) :\n Equiv.Perm.decomposeEnd.symm (k, s) k = 0 := by sorry\n\nlemma val_le {n : ℕ} {a b : Fin n} (h : a.val ≤ b.val) : a ≤ b := sorry\n\nlemma val_lt {n : ℕ} {a b : Fin n} (h : a.val < b.val) : a < b := sorry\n\nset_option maxHeartbeats 300000 in\n\ntheorem decomposeEnd {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n if h0 : k = 0 then count_bump s + 1 else\n if h1 : k = n + 1 then count_bump s else\n if s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩ then count_bump s else\n count_bump s + 1 := by sorry\n\ntheorem decomposeEnd' {n : ℕ} (s : Perm (Fin (n + 1))) (k : Fin (n + 1 + 1)) :\n count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s ∨ count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) =\n count_bump s + 1 := by sorry\n\nend\n\ntheorem ncard_decomposeEnd_image\n {n : ℕ} (S : Set (Perm (Fin (n + 1)))) :\n ((Equiv.Perm.decomposeEnd)'' S).ncard = S.ncard := by sorry\n\ntheorem ncard_subset_prod (n : ℕ) {A : Type u} {B : Type v} [DecidableEq B]\n {S : Set (A × B)} (hS : S.Finite)\n (h : ∀ t ∈ S, {i : A | (i, t.2) ∈ S}.ncard = n) :\n S.ncard = n * {t.2 | t ∈ S}.ncard := by sorry\n\ntheorem decomposeEnd_set_eq {n : ℕ} (s : Perm (Fin (n + 1))) :\n {k : Fin (n + 1 + 1) | count_bump (Equiv.Perm.decomposeEnd.symm (k, s)) = count_bump s}\n = {k : Fin (n + 1 + 1) | k = n + 1 ∨ ∃ h1 : k ≠ n + 1, ∃ h0 : k ≠ 0,\n s (k.pred h0) < s ⟨k, decompose_end_lt'' h1⟩} := by sorry\n\ntheorem eulerianNumber_rec'\n (m k : ℕ) : EulerianNumber (m + 1 + 1) (k + 1) =\n (m + 1 - k) * EulerianNumber (m + 1) k + (k + 2) * EulerianNumber (m + 1) (k + 1) := by sorry\n\ntheorem eulerianNumber_rec (n k : ℕ) :\n EulerianNumber (n + 1) (k + 1)\n = (n - k) * EulerianNumber n k + (k + 2) * EulerianNumber n (k + 1) := by sorry\n\nvariable {R : Type u} [Ring R] [BinomialRing R]\n\nsection\n\ntheorem choose_succ_right_eq' (n k : ℕ) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := by sorry\n\nend\n\ntheorem sum_pull_front {S : Type u} [AddCommGroup S] (f : ℕ → S) {n : ℕ} (hn : 0 < n) :\n ∑ k ∈ Finset.range n, f k = f 0 + ∑ k ∈ Finset.Ico 1 n, f k := by sorry\n\ntheorem worpitzky3 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n ∑ k ∈ Finset.range (n + 1),\n EulerianNumber n k * ((n - k) * (Ring.choose (x + k) (n + 1) + Ring.choose (x + k) n)\n + (k + 1) * Ring.choose (x + k) (n + 1)) = x ^ (n + 1) := by sorry\n\ntheorem worpitzky2 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n ∑ k ∈ Finset.range (n + 1),\n (n - k) * EulerianNumber n k * Ring.choose (x + ↑(k + 1)) (n + 1)\n + ∑ k ∈ Finset.range (n + 1),\n (k + 1) * EulerianNumber n k * Ring.choose (x + k) (n + 1)= x ^ (n + 1) := by sorry\n\ntheorem worpitzky1 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n Ring.choose x (n + 1) + ∑ k ∈ Finset.Ico 0 (n + 1),\n (n - k) * EulerianNumber n k * Ring.choose (x + ↑(k + 1)) (n + 1)\n + ∑ k ∈ Finset.Ico 0 (n + 1),\n (k + 2) * EulerianNumber n (k + 1) * Ring.choose (x + ↑(k + 1)) (n + 1) = x ^ (n + 1) := by sorry\n\ntheorem worpitzky (n : ℕ) (x : R) :\n ∑ k ∈ Finset.range (n + 1), (↑(EulerianNumber n k) : R) * Ring.choose (x + k) n = x ^ n := by sorry"} -{"project_name": "ZsigmondyTheorem", "name": "zsigmondy_theorem", "type": "theorem", "code": "import Mathlib\n/-- A prime `p` is a *primitive prime divisor* of `a ^ n - b ^ n` if `p` divides `a ^ n - b ^ n`\nbut does not divide `a ^ k - b ^ k` for any positive `k < n`. -/\n\ndef IsPrimitivePrimeDivisor (a b n p : Nat) : Prop :=\n Nat.Prime p\n ∧ p ∣ a ^ n - b ^ n\n ∧ ∀ k : Nat, 1 ≤ k → k < n → ¬(p ∣ a ^ k - b ^ k)\n/-- **Zsigmondy's theorem.** Let `a > b ≥ 1` be coprime positive integers and `n ≥ 2`.\nThen `a ^ n - b ^ n` has a primitive prime divisor, unless either\n(1) `n = 2` and `a + b` is a power of two, or (2) `(a, b, n) = (2, 1, 6)`. -/\n\ntheorem zsigmondy_theorem\n (a b n : Nat)\n (hab_coprime : Nat.Coprime a b)\n (ha_gt_b : b < a)\n (hb_pos : 0 < b)\n (hn : 2 ≤ n)\n (hexc1 : ¬(n = 2 ∧ (a + b).isPowerOfTwo))\n (hexc2 : ¬(a = 2 ∧ b = 1 ∧ n = 6)) :\n ∃ p, IsPrimitivePrimeDivisor a b n p := by sorry"} diff --git a/scripts/create_sorries/statements_autoformalization.jsonl b/scripts/create_sorries/statements_autoformalization.jsonl deleted file mode 100644 index e73d7c7..0000000 --- a/scripts/create_sorries/statements_autoformalization.jsonl +++ /dev/null @@ -1,116 +0,0 @@ -{"project_name": "AndersonTheorem", "name": "anderson", "type": "theorem", "title": "Anderson's theorem", "informal_statement": "Let $E \\subseteq \\mathbb{R}^n$ be convex, symmetric about the origin.\n Let $f$ be a nonnegative function on $\\mathbb{R}^n$ such that\n \\begin{enumerate}\n \\item $f(x)=f(-x)$ for all $x$.\n \\item $\\{x | f(x) \\geq u\\} = K_u$ is convex for every $u$ ($0 < u < \\infty$), and\n \\item $\\int_{\\mathbb{R}^n} f(x)dx<\\infty$.\n \\end{enumerate}\n Then\n \\begin{displaymath}\n \\int_E f(x+ky)dx \\geq \\int_E f(x+y)dx\n \\end{displaymath}\n for $0 \\leq k \\leq 1$.", "informal_proof": "\\chapter{Anderson's theorem}\n\nThis section contains a proof of Anderson's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Anderson's_theorem} for more details.\n\n\\begin{theorem}\n \\label{thm:brunn_minkowski_onedim}\n \\lean{brunn_minkowski_1d}\n If $A, B, A + B \\subseteq \\mathbb{R}$ are nonempty and Lebesgue measurable where\n $A + B = {x + y | x \\in A, y \\in B}$, then $\\mu(A) + \\mu(B) \\leq \\mu(A+B)$.\n\\end{theorem}\n\\begin{proof}\n Let $A_k = A \\cap [-k, k]$ for $k \\in \\mathbb{N}$.\n Since $\\mu(A+B) = \\lim_{k \\to \\infty} \\mu(A_k+B_k)$ and $\\mu(A) = \\lim_{k \\to \\infty} \\mu(A_k)$, $\\mu(B) = \\lim_{k \\to \\infty} \\mu(B_k)$, it suffices to show that for each $k$ such that both $A_k$ and $B_k$ are nonempty, $\\mu(A_k) + \\mu(B_k) \\leq \\mu(A_k+B_k)$.\n For any $\\epsilon > 0$, there are shifts $A_{k, \\epsilon}, B_{k, \\epsilon}$ of $A_k, B_k$, such that $0 \\in A_{k, \\epsilon} \\cap B_{k, \\epsilon}$ and\n $\\mu(A_{k, \\epsilon} \\cap B_{k, \\epsilon}) < \\epsilon$.\n Then $A_k \\cup B_k \\subseteq A_k + B_k$ and $\\mu(A_k \\cup B_k) \\leq \\mu(A_k) + \\mu(B_k) - \\epsilon$. By taking $\\epsilon \\to 0$ we get $\\mu(A_k) + \\mu(B_k) \\leq \\mu(A_k+B_k)$.\n\\end{proof}\n\n\\begin{theorem}\n \\label{thm:prekopa_leindler_for_anderson}\n \\lean{prekopa_leindler_for_anderson}\n \\uses{thm:brunn_minkowski_onedim}\n Fix $\\lambda \\in (0,1)$. Let $f, g, h: \\mathbb{R}^n \\to \\mathbb{R}_{+}$ be non-negative, measurable functions satisfying $h(\\lambda x+(1-\\lambda)y) \\geq f(x)^{\\lambda}g(y)^{1-\\lambda}$ for all $x,y\\in \\mathbb{R}^n$. Then $\\int_{\\mathbb{R}^n}h(x)dx \\geq (\\int_{\\mathbb{R}^n}f(x)dx)^{\\lambda}(\\int_{\\mathbb{R}^n}g(x)dx)^{1-\\lambda}$.\n\\end{theorem}\n\\begin{proof}\n We first show the $n=1$ case.\n Let $L_h(t) = \\{x : h(x) \\geq t\\}$. Then by assumption,\n $L_h(t) \\supseteq \\lambda L_f(t) + (1-\\lambda)L_g(t)$.\n By Theorem~\\ref{thm:brunn_minkowski_onedim},\n \\begin{displaymath}\n \\mu(L_h(t)) \\geq \\mu(\\lambda L_h(t) + (1 - \\lambda)L_g(t))\n \\geq \\lambda\\mu(L_f(t)) + (1-\\lambda)\\mu(L_g(t)).\n \\end{displaymath}\n Since $f(x)$ is non-negative, by Fubini theorem,\n $\\int_{\\mathbb{R}} h(x)dx = \\int_{t \\geq 0} \\mu(L_h(t)) dt$. Then, we have that\n \\begin{displaymath}\n \\int_{\\mathbb{R}} h(x)dx = \\int_{t \\geq 0} \\mu(L_h(t)) dt\n \\geq \\lambda \\int_{t \\geq 0} \\mu(L_f(t)) dt + (1-\\lambda) \\int_{t \\geq 0} \\mu(L_g(t)) dt\n = \\lambda \\int_{\\mathbb{R}} f(x)dx + (1-\\lambda) \\int_{\\mathbb{R}} g(x)dx\n \\geq (\\int_{\\mathbb{R}} f(x)dx)^\\lambda(\\int_{\\mathbb{R}} g(x)dx)^(1-\\lambda)\n \\end{displaymath}\n where the last step uses concavity of $\\log(\\cdot)$.\n\n Now we prove the $n>1$ case using induction. For $x, y \\in \\mathbb{R}^{n-1}$, $\\alpha, \\beta \\in \\mathbb{R}$, we set $\\gamma = \\lambda\\alpha + (1-\\lambda)\\beta$. For any $c$, we define $h_c(x)=h(x,c)$ for $x \\in \\mathbb{R}^{n-1}$, i.e., setting the last coordinate to be $c$. Then\n \\begin{displaymath}\n h_\\gamma(\\lambda x + (1-\\lambda) y) = h(\\lambda(x,\\alpha)+(1-\\lambda)(y,\\beta))\n \\geq f(x,\\alpha)^{\\lambda} g(y,\\beta)^{1-\\lambda}\n \\geq f_\\alpha(x)^\\lambda g_\\beta(y)^{1-\\lambda}.\n \\end{displaymath}\n By the inductive case applied to $h_\\gamma, f_\\alpha, g_\\beta$, we obtain\n $\\int_{\\mathbb{R}^{n-1}}h_\\gamma(z)dz \\geq (\\int_{\\mathbb{R}^{n-1}}f_\\alpha(z)dz)^{\\lambda}(\\int_{\\mathbb{R}^{n-1}}g_\\beta(z)dz)^{1-\\lambda}$.\n We define $H(\\gamma) = \\int_{\\mathbb{R}^{n-1}}h_\\gamma(z)dz$ and $F(\\alpha)$, $G(\\beta)$ similarly. Then\n $H(\\lambda\\alpha+(1-\\lambda)\\beta) \\geq F(\\alpha)^\\lambda G(\\beta)^{1-\\lambda}$.\n So $H,F,G$ satisfy the hypothesis for $n=1$. So\n $\\int_{\\mathbb{R}} H(\\gamma)d\\gamma\n \\geq (\\int_{\\mathbb{R}} F(\\alpha)d\\alpha)^\\lambda(\\int_{\\mathbb{R}} G(\\beta)d\\beta)^(1-\\lambda)$.\n So the conclusion follows by Fubini's theorem.\n\\end{proof}\n\n\\begin{theorem}\n \\label{thm:brunn_minkowski_mul}\n \\lean{brunn_minkowski_mul}\n \\uses{thm:prekopa_leindler_for_anderson}\n If $A,B, A+B$ are nonempty Lebesgue measurable subsets of $\\mathbb{R}^n$ and $\\lambda \\in [0, 1]$, then $\\mu(\\lambda A + (1-\\lambda) B) \\geq \\mu(A)^\\lambda \\mu(B)^{1-\\lambda}$.\n\\end{theorem}\n\\begin{proof}\n Apply Theorem~\\ref{thm:prekopa_leindler_for_anderson} by taking $h = 1_{\\lambda A + (1-\\lambda) B}$, $f = 1_{A}$, $g = 1_{B}$.\n\\end{proof}\n\n\\begin{theorem}\n \\label{thm:brunn_minkowski}\n \\lean{brunn_minkowski}\n \\uses{thm:brunn_minkowski_mul}\n If $A,B, A+B$ are nonempty Lebesgue measurable subsets of $\\mathbb{R}^n$, then $\\mu(A + B)^{1/n} \\geq \\mu(A)^{1/n} + \\mu(B)^{1/n}$.\n\\end{theorem}\n\\begin{proof}\n Let $\\lambda = \\frac{\\mu(A)^{1/n}}{\\mu(A)^{1/n}+\\mu(B)^{1/n}}$. Then by\n Theorem~\\ref{thm:brunn_minkowski_mul}\n \\begin{displaymath}\n \\mu(A+B) = \\mu(\\lambda \\frac{A}{\\lambda} + (1-\\lambda) \\frac{B}{1-\\lambda})\n \\geq (\\frac{\\mu(A)}{\\lambda^n})^{\\lambda} (\\frac{\\mu(B)}{(1-\\lambda)^n})^{1-\\lambda}.\n \\end{displaymath}\n Substitute $\\lambda$ back and we get $\\mu(A+B) \\geq (\\mu(A)^{1/n}+\\mu(B)^{1/n})^n$.\n\\end{proof}\n\n\\begin{theorem}\n \\label{thm:anderson}\n \\lean{anderson}\n \\uses{thm:brunn_minkowski}\n Let $E \\subseteq \\mathbb{R}^n$ be convex, symmetric about the origin.\n Let $f$ be a nonnegative function on $\\mathbb{R}^n$ such that\n \\begin{enumerate}\n \\item $f(x)=f(-x)$ for all $x$.\n \\item $\\{x | f(x) \\geq u\\} = K_u$ is convex for every $u$ ($0 < u < \\infty$), and\n \\item $\\int_{\\mathbb{R}^n} f(x)dx<\\infty$.\n \\end{enumerate}\n Then\n \\begin{displaymath}\n \\int_E f(x+ky)dx \\geq \\int_E f(x+y)dx\n \\end{displaymath}\n for $0 \\leq k \\leq 1$.\n\\end{theorem}\n\\begin{proof}\n We need to show that\n \\begin{displaymath}\n \\int_{E+ky} f(x)dx \\geq \\int_{E+y} f(x)dx\n \\end{displaymath}\n where $E+y$ is the set $E$ translated by the vector $y$.\n For this, it suffices to show that\n \\begin{displaymath}\n \\mu((E+ky)\\cap K_u) \\geq \\mu((E+y)\\cap K_u)\n \\end{displaymath}\n for every $u$.\n Let $\\alpha = (1+k)/2$. Then\n $(E+ky)\\cap K_u \\supseteq \\alpha((E+y)\\cap K_u) + (1-\\alpha) ((E-y)\\cap K_u)$\n because $K_u$ is convex and\n $E+ky \\supseteq \\alpha(E+y)+(1-\\alpha)(E-y) = (\\alpha E + (1-\\alpha)E)+ky$.\n Thus,\n \\begin{displaymath}\n \\mu((E+ky)\\cap K_u) \\geq \\mu(\\alpha((E+y)\\cap K_u) + (1-\\alpha) ((E-y)\\cap K_u)).\n \\end{displaymath}\n By Theorem~\\ref{thm:brunn_minkowski},\n \\begin{displaymath}\n \\mu(\\alpha((E+y)\\cap K_u) + (1-\\alpha) ((E-y)\\cap K_u))\n \\geq (\\alpha \\mu((E+y)\\cap K_u)^{1/n} + (1-\\alpha) \\mu((E-y)\\cap K_u)^{1/n})^n\n = \\mu((E+y)\\cap K_u)\n \\end{displaymath}\n where the last equality is because $(E+y)\\cap K_u$ is the mirror image through the origin of $(E-y)\\cap K_u$, and therefore these two sets have the same volume.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\n\n\ntheorem anderson {n : ℕ} (hn : 0 < n) {c : ℝ} {y : RSpace n} {E : Set (RSpace n)} {f : (RSpace n) → ℝ}\n (E_symm : E = -E) (E_convex : Convex ℝ E)\n (f_nonneg : ∀ x, 0 ≤ f x) (f_symm : ∀ x, f (-x) = f x)\n (f_int : Integrable f volume) (f_unimodal : ∀ t, 0 ≤ t → Convex ℝ (f ⁻¹' (Ici t)))\n (hc : 0 ≤ c ∧ c ≤ 1) :\n ∫ x in E, f (x + y) ≤ ∫ x in E, f (x + c • y) := by sorry"} -{"project_name": "Apery", "name": "apery", "type": "theorem", "title": "Apery", "informal_statement": "TODO", "informal_proof": "\\chapter{Apery}\n\nThis section contains a (stub of a) proof of Apery's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Ap%C3%A9ry%27s_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Apery]\n \\label{thm:apery}\n \\lean{apery}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem apery : Irrational (riemannZeta 3).re := by sorry"} -{"project_name": "AztecDiamond", "name": "aztecDiamond_tiling", "type": "theorem", "title": "Aztec-Diamonds", "informal_statement": "TODO", "informal_proof": "\\chapter{Aztec-Diamonds}\n\nThis section contains a (stub of a) proof of the Aztec diamond theorem.\nSee \\url{https://en.wikipedia.org/wiki/Aztec_diamond} and \\url{https://link.springer.com/content/pdf/10.1023/A%3A1022420103267.pdf} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Aztec-Diamonds]\n \\label{thm:aztec-diamond}\n \\lean{aztecDiamond_tiling}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem aztecDiamond_tiling (n : ℕ) :\n Nat.card (DominoTiling (AztecDiamond n)) = 2 ^ ((n + 1).choose 2) := by sorry"} -{"project_name": "BanachMazur", "name": "banach_mazur", "type": "theorem", "title": "Banach-Mazur Theorem", "informal_statement": "If $X$ is a separable Banach space, then $X$ embeds isometrically into $C[0, 1]$.", "informal_proof": "\\chapter{Banach–Mazur theorem}\n\nThis section contains a proof of the Banach–Mazur theorem.\nSee \\url{https://en.wikipedia.org/wiki/Banach%E2%80%93Mazur_theorem} for more details.\n\n\\begin{lemma}\n \\label{lem:compact-hausdorff-coincide}\n \\lean{compact_hausdorff_coincide}\n If $K$ is a compact set for some topology $\\tau$, and $\\tau'$ is any Hausdorff topology on $K$ which is weaker than $\\tau$, then $\\tau$ and $\\tau'$ coincide.\n\\end{lemma}\n\\begin{proof}\n Suppose $A$ is a $\\tau$-closed subset of $K$. Then $A$ is $\\tau$-compact and so its continuous\n image in $(K, \\tau')$ under the identity mapping $id_K : (K, \\tau) \\tau (K, \\tau')$ is also\n compact, i.e., $A$ is $\\tau'$-compact. Since $\\tau'$ is Hausdorff, $A$ is $\\tau'$-closed.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:separable-implies-compact-metrizable-weak-star}\n \\lean{separable_implies_compact_metrizable_weak_star}\n \\uses{lem:compact-hausdorff-coincide}\n If $X$ is a separable Banach space then the closed ball of $X^*$, $B_{X^*}$, is compact and metrizable for the weak$^*$ topology.\n\\end{lemma}\n\\begin{proof}\n Take $(x_n)_{n=1}^{\\infty}$ dense in the unit ball $B_X$ of $X$. We define the topology $\\rho$\n induced on $X^*$ by convergence on each $x_n$. Precisely, a base of neighborhoods for $\\rho$ at\n a point $x_0^* \\in X^*$ is given by sets of the form\n \\begin{displaymath}\n V_\\eps (x_0^*: x_1, \\dots, x_N) = \\{ x^* \\in X^* : |x^*(x_n) - x_0^*(x_n)| < \\eps, n = 1, \\dots, N\\},\n \\end{displaymath}\n where $\\eps > 0$ and $N \\in \\mathbb{N}$. This topology is metrizable, and a metric inducing $\\rho$\n may be defined by\n \\begin{displaymath}\n d (x^*, y^*) = \\sum_{n=1}^{\\infty} 2^{-n} min (1, |x^*(x_n) - y^*(x_n)|), x^*, y^* \\in X^*.\n \\end{displaymath}\n $\\rho$ is Hausdorff and weaker than the weak$^*$ topology, so it coincides with the weak$^*$\n topology on the weak$^*$ compact set $B_{X^*}$.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:separable-banach-implies-embeds-cont}\n \\lean{separable_banach_implies_embeds_cont}\n \\uses{lem:separable-implies-compact-metrizable-weak-star}\n If $X$ is a separable Banach space, then there exists a compact, Hausdorff, metrizable space $K$ such that $X$ embeds isometrically into $C(K)$.\n\\end{lemma}\n\\begin{proof}\n Take $K = B_{X^*}$ with the relative weak$^*$ topology. By Lemma~\\ref{lem:separable-implies-compact-metrizable-weak-star}, $B_{X^*}$ is compact and metrizable. The\n isometric embedding of $X$ into $C(B_{X^*})$ is the embedding $x \\mapsto f_x$ where\n $f_x(x^*) = x^*(x)$ for all $x^* \\in B_{X^*}$.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:compact-metrizable-implies-embeds}\n \\lean{compact_metrizable_implies_embeds}\n If $K$ is a compact metrizable space, then $K$ embeds homeomorphically into $[0, 1]^{\\mathbb{N}}$.\n\\end{lemma}\n\\begin{proof}\n Being compact and metrizable, $K$ contains a countable dense set, $(s_n)_{n=1}^{\\infty}$. Let\n $\\rho$ be a metric on $K$ inducing its topology. Without loss of generality we can assume that\n $0 \\leq \\rho \\leq 1$. Now we define $\\theta : K \\to [0, 1]^{\\mathbb{N}}$ by\n $\\theta(x) = (\\rho(x, s_n))_{n=1}^{\\infty}$.\n\n $\\theta$ is continuous since the mapping $x \\mapsto \\rho(x, s_n)$ is continuous for each $n$.\n $\\theta$ is injective because if $x$ and $y$ are two different points in $K$ then there exists\n some $s_n$ such that $\\rho(x, s_n) < \\rho(y, s_n)$ (or the other way around and, therefore,\n $\\theta(x)$ and $\\theta(y)$ will differ in the $n$th-coordinate.\n\n Since $K$ is compact and $[0, 1]^{\\mathbb{N}}$ is Hausdorff, it follows that $\\theta$ maps $K$\n homeomorphically into its image.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:closed-subset-interval-implies-cont-embeds}\n \\lean{closed_subset_interval_implies_cont_embeds}\n If $E$ is a closed subset of $[0, 1]$, then $C(E)$ embeds isometrically into $C[0, 1]$.\n\\end{lemma}\n\\begin{proof}\n We define $A : C(E) \\to C[0, 1]$ which satisfies $Af|_E = f$ for all $f \\in C(E)$. Notice that\n $[0, 1] \\setminus E$ is a countable disjoint union of relatively open intervals. Thus, we define\n $Af$ to be an extension of $f$ which is affine on each such interval interior to $[0, 1]$ and is\n constant on any such interval containing an endpoint of $[0, 1]$.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:compact-metrizable-implies-cont-embeds}\n \\lean{compact_metrizable_implies_cont_embeds}\n \\uses{lem:compact-metrizable-implies-embeds}\n \\uses{lem:closed-subset-interval-implies-cont-embeds}\n If $K$ is a compact metrizable space, then $C(K)$ embeds isometrically into $C[0, 1]$.\n\\end{lemma}\n\\begin{proof}\n Let $\\Delta$ be the Cantor set. Let $\\psi : \\Delta \\tau [0, 1]^{\\mathbb{N}}$ be a continuous\n injection. By Lemma~\\ref{lem:compact-metrizable-implies-embeds}, we may assume $K$ is a closed\n subset of $[0, 1]^{\\mathbb{N}}$. Let $E = \\psi^{-1}(K)$. Then $E$ is a closed subset of $[0, 1]$.\n By lemma~\\ref{lem:closed-subset-interval-implies-cont-embeds}, $C(E)$ embeds isometrically into\n $C[0, 1]$. $C(K)$ embeds isometrically into $C(E)$ by $f \\mapsto f \\circ \\psi$. Therefore, $C(K)$\n embeds isometrically into $C[0, 1]$.\n\\end{proof}\n\n\\begin{theorem}[Banach-Mazur Theorem]\n \\label{thm:banach-mazur}\n \\lean{banach_mazur}\n \\uses{lem:separable-banach-implies-embeds-cont}\n \\uses{lem:compact-metrizable-implies-cont-embeds}\n If $X$ is a separable Banach space, then $X$ embeds isometrically into $C[0, 1]$.\n\\end{theorem}\n\\begin{proof}\n By Lemma~\\ref{lem:separable-banach-implies-embeds-cont}, there exists a compact, Hausdorff,\n metrizable space $K$ such that $X$ embeds isometrically into $C(K)$. For such $K$, by\n Lemma~\\ref{compact-metrizable-implies-cont-embeds}, $C(K)$ embeds isometrically into $C[0, 1]$.\n Therefore, $X$ embeds isometrically into $C[0, 1]$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen TopologicalSpace\n\n\ntheorem banach_mazur (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E]\n [SeparableSpace E] :\n Nonempty (E →ₗᵢ[ℝ] C(unitInterval, ℝ)) := by sorry"} -{"project_name": "BauerFike", "name": "bauer_fike", "type": "theorem", "title": "Bauer–Fike Theorem", "informal_statement": "Let $A \\in \\mathbb{C}^{n \\times n}$ be a diagonalizable matrix, and let $\\mu$ be an eigenvalue of $A + \\delta A$. Then there exists an eigenvalue $\\lambda \\in \\Lambda(A)$ such that:\n $$ |\\lambda - \\mu| \\le \\kappa_p(V) \\|\\delta A\\|_p $$\n where $V$ is the matrix of eigenvectors of $A$ and $\\kappa_p(V)$ is the condition number of $V$.", "informal_proof": "\\chapter{Bauer–Fike Theorem}\n\nThis section contains a proof of the Bauer–Fike Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Bauer%E2%80%93Fike_theorem} for more details.\n\n\\begin{definition}[Subordinate Matrix Norm Properties]\n \\label{def:Subordinate_Matrix_Norm}\n \\lean{IsSubordinateMatrixNorm}\n A matrix norm $\\|\\cdot\\|_p$ on the space of $n \\times n$ complex matrices is a norm that is consistent with a vector p-norm, defined as $\\|M\\|_p = \\sup_{x \\neq 0} \\frac{\\|Mx\\|_p}{\\|x\\|_p}$. For the purposes of this theorem, we require that the norm satisfies the following properties, in addition to being nonnegative and taking the value 1 on the identity matrix:\n\n \\begin{itemize}\n \\item \\textbf{Eigenvalue Bound:} For any matrix $M \\in \\mathbb{C}^{n \\times n}$, if $\\gamma$ is an eigenvalue of $M$, then $|\\gamma| \\le \\|M\\|_p$.\n \\item \\textbf{Sub-multiplicative Property:} For any two matrices $M_1, M_2 \\in \\mathbb{C}^{n \\times n}$, the norm satisfies $\\|M_1 M_2\\|_p \\le \\|M_1\\|_p \\|M_2\\|_p$.\n \\item \\textbf{Diagonal Matrix Norm:} For any diagonal matrix $D \\in \\mathbb{C}^{n \\times n}$ with diagonal entries $d_1, d_2, \\dots, d_n$, the norm satisfies $\\|D\\|_p = \\max_{i=1,\\dots,n} |d_i|$.\n \\end{itemize}\n\n\\end{definition}\n\n\\begin{definition}[Condition Number]\n \\label{def:Condition_Number}\n \\lean{conditionNumber}\n For an invertible matrix $V \\in \\mathbb{C}^{n \\times n}$, its condition number with respect to a norm is defined as $\\kappa_p(V) = \\|V\\| \\|V^{-1}\\|$.\n\\end{definition}\n\n\\begin{lemma}[Equivalent Eigenvalue Condition]\n \\label{lem:Equivalent_Eigenvalue_Condition}\n \\lean{equivalent_eigenvalue_condition}\n Let $A$ be a diagonalizable matrix with eigenvector matrix $V$ and eigenvalue matrix $\\Lambda$. Let $\\mu$ be an eigenvalue of the perturbed matrix $A + \\delta A$. If $\\mu \\notin \\Lambda(A)$, then $-1$ is an eigenvalue of the matrix $(\\Lambda - \\mu I)^{-1} V^{-1} \\delta A V$.\n\\end{lemma}\n\n\\begin{proof}\n Since $\\mu$ is an eigenvalue of $A + \\delta A$, the matrix $(A + \\delta A - \\mu I)$ is singular, so its determinant is zero. Using lemma \\ref{lem:Determinant_Invariance}:\n $$ 0 = \\det(A + \\delta A - \\mu I) = \\det(V^{-1}(A + \\delta A - \\mu I)V) $$\n $$ 0 = \\det(V^{-1}AV + V^{-1}\\delta A V - \\mu V^{-1}IV) = \\det(\\Lambda + V^{-1}\\delta A V - \\mu I) $$\n $$ 0 = \\det((\\Lambda - \\mu I) + V^{-1}\\delta A V) $$\n Since $\\mu \\notin \\Lambda(A)$, the diagonal matrix $(\\Lambda - \\mu I)$ is invertible. Using lemma \\ref{lem:Determinant_Multiplicative}:\n $$ 0 = \\det(\\Lambda - \\mu I) \\det(I + (\\Lambda - \\mu I)^{-1} V^{-1} \\delta A V) $$\n As $\\det(\\Lambda - \\mu I) \\neq 0$, we must have $\\det(I + (\\Lambda - \\mu I)^{-1} V^{-1} \\delta A V) = 0$.\n This implies that the matrix $M = I + (\\Lambda - \\mu I)^{-1} V^{-1} \\delta A V$ is singular and thus has an eigenvalue of $0$. Let $N = (\\Lambda - \\mu I)^{-1} V^{-1} \\delta A V$, so $M=I+N$. Since $0$ is an eigenvalue of $I+N$, it follows that $N$ must have an eigenvalue of $0-1 = -1$.\n\\end{proof}\n\n\n\\begin{lemma}[Norm of an Inverted Diagonal Matrix]\n \\label{lem:Norm_of_Inverted_Diagonal_Matrix}\n \\lean{norm_inverted_diagonal}\n \\uses{def:Subordinate_Matrix_Norm}\n Let $\\Lambda$ be a diagonal matrix with diagonal entries $\\lambda_1, \\dots, \\lambda_n$. For any scalar $\\mu$ such that $\\lambda_i \\neq \\mu$ for all $i$, the p-norm of the inverse of $(\\Lambda - \\mu I)$ is given by:\n $$ \\|(\\Lambda - \\mu I)^{-1}\\|_p = \\frac{1}{\\min_{i} |\\lambda_i - \\mu|} $$\n\\end{lemma}\n\n\\begin{proof}\n The matrix $(\\Lambda - \\mu I)^{-1}$ is a diagonal matrix with diagonal entries $(\\lambda_i - \\mu)^{-1}$ for $i=1, \\dots, n$. Then\n $$ \\|(\\Lambda - \\mu I)^{-1}\\|_p = \\max_{i} \\left| \\frac{1}{\\lambda_i - \\mu} \\right| = \\frac{1}{\\min_{i} |\\lambda_i - \\mu|} $$\n This concludes the proof.\n\\end{proof}\n\n\\begin{theorem}[Bauer–Fike Theorem]\n \\label{thm:Bauer-Fike_Theorem}\n \\lean{bauer_fike}\n \\uses{def:Subordinate_Matrix_Norm}\n \\uses{def:Condition_Number}\n \\uses{lem:Equivalent_Eigenvalue_Condition}\n \\uses{lem:Norm_of_Inverted_Diagonal_Matrix}\n Let $A \\in \\mathbb{C}^{n \\times n}$ be a diagonalizable matrix, and let $\\mu$ be an eigenvalue of $A + \\delta A$. Then there exists an eigenvalue $\\lambda \\in \\Lambda(A)$ such that:\n $$ |\\lambda - \\mu| \\le \\kappa_p(V) \\|\\delta A\\|_p $$\n where $V$ is the matrix of eigenvectors of $A$ and $\\kappa_p(V)$ is the condition number of $V$.\n\\end{theorem}\n\n\\begin{proof}\n If $\\mu$ is an eigenvalue of $A$, we can choose $\\lambda = \\mu$, so $|\\lambda - \\mu| = 0$. Since $\\kappa_p(V) \\ge 1$ by lemma \\ref{lem:Condition_Number_Lower_Bound} and $\\|\\delta A\\|_p \\ge 0$, the inequality $0 \\le \\kappa_p(V) \\|\\delta A\\|_p$ holds trivially.\n\n If $\\mu$ is not an eigenvalue of $A$, by lemma \\ref{lem:Equivalent_Eigenvalue_Condition}, we know that $-1$ is an eigenvalue of the matrix $M = (\\Lambda - \\mu I)^{-1} V^{-1} \\delta A V$.\n\n Using the property of subordinate matrix norms from definition \\ref{def:Subordinate_Matrix_Norm}, the magnitude of any eigenvalue is bounded by the norm of the matrix:\n $$ 1 = |-1| \\le \\|M\\|_p = \\|(\\Lambda - \\mu I)^{-1} V^{-1} \\delta A V\\|_p $$\n By the sub-multiplicative property of the norm and definition \\ref{def:Condition_Number}:\n $$ 1 \\le \\|(\\Lambda - \\mu I)^{-1}\\|_p \\|V^{-1}\\|_p \\|\\delta A\\|_p \\|V\\|_p = \\|(\\Lambda - \\mu I)^{-1}\\|_p \\kappa_p(V) \\|\\delta A\\|_p $$\n Applying lemma \\ref{lem:Norm_of_Inverted_Diagonal_Matrix}:\n $$ 1 \\le \\left(\\frac{1}{\\min_{\\lambda \\in \\Lambda(A)} |\\lambda - \\mu|}\\right) \\kappa_p(V) \\|\\delta A\\|_p $$\n Rearranging this inequality gives the desired result:\n $$ \\min_{\\lambda \\in \\Lambda(A)} |\\lambda - \\mu| \\le \\kappa_p(V) \\|\\delta A\\|_p $$\n This implies the existence of a $\\lambda \\in \\Lambda(A)$ satisfying the theorem's inequality.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Matrix BigOperators\n\n\ntheorem bauer_fike\n (A : Matrix (Fin n) (Fin n) ℂ) (V Λ δA : Matrix (Fin n) (Fin n) ℂ)\n (hV : IsUnit (V.det)) (hΛ : Λ.IsDiag) (hA : A = V * Λ * V⁻¹)\n (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (hnorm : IsSubordinateMatrixNorm norm)\n (μ : ℂ) (hμ : Module.End.HasEigenvalue (toLin' (A + δA)) μ) :\n ∃ i : Fin n, ‖Λ i i - μ‖ ≤ conditionNumber norm V * norm δA := by sorry"} -{"project_name": "BeckmanQuarlesTheorem", "name": "beckmann_quarles", "type": "theorem", "title": "Beckman–Quarles theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Beckman–Quarles theorem}\n\nThis section contains a (stub of a) proof of the Beckman–Quarles theorem.\nSee \\url{https://en.wikipedia.org/wiki/Beckman%E2%80%93Quarles_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Beckman–Quarles theorem]\n \\label{thm:beckman-quarles-theorem}\n \\lean{beckmann_quarles}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem beckmann_quarles {d : ℕ} {f : EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)}\n (h : ∀ x y : EuclideanSpace ℝ (Fin d), dist x y = 1 → dist (f x) (f y) = 1) :\n Isometry f := by sorry"} -{"project_name": "BergeTheorem", "name": "SimpleGraph.Subgraph.IsMatching.berge", "type": "theorem", "title": "Berge's theorem", "informal_statement": "Let \\(G\\) be a finite graph and \\(M\\) be a matching in \\(G\\).\n Then \\(M\\) is a matching of maximal cardinality if and only if there is no \\(M\\)-augmenting path in \\(G\\).", "informal_proof": "\\chapter{Berge's theorem}\n\nThis section contains a (stub of a) proof of Berge's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Berge's_theorem} for more details.\n\n\\begin{definition}[Augmenting path]\n \\label{def:augmenting-path}\n \\lean{SimpleGraph.Subgraph.IsAugmentingPath}\n Let \\(G\\) be a finite graph and \\(M\\) be a matching in \\(G\\).\n An \\emph{\\(M\\)-augmenting path} is a path in \\(G\\) that starts and ends with unmatched vertices, and whose edges alternate between edges not in \\(M\\) and edges in \\(M\\).\n\\end{definition}\n\n\\begin{theorem}[Berge's theorem, forward direction]\n \\label{theorem:berge-forward}\n \\lean{SimpleGraph.Subgraph.IsMatching.not_maximal_of_augmentingPath}\n \\uses{def:augmenting-path}\n Let \\(G\\) be a finite graph and \\(M\\) be a matching in \\(G\\).\n If there is an \\(M\\)-augmenting path in \\(G\\), then \\(M\\) is not a matching of maximal cardinality.\n\\end{theorem}\n\n\\begin{proof}\n Let \\(P\\) be an \\(M\\)-augmenting path in \\(G\\).\n We can construct a new matching \\(M'\\) by taking the symmetric difference of \\(M\\) and the edges of \\(P\\).\n Since \\(P\\) starts and ends with unmatched vertices, the number of edges in \\(M'\\) is one more than the number of edges in \\(M\\).\n Therefore, \\(M'\\) is a matching of larger cardinality than \\(M\\), which means that \\(M\\) is not a matching of maximal cardinality.\n\\end{proof}\n\n\\begin{lemma}[symmetric difference of matchings]\n \\label{lemma:symmetric-difference-matchings}\n \\lean{SimpleGraph.isAlternating_symmDiff_of_isMatching}\n Let \\(G\\) be a finite graph and \\(M\\) and \\(M'\\) be two matchings in \\(G\\).\n Then the graph formed by the edges in the symmetric difference \\(M \\oplus M'\\) consists of a union of paths and cycles where edges alternate between those in \\(M\\) and those in \\(M'\\).\n\\end{lemma}\n\n\\begin{proof}\n Each vertex in the graph formed by \\(M \\oplus M'\\) has degree at most 2, since it can be incident to at most one edge from \\(M\\) and at most one edge from \\(M'\\).\n Therefore, the connected components of this graph are either paths or cycles.\n Moreover, since \\(M\\) and \\(M'\\) are matchings, the edges in these paths and cycles cannot be adjacent to each other if they belong to the same matching, which means that the edges must alternate between those in \\(M\\) and those in \\(M'\\).\n\\end{proof}\n\n\\begin{theorem}[Berge's theorem, backward direction]\n \\label{theorem:berge-backward}\n \\lean{SimpleGraph.Subgraph.IsMatching.maximal_of_no_augmentingPath}\n \\uses{lemma:symmetric-difference-matchings, def:augmenting-path}\n Let \\(G\\) be a finite graph and \\(M\\) be a matching in \\(G\\).\n If there is no \\(M\\)-augmenting path in \\(G\\), then \\(M\\) is a matching of maximal cardinality.\n\\end{theorem}\n\n\\begin{proof}\n Assume for the sake of contradiction that \\(M\\) is not a matching of maximal cardinality.\n Then there exists a matching \\(M'\\) in \\(G\\) such that \\(|M'| > |M|\\).\n Consider the symmetric difference \\(M \\oplus M'\\), which consists of edges that are in either \\(M\\) or \\(M'\\) but not in both.\n The graph formed by the edges in \\(M \\oplus M'\\) consists of paths and cycles where edges alternate between those in \\(M\\) and those in \\(M'\\), as stated in Lemma~\\ref{lemma:symmetric-difference-matchings}.\n Cycles contain an equal number of edges from \\(M\\) and \\(M'\\), so they do not contribute to the difference in cardinality between \\(M\\) and \\(M'\\).\n Since \\(|M'| > |M|\\), there must be at least one path in this graph that starts and ends with unmatched vertices (with respect to \\(M\\)).\n This path is an \\(M\\)-augmenting path, which contradicts our assumption that there are no \\(M\\)-augmenting paths in \\(G\\).\n Therefore, \\(M\\) must be a matching of maximal cardinality.\n\\end{proof}\n\n\\begin{theorem}[Berge's theorem]\n \\label{theorem:berge}\n \\lean{SimpleGraph.Subgraph.IsMatching.berge}\n \\uses{theorem:berge-forward, theorem:berge-backward, def:augmenting-path}\n Let \\(G\\) be a finite graph and \\(M\\) be a matching in \\(G\\).\n Then \\(M\\) is a matching of maximal cardinality if and only if there is no \\(M\\)-augmenting path in \\(G\\).\n\\end{theorem}\n\n\\begin{proof}\n This follows directly from the earlier proofs of the forward and backward directions Theorem~\\ref{theorem:berge-forward} and Theorem~\\ref{theorem:berge-backward}.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen SimpleGraph SimpleGraph.Subgraph\n\nopen scoped symmDiff\n\n\ntheorem SimpleGraph.Subgraph.IsMatching.berge\n [Fintype V] [DecidableEq V] {M : G.Subgraph} (hM : M.IsMatching) :\n (∀ M' : G.Subgraph, M'.IsMatching → M'.edgeSet.ncard ≤ M.edgeSet.ncard) ↔\n ∀ {u v : V} (p : G.Walk u v), ¬M.IsAugmentingPath p := by sorry"} -{"project_name": "BondyTheorem", "name": "bondy", "type": "theorem", "title": "Bondy's theorem", "informal_statement": "Let $A_0, \\dots, A_{n-1} \\subseteq [n]$ be distinct sets.\n Then there exists a set $S \\subseteq [n]$ of size $n-1$ such that the sets $A_0 \\cap S, \\dots, A_{n-1} \\cap S$ are distinct.", "informal_proof": "\\chapter{Bondy's theorem}\n\nThis section contains a (stub of a) proof of Bondy's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Bondy's_theorem} for more details.\n\n\\begin{definition}[Hypercube Graph]\n \\label{def:hypercube-graph}\n \\lean{hypercubeGraph}\n The \\emph{hypercube graph} $Q_n$ is the graph whose vertices are the subsets of $[n]$, and two vertices $A, B$ are adjacent if and only if $|A \\triangle B| = 1$.\n\\end{definition}\n\n\\begin{lemma}\n \\label{lem:parallel-edges-hypercube-graph}\n \\lean{hypercube_cycle_has_parallel_edges}\n \\uses{def:hypercube-graph}\n Any cycle in $Q_n$ has two distinct edges that are parallel.\n\\end{lemma}\n\n\\begin{proof}\n Let $C$ be a cycle in $Q_n$, and let $v_1, \\dots, v_k$ be the vertices of $C$ in order.\n Let $i$ be the index along which $v_0, v_1$ differ, and let $v_j$ be the next vertex in $c$ which is equal to $v_0$ along index $i$.\n Then the edges $v_0 v_1$ and $v_{j-1} v_j$ are parallel.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:acyclic-graph-vertices-edges-components}\n \\lean{acyclic_card_eq_edges_add_components}\n An acyclic graph has a number of vertices equal to the sum of the number of edges and the number of connected components.\n\\end{lemma}\n\n\\begin{proof}\n We proceed by induction on the number of edges.\n If there are no edges, then the number of vertices is equal to the number of connected components, and we are done.\n Otherwise, let $e$ be an edge, and let $G'$ be the graph obtained by removing $e$ from $G$.\n Then $G'$ has one more connected component than $G$, and one less edge than $G$, so the number of vertices in $G'$ is equal to the number of edges in $G$ plus the number of connected components in $G$.\n Since $G$ is acyclic, it has at least one edge, so the number of vertices in $G$ is equal to the number of edges in $G$ plus the number of connected components in $G$.\n\\end{proof}\n\n\\begin{theorem}[Bondy's theorem]\n \\label{thm:bondy-theorem}\n \\lean{bondy}\n \\uses{lem:parallel-edges-hypercube-graph, lem:acyclic-graph-vertices-edges-components}\n Let $A_0, \\dots, A_{n-1} \\subseteq [n]$ be distinct sets.\n Then there exists a set $S \\subseteq [n]$ of size $n-1$ such that the sets $A_0 \\cap S, \\dots, A_{n-1} \\cap S$ are distinct.\n\\end{theorem}\n\n\\begin{proof}\n Suppose for contradiction that for every $S$ of size $n-1$, i.e. for every $S = {0, 1, ..., n-1} \\ {k}$, there exist $i ≠ j$ such that $(S ∩ A_i) = (S ∩ A_j)$.\n This would make an induced subgraph of $n$ edges on the boolean hypercube with one edge in every orientation\n But such a subgraph must be a forest, by Lemma~\\ref{lem:parallel-edges-hypercube-graph}.\n By Lemma~\\ref{lem:acyclic-graph-vertices-edges-components}, the number of vertices in this subgraph is equal to the number of edges plus the number of connected components, which is at least $n + 1$.\n Thus the number of vertices of the subgraph is at least $n+1$, a contradiction to the claim that there are only $n$ vertices (the $A_i$'s).\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set Finset\n\n\ntheorem bondy {n : ℕ} (hn : 0 < n) {A : Fin n → Finset (Fin n)}\n (h_disj : ∀ i j : Fin n, i ≠ j → A i ≠ A j) :\n ∃ S : Finset (Fin n),\n S.card + 1 = n ∧\n ∀ i j : Fin n, i ≠ j → (S) ∩ A i ≠ (S) ∩ A j := by sorry"} -{"project_name": "BorsukUlamTheorem", "name": "borsuk_ulam", "type": "theorem", "title": "Borsuk–Ulam theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Borsuk–Ulam theorem}\n\nThis section contains a (stub of a) proof of the Borsuk–Ulam theorem.\nSee \\url{https://en.wikipedia.org/wiki/Borsuk–Ulam_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Borsuk–Ulam theorem]\n \\label{thm:borsuk-ulam-theorem}\n \\lean{borsuk_ulam}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Metric\n\n\ntheorem borsuk_ulam (n : ℕ) {g : UnitNDimensionalSphere n → Fin n → ℝ}\n (hg : ∀ x : UnitNDimensionalSphere n, g (-x) = g x) (cont : Continuous g):\n ∃ x : UnitNDimensionalSphere n, g x = 0 := by sorry"} -{"project_name": "BrascampLieb", "name": "upperBound", "type": "theorem", "title": "Upper bound", "informal_statement": "Let $(\\mathcal{D},\\mathcal{R}, T)$ be a localised regularised Brascamp-Lieb datum, let $\\vec{\\alpha} \\in \\R_{>0}^J$ and $\\beta \\in \\R_{\\geq 0}$. Assume $\\mathcal{D}$ is $(\\vec{\\alpha}, \\beta)$-perceptive and $\\mathrm{rk}_{\\alpha_j}(\\ell_j) = \\dim H_j$ for each $j \\in J$.\nThen, writing $d = \\dim H$, we have\n\\begin{equation}\\label{eq:rlub}\n\\mathrm{BL}_{\\mathbf{g}}(\\mathcal{D}, \\mathcal{R}, T)\n\\leq d^{\\frac{\\mathrm{Ac}(\\mathcal{D})}{2}} \\mathcal{E}(\\mathcal{D}) \\prod_{j \\in J} \\alpha_j^{-q_j \\dim H_j} N(\\mathcal{D}, \\mathcal{R}, T)^{\\frac{\\mathrm{Ac}(\\mathcal{D})-d+\\beta}{2}} \\norm{T^{-1}}^{\\frac{\\beta}{2}}.\n\\end{equation}\nwhere $\\mathcal{E}(\\mathcal{D}) = \\prod_{j \\in J} q_j^{-q_j \\dim H_j / 2}$ and $N(\\mathcal{D}, \\mathcal{R}, T) = \\norm{T + \\sum_{j} q_j \\ell^* R_j \\ell_j}$.", "informal_proof": "\\chapter{The Brascamp-Lieb Inequalities}\n\nThis section contains a proof of results from the paper \"Effective Brascamp-Lieb inequalities\n\" by Timothée Bénard and Weikun He.\nSee \\url{https://arxiv.org/abs/2511.11091} for more details.\n\n\\section{Brascamp-Lieb data}\n\nA \\emph{Brascamp-Lieb datum} is a tuple\n$$\\mathcal{D}=(H, (H_{j})_{j\\in J}, (\\ell_j)_{j \\in J}, (q_{j})_{j \\in J}) $$\nwhere $J$ is a finite index set, $H$ and $H_{j}$ are finite dimensional real Hilbert spaces (a.k.a. Euclidean spaces), $\\ell_{j} : H \\to H_{j}$ are\nlinear maps from $H$ to $H_{j}$, and $q_{j}>0$ are positive real numbers. Below, we simply write\n$$\\mathcal{D}=((\\ell_j)_{j \\in J}, (q_{j})_{j \\in J})$$\nand keep implicit the notation $H,H_{j}$.\n\nA localised regularised Brascamp-Lieb datum is a triple $(\\mathcal{D}, \\mathcal{R}, T)$ where\n$\\mathcal{D} = ((\\ell_j)_{j \\in J}, (q_j)_{j \\in J})$ is a Brascamp-Lieb datum,\n$\\mathcal{R} = (R_{j})_{j \\in J}$ is a collection such that each $R_j$ is a positive definite symmetric endomorphism of $H_j$\nand $T$ is a positive definite symmetric endomorphism of $H$.\n\n\n\\section{Brascamp-Lieb constants}\n\nThe \\emph{gaussian Brascamp-Lieb constant} of $\\mathcal{D}$ is\n\\begin{equation*}\n\\mathrm{BL}_{\\mathbf{g}}(\\mathcal{D}) = \\sup_{A_{j}} \\left(\\frac{ \\prod_{j}(\\det A_{j})^{q_{j}}}{\\det(\\sum_{j} q_{j} \\ell_{j}^*A_{j}\\ell_{j} )}\\right)^{1/2},\n\\end{equation*}\nwhere $A_j$ ranges through all positive definite symmetric endomorphisms of $H_j$, for each $j \\in J$.\n\n\nThe \\emph{gaussian localised regularised Brascamp-Lieb constant} of $(\\mathcal{D}, \\mathcal{R}, T)$ is\n\\begin{equation*}\n\\mathrm{BL}_{\\mathbf{g}}(\\mathcal{D}, \\mathcal{R}, T)\n= \\sup_{0 \\alpha$ for $1 \\leq i \\leq r$ while $\\sigma_i \\leq \\alpha$ for $r + 1 \\leq i \\leq k$.\n\nOn the one hand, for $E_0 := \\mathrm{Span}\\{\\ell w_1, \\dotsc, \\ell w_r \\}$, we have\n\\(\n\\ell(B_1^W) \\subset B^{H'}_\\alpha + E_0,\n\\)\nleading to $\\widetilde r \\leq \\dim E_0 = r $.\n\nOn the other hand, we observe that\n$$\\ell(B^W_{1})\\supseteq \\ell(B^{\\mathrm{Span}(w_{1}, \\dots, w_{r})}_{1}) \\supseteq B^{E_{0}}_{\\sigma_{r}}.$$\nAs $\\sigma_{r}>\\alpha$, we obtain that $\\ell(B^W_{1})$ cannot be included in $B_\\alpha^{H'} + E$ for some $E\\in \\mathrm{Gr}(H')$ with dimension $\\dim E<\\dim E_{0}$. Therefore $\\widetilde{r}\\geq r$.\n\\end{proof}\n\n\n\\begin{lemma}\n\\label{lem:Choleski}\n\\lean{LinearMap.choleski_det_bound}\nLet $H$ be a Euclidean space, let $Q\\in \\mathrm{End}(H)$ be a positive semi-definite symmetric endomorphism, let $(\\eps_{1}, \\dots, \\eps_{d})$ be a basis of $H$.\nThen\n\\begin{equation*}\n\\det Q \\leq \\|\\eps_{1}\\wedge \\dots \\wedge \\eps_{d}\\|^{-2}\\prod_{k=1}^d \\langle Q \\eps_{k}, \\eps_{k}\\rangle.\n\\end{equation*}\n\\end{lemma}\n\n\\begin{proof}\nIf $(\\eps_{1}, \\dots, \\eps_{d})$ is an orthonormal basis, then $\\|\\eps_{1}\\wedge \\dots \\wedge \\eps_{d}\\|=1$ and the result follows by the Choleski decomposition, which states that $Q=F^*F$ where $F$ is upper triangular in the basis $(\\eps_{1}, \\dots, \\eps_{d})$. For the general case, we write $(\\eps_{1}, \\dots, \\eps_{d})=A(\\eps'_{1}, \\dots, \\eps'_{d})$ where $A\\in \\mathrm{GL}_{d}(\\R)$ and the $\\eps'_{i}$ form an orthonormal basis. We then have\n$$\\det Q = (\\det A)^{-2}\\det A^*Q A \\leq \\norm{\\eps_{1}\\wedge \\dots \\wedge \\eps_{d}}^{-2} \\prod_{k=1}^d \\langle A^*Q A \\eps'_{k}, \\eps'_{k}\\rangle,$$\nhence the result.\n\\end{proof}\n\n\\section{Additional Formalization Lemmas}\n\nThe following lemmas are added to support the formalization of the main theorem in Mathlib.\n\n\n\\begin{definition}[Greedy Index Set]\n\\label{def:greedy_sets}\n\\lean{BrascampLieb.greedy_index_set}\nLet $(e_1, \\dots, e_d)$ be a fixed basis of $H$. For a linear map $\\ell: H \\to H'$ and a threshold $\\epsilon > 0$, we define the \\emph{greedy index set} $I \\subseteq \\{1, \\dots, d\\}$ inductively from $d$ down to $1$.\nLet $I_{>k} = I \\cap \\{k+1, \\dots, d\\}$.\nWe include $k \\in I$ if and only if\n$$\\mathrm{dist}(\\ell e_k, \\mathrm{span}\\{\\ell e_i \\mid i \\in I_{>k}\\}) \\ge \\epsilon$$\nwhere $\\mathrm{dist}(v, S)$ denotes the orthogonal distance from vector $v$ to subspace $S$.\n\\end{definition}\n\n\\begin{lemma}[Properties of Greedy Sets]\n\\label{lem:greedy_set_properties}\n\\lean{BrascampLieb.greedy_index_set_volume_bound, BrascampLieb.essRank_le_ncard_inter_greedy}\n\\uses{def:greedy_sets, lem:essential_rank_eq}\nLet $I_j$ be the greedy index set constructed for $\\ell_j$ with respect to the basis $(e_k)_k$ and threshold $\\epsilon = 1/\\sqrt{d}$.\n\\begin{enumerate}\n \\item \\textbf{Volume Lower Bound:} The wedge product of the images of the selected basis vectors satisfies:\n $$\\| \\bigwedge_{k \\in I_j} \\ell_j e_k \\| \\ge \\epsilon^{|I_j|}$$\n \\item \\textbf{Rank Control:} For any $k \\in \\{0, \\dots, d-1\\}$, let $V_{>k} = \\mathrm{span}\\{e_{k+1}, \\dots, e_d\\}$. Then the $1$-essential rank of $\\ell_j$ restricted to $V_{>k}$ is bounded by the number of selected indices in the tail:\n $$\\mathrm{rk}_{1}(\\ell_j \\mid V_{>k}) \\le |I_j \\cap (k, d]|$$\n provided $\\epsilon = 1/\\sqrt{d}$ (since $\\sum_{i=1}^d \\epsilon^2 = 1$).\n\\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n1. By the definition of the greedy set, for every $k \\in I_j$, the vector $\\ell_j e_k$ has a component orthogonal to the span of the previously selected vectors (those with index $> k$) with norm at least $\\epsilon$. The norm of the wedge product is the product of these orthogonal heights, hence $\\ge \\epsilon^{|I_j|}$.\n\n2. For any vector $v \\in V_{>k}$ with $\\|v\\| \\le 1$, we can expand $v = \\sum_{m=k+1}^d c_m e_m$. The image $\\ell_j v$ can be approximated by elements in the span of $\\ell_j(\\{e_i \\mid i \\in I_j, i > k\\})$. Specifically, for any $m \\notin I_j$ ($m > k$), $\\ell_j e_m$ is within distance $\\epsilon$ of the span of $\\ell_j(I_j \\cap (m, d])$. Summing these approximations (and noting $\\sum c_m^2 \\le 1$ and $\\epsilon = 1/\\sqrt{d}$), one can show the image of the unit ball of $V_{>k}$ lies within a radius 1 neighborhood of the subspace spanned by $\\{\\ell_j e_i \\mid i \\in I_j, i > k\\}$. By Lemma \\ref{lem:essential_rank_eq}, the 1-essential rank is at most the dimension of this subspace, which is $|I_j \\cap (k, d]|$.\n\\end{proof}\n\n\\begin{lemma}[Hadamard Determinant Bound]\n\\label{lem:hadamard_bound}\n\\lean{LinearMap.choleski_det_bound}\n\\uses{lem:Choleski}\nLet $A$ be a positive definite operator on $H_j$, and let $v_1, \\dots, v_m$ be linearly independent vectors in $H_j$. Then\n$$\\det A \\le \\| v_1 \\wedge \\dots \\wedge v_m \\|^{-2} \\prod_{k=1}^m \\langle A v_k, v_k \\rangle$$\nwhere $m = \\dim H_j$.\n\\end{lemma}\n\n\\begin{proof}\nThis is a direct restatement of Lemma \\ref{lem:Choleski} applied to the space $H_j$ with the specific basis vectors $v_k = \\ell_j e_{i_k}$ for $i_k \\in I_j$.\n\\end{proof}\n\n\\begin{lemma}[Telescoping Product Inequality]\n\\label{lem:telescoping_eigenvalues}\n\\lean{BrascampLieb.eigenvalue_telescoping'}\nLet $\\lambda_1 \\ge \\dots \\ge \\lambda_d > 0$ be a non-increasing sequence. Let $c_{j,k} \\in \\{0, 1\\}$ be indicators such that for each $k$, $\\sum_{j \\in J} q_j \\sum_{m=k+1}^d c_{j,m} \\ge d - k - \\beta$. Then:\n$$\\prod_{j \\in J} \\left( \\prod_{k=1}^d \\lambda_k^{c_{j,k}} \\right)^{q_j} \\le \\lambda_1^{\\sum q_j |I_j| - d + \\beta} \\lambda_d^{-\\beta} \\left( \\prod_{k=1}^d \\lambda_k \\right)$$\nwhere $|I_j| = \\sum_k c_{j,k}$.\n\\end{lemma}\n\n\\begin{proof}\nLet $P$ be the product on the LHS. We can rewrite $P = \\prod_{k=1}^d \\lambda_k^{p_k}$ where $p_k = \\sum_{j \\in J} q_j c_{j,k}$.\nWe normalize by the determinant $\\prod \\lambda_k$:\n$$\\frac{P}{\\prod \\lambda_k} = \\prod_{k=1}^d \\lambda_k^{p_k - 1}$$\nUsing Abel summation (telescoping) on the exponents with $\\mu_k = \\ln \\lambda_k$:\n$$\\sum_{k=1}^d (p_k - 1) \\mu_k = (S_d)\\mu_d + \\sum_{k=1}^{d-1} S_k (\\mu_k - \\mu_{k+1})$$\nwhere $S_k = \\sum_{m=1}^k (p_m - 1)$.\nAlternatively, working from the tail sums as in the main proof:\nLet $T_k = \\sum_{m=k+1}^d p_m$. The condition given is $T_k \\ge d - k - \\beta$.\nNote that $\\sum_{m=1}^d (p_m - 1) = \\sum p_m - d$.\nThe exponent of $\\lambda_1$ will collect the total weight. The crucial step is using the monotonicity $\\lambda_k \\ge \\lambda_{k+1}$ (so $\\ln \\lambda_k - \\ln \\lambda_{k+1} \\ge 0$) to bound the telescoping sum using the lower bounds on the tail sums of weights.\n\\end{proof}\n\n\n\\section{Effective estimates}\n\n\nThe following is a reformulation of [Theorem 1.4, Bénard-He].\n\\begin{theorem}[Upper bound]\n\\label{thm:BL_local_regular_upper_bound}\n\\lean{BrascampLieb.upperBound}\n\\uses{def-ess-rank, def-acuity, def-alpha-beta-percep, lem:essential_rank_eq, lem:Choleski, lem:greedy_set_properties, lem:hadamard_bound, lem:telescoping_eigenvalues}\nLet $(\\mathcal{D},\\mathcal{R}, T)$ be a localised regularised Brascamp-Lieb datum, let $\\vec{\\alpha} \\in \\R_{>0}^J$ and $\\beta \\in \\R_{\\geq 0}$. Assume $\\mathcal{D}$ is $(\\vec{\\alpha}, \\beta)$-perceptive and $\\mathrm{rk}_{\\alpha_j}(\\ell_j) = \\dim H_j$ for each $j \\in J$.\nThen, writing $d = \\dim H$, we have\n\\begin{equation}\\label{eq:rlub}\n\\mathrm{BL}_{\\mathbf{g}}(\\mathcal{D}, \\mathcal{R}, T)\n\\leq d^{\\frac{\\mathrm{Ac}(\\mathcal{D})}{2}} \\mathcal{E}(\\mathcal{D}) \\prod_{j \\in J} \\alpha_j^{-q_j \\dim H_j} N(\\mathcal{D}, \\mathcal{R}, T)^{\\frac{\\mathrm{Ac}(\\mathcal{D})-d+\\beta}{2}} \\norm{T^{-1}}^{\\frac{\\beta}{2}}.\n\\end{equation}\nwhere $\\mathcal{E}(\\mathcal{D}) = \\prod_{j \\in J} q_j^{-q_j \\dim H_j / 2}$ and $N(\\mathcal{D}, \\mathcal{R}, T) = \\norm{T + \\sum_{j} q_j \\ell^* R_j \\ell_j}$.\n\\end{theorem}\n\n\\begin{proof}\nWe first reduce to the case where $\\alpha_j = 1$ for all $j \\in J$. Indeed, note that for each $j \\in J$ and every $W \\in \\mathrm{Gr}(H)$, we have\n$\\mathrm{rk}_1( \\alpha_j^{-1} \\ell_j \\mid W) = \\mathrm{rk}_{\\alpha_j}(\\ell_j \\mid W)$.\nTherefore the datum $\\mathcal{D}':=\\bigl((\\alpha_j^{-1} \\ell_j)_j, (q_j)_j\\bigr)$ is $((1,\\dotsc,1), \\beta)$-perceptive and satisfies $\\mathrm{rk}_1( \\alpha_j^{-1} \\ell_j)=\\dim H_{j}$ for all $j$.\nBy a simple change of variables, we also have\n$$\\mathrm{BL}_{\\mathbf{g}}(\\mathcal{D}, \\mathcal{R}, T)=\\prod_{j\\in J} \\alpha_{j}^{-q_{j}\\dim H_{j}} \\mathrm{BL}_{\\mathbf{g}}(\\mathcal{D}', \\mathcal{R}', T)$$\n where $\\mathcal{R}'=(\\alpha_{j}^2 R_{j})_{j\\in J}$, and $N(\\mathcal{D}, \\mathcal{R}, T)=N(\\mathcal{D}', \\mathcal{R}', T)$.\nIt is thus sufficient to prove the theorem for $\\mathcal{D}=\\mathcal{D}'$, whence the reduction to $\\vec{\\alpha}=(1,\\dotsc,1)$.\n\nInject the definition and taking the squares, our goal is to show\n\\begin{equation}\n\\label{eq:rlub1}\n\\frac{\\prod_{j\\in J} (\\det A_{j})^{q_{j}} }{\\det(T + \\sum_{j \\in J} q_j \\ell_j^* A_{j}\\ell_j)}\\leq d^{\\mathrm{Ac}(\\mathcal{D})} \\mathcal{E}(\\mathcal{D})^2 N(\\mathcal{D}, \\mathcal{R}, T)^{\\mathrm{Ac}(\\mathcal{D})-d+\\beta} \\norm{T^{-1}}^{\\beta}\n\\end{equation}\n% we just need to control the supremum \\eqref{gaussian-upp} concerning Gaussian inputs\nfor all positive definite symmetric endomorphisms $A_j \\in \\mathrm{End}(H_j)$ satisfying $A_j \\leq R_j$.\n\nLet $M := T+ \\sum_{j\\in J} q_{j} \\,\\ell^*_{j} A_{j}\\ell_{j} \\in \\mathrm{End}(H)$.\nBy additivity of positive definite maps, $M$ is symmetric and positive definite.\nLet $(e_1, \\dotsc, e_d)$ be an orthonormal basis of $H$ in which the matrix of $M$ is diagonal, with diagonal entries $\\lambda_{1}\\geq \\dots \\geq \\lambda_{d}>0$.\nFor a set of indices $I \\subset \\set{1, \\dotsc, d}$, we write\n\\[\nV_I = \\mathrm{Span} \\set{ e_i : i \\in I}.\n\\]\nFor $k \\in \\set{0,\\dotsc, d-1}$, we abbreviate\n\\(\nV_{> k} = V_{\\set{k+1, \\dotsc, d}}.\n\\)\n\nFor each $j \\in J$, we construct an index subset $I_j \\subset \\set{1, \\dotsc, d}$ satisfying\n\\begin{equation}\n\\label{eq:Ij}\n\\forall i \\in I_{j}, \\quad \\mathrm{dist}(\\ell_j e_i, \\ell_j V_{I_j \\cap (i,d] }) \\geq \\frac{1}{\\sqrt{d}},\n\\end{equation}\n\\begin{equation}\\label{eq:Ij2nd}\n\\forall i \\in \\set{1, \\dotsc, d},\\quad \\mathrm{dist}(\\ell_j e_i, \\ell_j V_{I_j \\cap [i,d]}) < \\frac{1}{\\sqrt{d}}.\n\\end{equation}\nThis construction is done inductively (Greedy construction).\nFirst, we put $d$ in $I_j$ if and only if $\\norm{\\ell_j e_d} \\geq \\frac{1}{\\sqrt{d}}$.\nThis determines $I_j \\cap (d-1,d]$.\nThen for each integer $i < d$, starting from $d - 1$, suppose the intersection $I_j \\cap (i, d]$ is determined.\nWe put $i$ in $I_j$ if \\eqref{eq:Ij} holds, and we skip $i$ and proceed to $i - 1$ otherwise.\nThis procedure terminates when $i$ reaches $0$, and yields a set $I_{j}$ satisfying \\eqref{eq:Ij}, \\eqref{eq:Ij2nd}.\n\n\nWe derive further properties of the sets $I_{j}$ using Lemma \\ref{lem:greedy_set_properties}. First, for all $k\\in \\set{0, \\dotsc, d - 1}$, we have\n\\begin{equation}\\label{Ij-percep-estimate}\n\\sum_{j\\in J} q_{j} \\abs{I_j \\cap (k, d] } \\geq d - k - \\beta.\n\\end{equation}\nTo see that, note that by \\eqref{eq:Ij2nd}, we have\n\\begin{equation*}%\\label{ellVk}\n\\ell_j B_{1}^{V_{> k}} \\subset \\ell_j V_{I_j \\cap (k,d]} + B^H_{1}.\n\\end{equation*}\nIn view of Lemma \\ref{lem:essential_rank_eq}, this implies\n\\begin{equation}\\label{ellVk}\n\\mathrm{rk}_1(\\ell_j \\mid V_{> k}) \\leq \\dim V_{I_j \\cap (k, d]} = \\abs{I_j \\cap (k, d]}.\n\\end{equation}\nSumming over $j \\in J$ and using the assumption of perceptivity, the claim \\eqref{Ij-percep-estimate} follows.\n\n\nWe also see that $|I_{j}|=\\dim H_{j}$. Indeed, taking $k=0$ in \\eqref{ellVk} and recalling $\\mathrm{rk}_{1}(\\ell_j) = \\dim H_j$ by hypothesis, we obtain $\\dim H_j \\leq \\abs{I_j}$.\nBy Lemma \\ref{lem:greedy_set_properties} (volume bound) which relies on \\eqref{eq:Ij}, we have\n\\begin{equation}\\label{eq:detellj}\n\\norm{\\wedge_{i\\in I_{j}}\\ell_{j}e_{i} } = \\prod_{i \\in I_j} \\mathrm{dist}\\bigl(\\ell_j e_i, \\ell_j V_{I_j \\cap (i,d]}\\bigr) \\geq d^{-\\frac{\\abs{I_j}}{2}},\n\\end{equation}\nand in particular $\\abs{I_j} \\leq \\dim H_j$.\n%and using again that the $\\ell_{j}$'s are orthogonal projectors,\nTherefore $\\abs{I_j}=\\dim H_{j}$. Note the argument shows that $(\\ell_{j}e_{i})_{i\\in I_{j}}$ is a basis of $H_{j}$. By definition of $\\mathrm{Ac}(\\mathcal{D})$, we also have\n\\begin{equation}\\label{Ij-cardinal}\n\\sum_{j}q_{j} \\abs{I_{j}} = \\mathrm{Ac}(\\mathcal{D}).\n\\end{equation}\n\n\nWe deduce upper bounds on the determinants of the $A_{j}$.\nGiven $j \\in J$, and $i\\in I_j$, we have\n\\begin{equation}\\label{bnd-scalar-prod}\n{\\langle A_{j}\\ell_{j}e_{i}, \\ell_{j} e_{i}\\rangle} = {\\langle \\ell_{j}^*A_{j}\\ell_{j}e_{i}, e_{i}\\rangle} \\leq \\frac{1}{q_j} {\\langle M e_{i}, e_{i}\\rangle} \\leq \\frac{\\lambda_i}{q_j}.\n\\end{equation}\nEmploying Lemma~\\ref{eq:Choleski} and Lemma \\ref{lem:hadamard_bound}, then \\eqref{eq:detellj} and \\eqref{bnd-scalar-prod}, we deduce\n\\begin{align*}\n{\\det A_{j}} & \\leq \\norm{\\wedge_{i\\in I_{j}}\\ell_{j}e_{i} }^{-2} \\prod_{i\\in I_{j}}{\\langle A_{j}\\ell_{j}e_{i}, \\ell_{j} e_{i}\\rangle}\\\\\n&\\leq \\Bigl(\\frac{d}{q_j}\\Bigr)^{\\abs{I_j}} \\prod_{i\\in I_{j}}\\lambda_{i}.\n\\end{align*}\n\nTaking power $q_{j}$, then the product over $j$, and using \\eqref{Ij-cardinal}, we get\n\\begin{equation} \\label{eqproddetAj}\n\\prod_{j\\in J} (\\det A_{j})^{q_{j}} \\leq\nd^{\\mathrm{Ac}(\\mathcal{D})}\\mathcal{E}(\\mathcal{D})^2\n\\prod_{i=1}^d{\\lambda_{i}}^{\\sum_{j \\in J} q_{j}\\abs{I_{j}\\cap \\{i\\}}}.\n\\end{equation}\n%Observing that the map $t\\mapsto t^{-t}$ is uniformly bounded on $(0, +\\infty]$, we have $q_{j}^{-q_{j}\\dim L_{j}}=O_{d}(1)$. Hence we can remove the term $\\prod_{j}q_{j}^{-q_{j}\\dim L_{j}}$ in \\eqref{eqproddetAj} up to increasing the implicit constant in $\\ll_{d}$.\nWe now bound the product on the eigenvalues $\\lambda_{i}$.\nUsing Lemma \\ref{lem:telescoping_eigenvalues} which relies on telescoping and the properties \\eqref{Ij-percep-estimate} and \\eqref{Ij-cardinal} of $I_{j}$, we have\n\\begin{align}\n \\prod_{i=1}^d{\\lambda_{i}}^{\\sum_{j}q_{j}\\abs{I_{j} \\cap \\{i\\}}}\n &= \\lambda_{1}^{\\sum_{j}q_{j}\\abs{I_j}}\\prod_{k=1}^{d-1} \\left(\\frac{\\lambda_{k+1}}{\\lambda_k}\\right)^{\\sum_{j}q_{j}\\abs{I_{j}\\cap (k,d]} } \\nonumber\\\\\n &\\leq \\lambda_{1}^{\\mathrm{Ac}(\\mathcal{D})}\\prod_{k=1}^{d-1} \\left(\\frac{\\lambda_{k+1}}{\\lambda_k}\\right)^{d-k-\\beta} \\nonumber\\\\\n &=\\lambda_{1}^{\\mathrm{Ac}(\\mathcal{D})-d+1+\\beta} \\lambda_{2}\\lambda_{3}\\dotsm \\lambda_{d-1} \\lambda_{d}^{1-\\beta} \\nonumber\\\\\n &= \\lambda_{1}^{\\mathrm{Ac}(\\mathcal{D})-d+\\beta} \\lambda_{d}^{-\\beta} \\det M. \\label{eqprodlambdai}\n \\end{align}\nEquations \\eqref{eqproddetAj} and \\eqref{eqprodlambdai} together yield\n$$\n\\frac{\\prod_{j\\in J} (\\det A_{j})^{q_{j}} }{{\\det M}}\\leq d^{\\mathrm{Ac}(\\mathcal{D})}\\mathcal{E}(\\mathcal{D})^2\n\\lambda_{1}^{\\mathrm{Ac}(\\mathcal{D})-d+\\beta} \\lambda_{d}^{-\\beta}.\n$$\n\nNow since the Gaussian input $(A_j)_j$ is dominated by $(R_j)_j$\nwe have $\\lambda_{1}\\leq N(\\mathcal{D}, \\mathcal{R}, T)$.\nOn the other hand, $\\lambda_{d} \\geq \\norm{T^{-1}}^{-1}$.\nThis concludes the proof of \\eqref{eq:rlub1}.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen EuclideanSpace in\n\n\ntheorem upperBound {J E : Type*} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n [FiniteDimensional ℝ E] {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (hE : Module.finrank ℝ E ≠ 0)\n (D : locRegDatum E F) (α : J → NNReal) (β : NNReal) (hα : ∀ i, 0 < α i)\n (hP : D.IsMetricPercep α β)\n (hS : ∀ j : J, (D.map j).EssentialRank rfl (α j) = Module.finrank ℝ (F j)) :\n let M_max := (D.loc + ∑ j, (D.weight j) • (D.map j).adjoint ∘ₗ (D.reg j) ∘ₗ (D.map j))\n loc_reg_constant_g D ≤\n (Module.finrank ℝ E : NNReal)^(D.Acuity / 2 : ℝ) *\n (∏ j, (D.weight j)^(- (D.weight j : ℝ) * Module.finrank ℝ (F j) / 2)) *\n (∏ j, (α j)^(- (D.weight j : ℝ) * Module.finrank ℝ (F j))) *\n ‖M_max.toContinuousLinearMap‖₊^((D.Acuity.toReal - Module.finrank ℝ E + β) / 2) *\n ‖(D.loc.equivOfDetNeZero D.pos_loc.2).symm.toContinuousLinearMap‖₊^(β.toReal / 2) := by sorry"} -{"project_name": "BrooksTheorem", "name": "brooks_theorem", "type": "theorem", "title": "Brooks' theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Brooks' theorem}\n\nThis section contains a (stub of a) proof of Brooks' theorem.\nSee \\url{https://en.wikipedia.org/wiki/Brooks%27_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Brooks' theorem]\n \\label{thm:brooks-theorem}\n \\lean{brooks_theorem}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Finset\n\n\ntheorem brooks_theorem {V : Type} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj]\n (h_connected : G.Connected) :\n (G.chromaticNumber ≤ G.maxDegree) ∨\n (∃ n : ℕ, Nonempty (G ≃g SimpleGraph.completeGraph (Fin n))) ∨\n (∃ n : ℕ, Nonempty (G ≃g SimpleGraph.cycleGraph (2 * n + 3))) := by sorry"} -{"project_name": "BrunTheorem", "name": "brun", "type": "theorem", "title": "Brun's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Brun's theorem}\n\nThis section contains a (stub of a) proof of Brun's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Brun's_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Brun's theorem]\n \\label{thm:brun-theorem}\n \\lean{brun}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat\n\nopen Classical in\n\n\ntheorem brun : Summable (fun n ↦ if n ∈ TwinPrimes then 1 / (n : ℝ) else 0) := by sorry"} -{"project_name": "BrunTitchmarshTheorem", "name": "brunTitchmarsh", "type": "theorem", "title": "Brun–Titchmarsh theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Brun–Titchmarsh theorem}\n\nThis section contains a (stub of a) proof of the Brun–Titchmarsh theorem.\nSee \\url{https://en.wikipedia.org/wiki/Brun–Titchmarsh_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Brun–Titchmarsh theorem]\n \\label{thm:brun-titchmarsh-theorem}\n \\lean{brunTitchmarsh}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem brunTitchmarsh {x q a : ℕ} (ha : a < q) (hq : q < x) :\n {m ∈ Finset.range (x + 1) | m.Prime ∧ a = m%q}.card\n < 2 * x / (φ q * Real.log (x / (q : ℝ))) := by sorry"} -{"project_name": "BrunnMinkowski", "name": "EuclideanSpace.volume_pow_add_le", "type": "theorem", "title": "Brunn-Minkowski Inequality (Additive Form)", "informal_statement": "Let $A$ and $B$ be two non-empty measurable subsets of $\\mathbb{R}^n$ such that $A+B$ is also measurable. Then the following inequality holds:\n \\[ [\\mu(A+B)]^{1/n} \\geq [\\mu(A)]^{1/n} + [\\mu(B)]^{1/n}. \\]", "informal_proof": "\\chapter{Brunn-Minkowski Theorem}\n\nThis section contains a proof of the Brunn-Minkowski Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Brunn%E2%80%93Minkowski_theorem} for more details.\n\n\\begin{lemma}\n \\label{lem:PL_ineq_dim1'}\n \\lean{prekopa_leindler_dim1}\n Let $0 < \\lambda < 1$ and let $f, g, h$ be nonnegative integrable functions on $\\mathbb{R}$ satisfying\n \\[ h\\big((1-\\lambda)x + \\lambda y\\big) \\;\\ge\\; f(x)^{1-\\lambda} g(y)^{\\lambda} \\tag{10}\\]\n for all $x,y \\in \\mathbb{R}$. Then\n \\[\n \\int_{\\mathbb{R}} h(x)\\,dx \\;\\ge\\;\n \\left( \\int_{\\mathbb{R}} f(x)\\,dx \\right)^{1-\\lambda}\n \\left( \\int_{\\mathbb{R}} g(x)\\,dx \\right)^{\\lambda}.\n \\tag{12}\n \\]\n\\end{lemma}\n\\begin{proof}\n If $\\int_{\\mathbb{R}} f(x)\\,dx = 0$ or $\\int_{\\mathbb{R}} g(x)\\,dx = 0$ the Prékopa–Leindler inequality (12) holds trivially. We thus assume $\\int_{\\mathbb{R}} f(x)\\,dx = F > 0$ and $\\int_{\\mathbb{R}} g(x)\\,dx = G > 0$.\n Define the auxiliary functions $u,v : [0,1] \\to \\mathbb{R}$ such that $u(t)$ and $v(t)$ are the smallest numbers satisfying\n \\[\n \\frac{1}{F}\\int_{-\\infty}^{u(t)} f(x)\\,dx\n = \\frac{1}{G}\\int_{-\\infty}^{v(t)} g(x)\\,dx\n = t.\n \\tag{13}\n \\]\n Since $f$ and $g$ are nonnegative, $u$ and $v$ are strictly increasing functions and hence are differentiable almost everywhere. Note that $u$ and $v$ do not have to be continuous everywhere. Taking the derivative of (13) with respect to $t$ gives for almost every $t$:\n \\[\n \\frac{f(u(t))u'(t)}{F} = \\frac{g(v(t))v'(t)}{G} = 1.\n \\tag{14}\n \\]\n Let $w(t) = (1-\\lambda)u(t) + \\lambda v(t)$. By (14), for almost every $t \\in (0,1)$ we have $f(u(t)) \\neq 0 \\neq g(v(t))$, and thus also\n \\[\n \\begin{aligned}\n w'(t) &= (1-\\lambda)u'(t) + \\lambda v'(t) \\\\\n &\\ge u'(t)^{1-\\lambda} v'(t)^{\\lambda} \\\\\n &= \\left( \\frac{F}{f(u(t))} \\right)^{1-\\lambda}\n \\left( \\frac{G}{g(v(t))} \\right)^{\\lambda},\n \\end{aligned}\n \\tag{15}\n \\]\n where we used Young’s inequality in the first step and (14) in the second step.\n By assumption (10), (15), $h \\ge 0$ and $w$ being strictly increasing we have\n \\[\n \\int_{\\mathbb{R}} h(x)\\,dx\n \\;\\ge\\; \\int_{0}^{1} h(w(t))w'(t)\\,dt\n \\]\n \\[\n \\;\\ge\\; \\int_{0}^{1} f(u(t))^{1-\\lambda} g(v(t))^{\\lambda}\n \\left( \\frac{F}{f(u(t))} \\right)^{1-\\lambda}\n \\left( \\frac{G}{g(v(t))} \\right)^{\\lambda} dt\n \\]\n \\[\n = F^{1-\\lambda} G^{\\lambda}\n = \\left(\\int_{\\mathbb{R}} f(x)\\,dx\\right)^{1-\\lambda}\n \\left(\\int_{\\mathbb{R}} g(x)\\,dx\\right)^{\\lambda}.\n \\]\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:PL_ineq}\n \\uses{lem:PL_ineq_dim1'}\n \\lean{prekopa_leindler}\n Let $0 < \\lambda < 1$ and let $f,g,h : \\mathbb{R}^n \\to [0,+\\infty)$ be non-negative real valued measurable functions defined on $n$ dimensional Euclidean space $\\mathbb{R}^n$. Suppose that these functions satisfy\n \\[ h\\big((1-\\lambda)x + \\lambda y\\big) \\;\\ge\\; f(x)^{1-\\lambda} g(y)^{\\lambda}\n \\qquad \\text{for all } x,y \\in \\mathbb{R}^n . \\]\n Then\n \\[ \\int_{\\mathbb{R}^n} h(x)\\,dx \\;\\ge\\;\n \\left(\\int_{\\mathbb{R}^n} f(x)\\,dx\\right)^{1-\\lambda}\n \\left(\\int_{\\mathbb{R}^n} g(x)\\,dx\\right)^{\\lambda} \\]\n\\end{lemma}\n\\begin{proof}\n We have just proven the Prékopa–Leindler inequality holds for dimension $n=1$. Suppose that the Prékopa–Leindler inequality holds for all positive integers less than $n$.\n For each $s \\in \\mathbb{R}$, define a nonnegative function $h_s$ on $\\mathbb{R}^{n-1}$ by\n \\[\n h_s(z) := h(z,s) \\quad \\text{for } z \\in \\mathbb{R}^{n-1},\n \\]\n and define $f_s$ and $g_s$ analogously. Let $a,b \\in \\mathbb{R}$, and let $c := (1-\\lambda)a + \\lambda b$. Then, for any $x,y \\in \\mathbb{R}^{n-1}$, by assumption (10)\n \\[\n \\begin{aligned}\n h_c((1-\\lambda)x + \\lambda y)\n &= h\\big((1-\\lambda)x + \\lambda y, (1-\\lambda)a + \\lambda b\\big) \\\\\n &= h\\big((1-\\lambda)(x,a) + \\lambda(y,b)\\big) \\\\\n &\\ge f(x,a)^{1-\\lambda} g(y,b)^{\\lambda} \\\\\n &= f_a(x)^{1-\\lambda} g_b(y)^{\\lambda}.\n \\end{aligned}\n \\]\n Using our inductive hypothesis (11) for $n-1$ we obtain that\n \\[\n \\int_{\\mathbb{R}^{n-1}} h_c(x)\\,dx\n \\;\\ge\\;\n \\left( \\int_{\\mathbb{R}^{n-1}} f_a(x)\\,dx \\right)^{1-\\lambda}\n \\left( \\int_{\\mathbb{R}^{n-1}} g_b(x)\\,dx \\right)^{\\lambda}.\n \\]\n Now define\n \\[\n F(a) := \\int_{\\mathbb{R}^{n-1}} f_a(x)\\,dx,\n \\quad G(b) := \\int_{\\mathbb{R}^{n-1}} g_b(x)\\,dx,\n \\quad H(c) := \\int_{\\mathbb{R}^{n-1}} h_c(x)\\,dx.\n \\]\n Then this inequality reads\n \\[\n H(c) = H((1-\\lambda)a + \\lambda b) \\;\\ge\\; F(a)^{1-\\lambda} G(b)^{\\lambda}.\n \\]\n Finally, using Fubini’s theorem and our induction base $n=1$ Lemma 12, we find that\n \\[\n \\begin{aligned}\n \\int_{\\mathbb{R}^n} h(x)\\,dx\n &= \\int_{\\mathbb{R}} \\int_{\\mathbb{R}^{n-1}} h_c(z)\\,dz\\,dc \\\\\n &= \\int_{\\mathbb{R}} H(c)\\,dc \\\\\n &\\ge \\left( \\int_{\\mathbb{R}} F(a)\\,da \\right)^{1-\\lambda}\n \\left( \\int_{\\mathbb{R}} G(b)\\,db \\right)^{\\lambda} \\\\\n &= \\left( \\int_{\\mathbb{R}^n} f(x)\\,dx \\right)^{1-\\lambda}\n \\left( \\int_{\\mathbb{R}^n} g(x)\\,dx \\right)^{\\lambda},\n \\end{aligned}\n \\]\n proving the Prékopa–Leindler inequality in all dimensions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:PL_ineq_variant}\n \\uses{lem:PL_ineq}\n \\lean{prekopa_leindler'}\n Let $d \\in \\mathbb{N}$ and $t \\in (0,1)$. Let $f, g, h: \\mathbb{R}^d \\to \\mathbb{R}_{\\ge 0}$ be three non-negative, integrable functions on the Euclidean space $\\mathbb{R}^d$.\n Assume that for all $x, y \\in \\mathbb{R}^d$, the following pointwise condition holds:\n $$f(x)^{1-t} g(y)^t \\le h(x+y).$$\n Then their integrals satisfy the inequality:\n $$\\left(\\int_{\\mathbb{R}^d} f(x)\\,dx\\right)^{1-t} \\left(\\int_{\\mathbb{R}^d} g(y)\\,dy\\right)^{t} \\le (1-t)^{d(1-t)} t^{dt} \\int_{\\mathbb{R}^d} h(z)\\,dz.$$\n\\end{lemma}\n\\begin{proof}\n Consider the rescaled functions\n \\[ \\phi(x) := f\\big((1-t)x\\big),\\qquad \\psi(y) := g\\big(ty\\big). \\]\n For any $x,y\\in\\mathbb R^d$,\n \\[ \\phi(x)^{\\,1-t}\\psi(y)^{\\,t}\n = f\\big((1-t)x\\big)^{1-t}\\,g\\big(ty\\big)^{t}\n \\le h\\big((1-t)x+ty\\big), \\]\n where the inequality is exactly the given assumption with the substitutions $x\\mapsto(1-t)x$ and $y\\mapsto ty$.\n By the classical Prékopa–Leindler inequality (in its Jensen-type form),\n \\[ \\int_{\\mathbb R^d} h \\ \\ge\\\n \\Big(\\int_{\\mathbb R^d}\\phi\\Big)^{1-t}\n \\Big(\\int_{\\mathbb R^d}\\psi\\Big)^{t}.\n \\tag{1} \\]\n Now compute the two integrals via change of variables. Since the linear maps $x\\mapsto (1-t)x$ and $y\\mapsto ty$ have Jacobians $(1-t)^d$ and $t^d$ respectively,\n \\[ \\int_{\\mathbb R^d}\\phi(x)\\,dx\n =\\int f\\big((1-t)x\\big)\\,dx\n =(1-t)^{-d}\\!\\int f,\n \\qquad\n \\int_{\\mathbb R^d}\\psi(y)\\,dy\n =\\int g(ty)\\,dy\n =t^{-d}\\!\\int g.\n \\tag{2} \\]\n Plug (2) into (1):\n \\[ \\int h \\ \\ge\\\n \\big((1-t)^{-d}\\!\\int f\\big)^{1-t}\n \\big(t^{-d}\\!\\int g\\big)^{t}\n =(1-t)^{-d(1-t)}\\,t^{-dt}\\,\n \\Big(\\int f\\Big)^{1-t}\\Big(\\int g\\Big)^t. \\]\n Rearranging gives\n \\[\\Big(\\int f\\Big)^{1-t}\\Big(\\int g\\Big)^{t}\n \\ \\le\\ (1-t)^{\\,d(1-t)}\\,t^{\\,dt}\\,\\int h, \\]\n which is the desired inequality.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:vol_mul_le}\n \\lean{prekopa_leindler'}\n \\leanok\n For any $f, g, h : \\mathbb R^n \\to \\mathbb R$ integrable functions, $t \\in \\left(0, 1\\right)$\n and $d \\in \\mathbb N$, $\\left(\\int_{\\mathbb R^d} f(x) dx\\right)^{1-t} * \\left(\\int_{\\mathbb R^d} g(y) dy \\right)^t \\le\n (1 - t) ^ (d * (1 - t)) * t ^ (d * t) * \\int_{mathbb R^n} h (z) dz$.\n\\end{lemma}\n\\begin{proof}\n \\uses{lem:PL_ineq_variant}\n This is another version of the Prékopa–Leindler inequality, which is trivial after ~\\href{lem:PL_ineq_variant}.\n\\end{proof}\n\n\\begin{theorem}[Brunn-Minkowski Inequality (Additive Form)]\n \\label{thm:Brunn-Minkowski_Inequality_Additive}\n \\uses{lem:PL_ineq_variant}\n \\lean{EuclideanSpace.volume_pow_add_le}\n \\uses{lem:PL_ineq_variant}\n Let $A$ and $B$ be two non-empty measurable subsets of $\\mathbb{R}^n$ such that $A+B$ is also measurable. Then the following inequality holds:\n \\[ [\\mu(A+B)]^{1/n} \\geq [\\mu(A)]^{1/n} + [\\mu(B)]^{1/n}. \\]\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:vol_mul_le}\n Let $n \\geq 1$ and let $A, B \\subseteq \\mathbb{R}^n$ be non-empty, compact, and measurable sets. We aim to prove that\n $(\\mathrm{vol}(A+B))^{1/n} \\geq (\\mathrm{vol}(A))^{1/n} + (\\mathrm{vol}(B))^{1/n},$\n where $A+B={a+b \\mid a\\in A,, b\\in B}$.\n\n The proof proceeds in two stages: first, we handle the trivial cases, and then, in the general case, we appeal to the **Prékopa–Leindler inequality**. If $\\mathrm{vol}(A)=0$, the inequality reduces to $(\\mathrm{vol}(A+B))^{1/n}\\geq (\\mathrm{vol}(B))^{1/n}$, which is immediate since $B\\subseteq A+B$. A symmetric argument applies if $\\mathrm{vol}(B)=0$. If $\\mathrm{vol}(A+B)=\\infty$, the inequality holds trivially. Thus, we may assume that $\\mathrm{vol}(A), \\mathrm{vol}(B),$ and $\\mathrm{vol}(A+B)$ are all finite and strictly positive.\n\n In this setting, consider a parameter $t$ with $0 0$ and $\\int_{\\mathbb{R}} g(x)\\,dx = G > 0$.\n Define the auxiliary functions $u,v : [0,1] \\to \\mathbb{R}$ such that $u(t)$ and $v(t)$ are the smallest numbers satisfying\n \\[\n \\frac{1}{F}\\int_{-\\infty}^{u(t)} f(x)\\,dx\n = \\frac{1}{G}\\int_{-\\infty}^{v(t)} g(x)\\,dx\n = t.\n \\tag{13}\n \\]\n Since $f$ and $g$ are nonnegative, $u$ and $v$ are strictly increasing functions and hence are differentiable almost everywhere. Note that $u$ and $v$ do not have to be continuous everywhere. Taking the derivative of (13) with respect to $t$ gives for almost every $t$:\n \\[\n \\frac{f(u(t))u'(t)}{F} = \\frac{g(v(t))v'(t)}{G} = 1.\n \\tag{14}\n \\]\n Let $w(t) = (1-\\lambda)u(t) + \\lambda v(t)$. By (14), for almost every $t \\in (0,1)$ we have $f(u(t)) \\neq 0 \\neq g(v(t))$, and thus also\n \\[\n \\begin{aligned}\n w'(t) &= (1-\\lambda)u'(t) + \\lambda v'(t) \\\\\n &\\ge u'(t)^{1-\\lambda} v'(t)^{\\lambda} \\\\\n &= \\left( \\frac{F}{f(u(t))} \\right)^{1-\\lambda}\n \\left( \\frac{G}{g(v(t))} \\right)^{\\lambda},\n \\end{aligned}\n \\tag{15}\n \\]\n where we used Young’s inequality in the first step and (14) in the second step.\n By assumption (10), (15), $h \\ge 0$ and $w$ being strictly increasing we have\n \\[\n \\int_{\\mathbb{R}} h(x)\\,dx\n \\;\\ge\\; \\int_{0}^{1} h(w(t))w'(t)\\,dt\n \\]\n \\[\n \\;\\ge\\; \\int_{0}^{1} f(u(t))^{1-\\lambda} g(v(t))^{\\lambda}\n \\left( \\frac{F}{f(u(t))} \\right)^{1-\\lambda}\n \\left( \\frac{G}{g(v(t))} \\right)^{\\lambda} dt\n \\]\n \\[\n = F^{1-\\lambda} G^{\\lambda}\n = \\left(\\int_{\\mathbb{R}} f(x)\\,dx\\right)^{1-\\lambda}\n \\left(\\int_{\\mathbb{R}} g(x)\\,dx\\right)^{\\lambda}.\n \\]\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:PL_ineq}\n \\uses{lem:PL_ineq_dim1'}\n \\lean{prekopa_leindler}\n Let $0 < \\lambda < 1$ and let $f,g,h : \\mathbb{R}^n \\to [0,+\\infty)$ be non-negative real valued measurable functions defined on $n$ dimensional Euclidean space $\\mathbb{R}^n$. Suppose that these functions satisfy\n \\[ h\\big((1-\\lambda)x + \\lambda y\\big) \\;\\ge\\; f(x)^{1-\\lambda} g(y)^{\\lambda}\n \\qquad \\text{for all } x,y \\in \\mathbb{R}^n . \\]\n Then\n \\[ \\int_{\\mathbb{R}^n} h(x)\\,dx \\;\\ge\\;\n \\left(\\int_{\\mathbb{R}^n} f(x)\\,dx\\right)^{1-\\lambda}\n \\left(\\int_{\\mathbb{R}^n} g(x)\\,dx\\right)^{\\lambda} \\]\n\\end{lemma}\n\\begin{proof}\n We have just proven the Prékopa–Leindler inequality holds for dimension $n=1$. Suppose that the Prékopa–Leindler inequality holds for all positive integers less than $n$.\n For each $s \\in \\mathbb{R}$, define a nonnegative function $h_s$ on $\\mathbb{R}^{n-1}$ by\n \\[\n h_s(z) := h(z,s) \\quad \\text{for } z \\in \\mathbb{R}^{n-1},\n \\]\n and define $f_s$ and $g_s$ analogously. Let $a,b \\in \\mathbb{R}$, and let $c := (1-\\lambda)a + \\lambda b$. Then, for any $x,y \\in \\mathbb{R}^{n-1}$, by assumption (10)\n \\[\n \\begin{aligned}\n h_c((1-\\lambda)x + \\lambda y)\n &= h\\big((1-\\lambda)x + \\lambda y, (1-\\lambda)a + \\lambda b\\big) \\\\\n &= h\\big((1-\\lambda)(x,a) + \\lambda(y,b)\\big) \\\\\n &\\ge f(x,a)^{1-\\lambda} g(y,b)^{\\lambda} \\\\\n &= f_a(x)^{1-\\lambda} g_b(y)^{\\lambda}.\n \\end{aligned}\n \\]\n Using our inductive hypothesis (11) for $n-1$ we obtain that\n \\[\n \\int_{\\mathbb{R}^{n-1}} h_c(x)\\,dx\n \\;\\ge\\;\n \\left( \\int_{\\mathbb{R}^{n-1}} f_a(x)\\,dx \\right)^{1-\\lambda}\n \\left( \\int_{\\mathbb{R}^{n-1}} g_b(x)\\,dx \\right)^{\\lambda}.\n \\]\n Now define\n \\[\n F(a) := \\int_{\\mathbb{R}^{n-1}} f_a(x)\\,dx,\n \\quad G(b) := \\int_{\\mathbb{R}^{n-1}} g_b(x)\\,dx,\n \\quad H(c) := \\int_{\\mathbb{R}^{n-1}} h_c(x)\\,dx.\n \\]\n Then this inequality reads\n \\[\n H(c) = H((1-\\lambda)a + \\lambda b) \\;\\ge\\; F(a)^{1-\\lambda} G(b)^{\\lambda}.\n \\]\n Finally, using Fubini’s theorem and our induction base $n=1$ Lemma 12, we find that\n \\[\n \\begin{aligned}\n \\int_{\\mathbb{R}^n} h(x)\\,dx\n &= \\int_{\\mathbb{R}} \\int_{\\mathbb{R}^{n-1}} h_c(z)\\,dz\\,dc \\\\\n &= \\int_{\\mathbb{R}} H(c)\\,dc \\\\\n &\\ge \\left( \\int_{\\mathbb{R}} F(a)\\,da \\right)^{1-\\lambda}\n \\left( \\int_{\\mathbb{R}} G(b)\\,db \\right)^{\\lambda} \\\\\n &= \\left( \\int_{\\mathbb{R}^n} f(x)\\,dx \\right)^{1-\\lambda}\n \\left( \\int_{\\mathbb{R}^n} g(x)\\,dx \\right)^{\\lambda},\n \\end{aligned}\n \\]\n proving the Prékopa–Leindler inequality in all dimensions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:PL_ineq_variant}\n \\uses{lem:PL_ineq}\n \\lean{prekopa_leindler'}\n Let $d \\in \\mathbb{N}$ and $t \\in (0,1)$. Let $f, g, h: \\mathbb{R}^d \\to \\mathbb{R}_{\\ge 0}$ be three non-negative, integrable functions on the Euclidean space $\\mathbb{R}^d$.\n Assume that for all $x, y \\in \\mathbb{R}^d$, the following pointwise condition holds:\n $$f(x)^{1-t} g(y)^t \\le h(x+y).$$\n Then their integrals satisfy the inequality:\n $$\\left(\\int_{\\mathbb{R}^d} f(x)\\,dx\\right)^{1-t} \\left(\\int_{\\mathbb{R}^d} g(y)\\,dy\\right)^{t} \\le (1-t)^{d(1-t)} t^{dt} \\int_{\\mathbb{R}^d} h(z)\\,dz.$$\n\\end{lemma}\n\\begin{proof}\n Consider the rescaled functions\n \\[ \\phi(x) := f\\big((1-t)x\\big),\\qquad \\psi(y) := g\\big(ty\\big). \\]\n For any $x,y\\in\\mathbb R^d$,\n \\[ \\phi(x)^{\\,1-t}\\psi(y)^{\\,t}\n = f\\big((1-t)x\\big)^{1-t}\\,g\\big(ty\\big)^{t}\n \\le h\\big((1-t)x+ty\\big), \\]\n where the inequality is exactly the given assumption with the substitutions $x\\mapsto(1-t)x$ and $y\\mapsto ty$.\n By the classical Prékopa–Leindler inequality (in its Jensen-type form),\n \\[ \\int_{\\mathbb R^d} h \\ \\ge\\\n \\Big(\\int_{\\mathbb R^d}\\phi\\Big)^{1-t}\n \\Big(\\int_{\\mathbb R^d}\\psi\\Big)^{t}.\n \\tag{1} \\]\n Now compute the two integrals via change of variables. Since the linear maps $x\\mapsto (1-t)x$ and $y\\mapsto ty$ have Jacobians $(1-t)^d$ and $t^d$ respectively,\n \\[ \\int_{\\mathbb R^d}\\phi(x)\\,dx\n =\\int f\\big((1-t)x\\big)\\,dx\n =(1-t)^{-d}\\!\\int f,\n \\qquad\n \\int_{\\mathbb R^d}\\psi(y)\\,dy\n =\\int g(ty)\\,dy\n =t^{-d}\\!\\int g.\n \\tag{2} \\]\n Plug (2) into (1):\n \\[ \\int h \\ \\ge\\\n \\big((1-t)^{-d}\\!\\int f\\big)^{1-t}\n \\big(t^{-d}\\!\\int g\\big)^{t}\n =(1-t)^{-d(1-t)}\\,t^{-dt}\\,\n \\Big(\\int f\\Big)^{1-t}\\Big(\\int g\\Big)^t. \\]\n Rearranging gives\n \\[\\Big(\\int f\\Big)^{1-t}\\Big(\\int g\\Big)^{t}\n \\ \\le\\ (1-t)^{\\,d(1-t)}\\,t^{\\,dt}\\,\\int h, \\]\n which is the desired inequality.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:vol_mul_le}\n \\lean{prekopa_leindler'}\n \\leanok\n For any $f, g, h : \\mathbb R^n \\to \\mathbb R$ integrable functions, $t \\in \\left(0, 1\\right)$\n and $d \\in \\mathbb N$, $\\left(\\int_{\\mathbb R^d} f(x) dx\\right)^{1-t} * \\left(\\int_{\\mathbb R^d} g(y) dy \\right)^t \\le\n (1 - t) ^ (d * (1 - t)) * t ^ (d * t) * \\int_{mathbb R^n} h (z) dz$.\n\\end{lemma}\n\\begin{proof}\n \\uses{lem:PL_ineq_variant}\n This is another version of the Prékopa–Leindler inequality, which is trivial after ~\\href{lem:PL_ineq_variant}.\n\\end{proof}\n\n\\begin{theorem}[Brunn-Minkowski Inequality (Additive Form)]\n \\label{thm:Brunn-Minkowski_Inequality_Additive}\n \\uses{lem:PL_ineq_variant}\n \\lean{EuclideanSpace.volume_pow_add_le}\n \\uses{lem:PL_ineq_variant}\n Let $A$ and $B$ be two non-empty measurable subsets of $\\mathbb{R}^n$ such that $A+B$ is also measurable. Then the following inequality holds:\n \\[ [\\mu(A+B)]^{1/n} \\geq [\\mu(A)]^{1/n} + [\\mu(B)]^{1/n}. \\]\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:vol_mul_le}\n Let $n \\geq 1$ and let $A, B \\subseteq \\mathbb{R}^n$ be non-empty, compact, and measurable sets. We aim to prove that\n $(\\mathrm{vol}(A+B))^{1/n} \\geq (\\mathrm{vol}(A))^{1/n} + (\\mathrm{vol}(B))^{1/n},$\n where $A+B={a+b \\mid a\\in A,, b\\in B}$.\n\n The proof proceeds in two stages: first, we handle the trivial cases, and then, in the general case, we appeal to the **Prékopa–Leindler inequality**. If $\\mathrm{vol}(A)=0$, the inequality reduces to $(\\mathrm{vol}(A+B))^{1/n}\\geq (\\mathrm{vol}(B))^{1/n}$, which is immediate since $B\\subseteq A+B$. A symmetric argument applies if $\\mathrm{vol}(B)=0$. If $\\mathrm{vol}(A+B)=\\infty$, the inequality holds trivially. Thus, we may assume that $\\mathrm{vol}(A), \\mathrm{vol}(B),$ and $\\mathrm{vol}(A+B)$ are all finite and strictly positive.\n\n In this setting, consider a parameter $t$ with $0 0$ such that the function $g(z) = \\frac{1}{f(z) - w_0}$ is holomorphic and bounded on $U$.\n\\end{lemma}\n\n\\begin{proof}\n If $f(U)$ is not dense in $\\mathbb{C}$, then by definition of dense sets, there exists a point $w_0 \\in \\mathbb{C}$ and an $\\epsilon > 0$ such that the open disk $B(w_0, \\epsilon)$ has no intersection with $f(U)$. This means that for all $z \\in U$, we have $|f(z) - w_0| \\ge \\epsilon$.\n Now, consider the function $g(z) = \\frac{1}{f(z) - w_0}$. Since the denominator $f(z) - w_0$ is never zero in $U$, $g(z)$ is holomorphic in $U$.\n Furthermore, for all $z \\in U$, we have $|g(z)| = \\frac{1}{|f(z) - w_0|} \\le \\frac{1}{\\epsilon}$. Thus, $g(z)$ is bounded on $U$.\n\\end{proof}\n\n\\begin{lemma}[Characterization of Removable Singularities and Poles]\n \\label{lem:Non_Essential_Singularity_Conclusion}\n \\lean{not_EssentialSingularity_of}\n Let $f$ have an isolated singularity at $z_0$. Suppose there exists $w_0 \\in \\mathbb{C}$ such that $g(z) = \\frac{1}{f(z) - w_0}$ has a removable singularity at $z_0$. Then $f(z)$ at $z_0$ is not an essential singularity.\n\\end{lemma}\n\n\\begin{proof}\n By the removable singularity theorem, $g(z)$ can be extended to a function $\\tilde{g}$ that is holomorphic at $z_0$. We can express $f(z)$ in terms of $\\tilde{g}(z)$ for $z$ in a punctured neighborhood of $z_0$: $f(z) = w_0 + \\frac{1}{\\tilde{g}(z)}$.\n There are two cases for the value of $\\tilde{g}(z_0)$:\n \\begin{enumerate}\n \\item If $\\tilde{g}(z_0) \\neq 0$: Since $\\tilde{g}$ is holomorphic and non-zero at $z_0$, the function $\\frac{1}{\\tilde{g}(z)}$ is also holomorphic at $z_0$. Thus, $\\lim_{z \\to z_0} f(z) = w_0 + \\frac{1}{\\tilde{g}(z_0)}$ exists and is finite. This implies that $z_0$ is a removable singularity for $f$.\n \\item If $\\tilde{g}(z_0) = 0$: Since $f(z)$ has an isolated singularity, $f(z)$ is not constant, so $g(z)$ is not identically zero. Thus, $\\tilde{g}(z)$ is not identically zero. As $z \\to z_0$, $|f(z)| \\to \\infty$, so this is a pole for $f$.\n \\end{enumerate}\n In both cases, the singularity $z_0$ is either removable or a pole, and therefore not essential.\n\\end{proof}\n\n\\begin{theorem}[Casorati-Weierstrass]\n \\label{thm:Casorati_Weierstrass}\n \\lean{casorati_weierstrass}\n \\uses{def:Essential_Singularity}\n Let $f$ be a holomorphic function with an essential singularity at $z_0$. For any punctured open neighborhood $U$ of $z_0$, the image $f(U)$ is dense in the complex plane $\\mathbb{C}$.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:Boundedness_from_Non_Dense_Image}\n \\uses{lem:Non_Essential_Singularity_Conclusion}\n We prove this by contradiction. Assume that the image $f(U)$ is not dense in $\\mathbb{C}$.\n By lemma \\ref{lem:Boundedness_from_Non_Dense_Image}, this assumption implies that there exists $w_0 \\in \\mathbb{C}$ such that the function $g(z) = \\frac{1}{f(z) - w_0}$ is holomorphic and bounded on $U$.\n According to the removable singularity theorem, because $g(z)$ is bounded on $U$, the singularity at $z_0$ must be removable for $g$.\n Finally, by lemma \\ref{lem:Non_Essential_Singularity_Conclusion}, if $g(z)$ has a removable singularity at $z_0$, then $f(z)$ must have either a removable singularity or a pole at $z_0$.\n This contradicts our initial hypothesis that $z_0$ is an essential singularity of $f$, as per definition \\ref{def:Essential_Singularity}. Therefore, the assumption that $f(U)$ is not dense in $\\mathbb{C}$ must be false, and the theorem is proved.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Complex Set Metric Filter Topology\n\n\ntheorem casorati_weierstrass (f : ℂ → ℂ) {s : Set ℂ} {c : ℂ}\n (hess : EssentialSingularity f c)\n (hc : s ∈ 𝓝 c) (hd : DifferentiableOn ℂ f (s \\ {c})) :\n Dense (f '' s) := by sorry"} -{"project_name": "ChenTheorem", "name": "chen", "type": "theorem", "title": "Chen's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Chen's theorem}\n\nThis section contains a (stub of a) proof of Chen's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Chen's_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Chen's theorem]\n \\label{thm:chen-theorem}\n \\lean{chen}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Filter Nat\n\n\ntheorem chen : ∀ᶠ n in atTop, ∃ a b : ℕ,\n 2 * n = a + b ∧ a.Prime ∧ 1 < b ∧ b.primeFactorsList.length ≤ 2 := by sorry"} -{"project_name": "CondorcetJury", "name": "condorcet_jury_theorem", "type": "theorem", "title": "Condorcet's Jury Theorem", "informal_statement": "If each member of a jury of odd size has an independent probability greater than 1/2 of making the correct decision, then as the size of the jury increases, the probability that the majority decision is correct approaches 1.", "informal_proof": "\n\\chapter{Condorcet's Jury Theorem}\n\nThis section contains a proof of Condorcet's Jury Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Condorcet%27s_jury_theorem} for more details.\n\n\\begin{definition}[Jury Accuracy]\n \\label{def:jury_accuracy}\n \\lean{jury_majority_decision_probability}\n The accuracy of a jury of size $2n+1$ is defined as the probability that the majority decision made by the jury is correct, which is given by the probability that a binomial random variable with parameters $n$ (the number of jurors) and $p$ (the probability of each juror being correct) exceeds $n$.\n\\end{definition}\n\n\\begin{lemma}[A sum of two independent binomial distributions is binomial]\n \\label{lem:sum_of_two_independent_binomials_is_binomial}\n \\lean{PMF.binomial_add_binomial}\n Let $X \\sim \\text{Binomial}(n_1, p)$ and $Y \\sim \\text{Binomial}(n_2, p)$ be two independent binomial random variables. Then the sum $Z = X + Y$ follows a binomial distribution with parameters $n_1 + n_2$ and $p$, i.e., $Z \\sim \\text{Binomial}(n_1 + n_2, p)$.\n\\end{lemma}\n\n\\begin{proof}\n This follows from the formula for the probability mass function of the sum of two independent random variables. Specifically, for any integer $k$,\n \\[P(Z = k) = \\sum_{i=0}^{k} P(X = i) P(Y = k - i)\\]\n Substituting the binomial probability mass functions for $X$ and $Y$, we have\n \\[P(Z = k) = \\sum_{i=0}^{k} \\binom{n_1}{i} p^i (1-p)^{n_1 - i} \\cdot \\binom{n_2}{k - i} p^{k - i} (1-p)^{n_2 - (k - i)}\\]\n Simplifying this expression, we get\n \\[P(Z = k) = p^k (1-p)^{(n_1 + n_2) - k} \\sum_{i=0}^{k} \\binom{n_1}{i} \\binom{n_2}{k - i}\\]\n By the Vandermonde's identity, we know that\n \\[\\sum_{i=0}^{k} \\binom{n_1}{i} \\binom{n_2}{k - i} = \\binom{n_1 + n_2}{k}\\]\n Therefore, we have\n \\[P(Z = k) = \\binom{n_1 + n_2}{k} p^k (1-p)^{(n_1 + n_2) - k}\\]\n which is the probability mass function of a binomial distribution with parameters $n_1 + n_2$ and $p$. Thus, $Z \\sim \\text{Binomial}(n_1 + n_2, p)$.\n\\end{proof}\n\n\\begin{lemma}[Breakdown for increase of accuracy on adding two jurors]\n \\label{lem:breakdown_for_increase_of_accuracy_on_adding_two_jurors}\n \\lean{convolution_identity}\n \\uses{def:jury_accuracy}\n \\uses{lem:sum_of_two_independent_binomials_is_binomial}\n By adding two jurors to a jury of size $2n+1$, the increase in accuracy is given by\n the probability that the smaller jury has exactly $n$ correct votes and the two additional jurors are both correct,\n minus the probability that the smaller jury has exactly $n+1$ correct votes and both additional jurors are incorrect.\n\\end{lemma}\n\n\\begin{proof}\n Since a jury of size $2n+3$ can be viewed as a jury of size $2n+1$ plus two additional jurors, we can use \\ref{lem:sum_of_two_independent_binomials_is_binomial} to express the distribution of correct votes in the larger jury as the sum of the distribution of correct votes in the smaller jury and the distribution of correct votes from the two additional jurors.\n\n Thus, the accuracy of the larger jury can be expressed as the sum, over all possible numbers of correct votes from the smaller jury, of the probability that the smaller jury has a certain number of correct votes multiplied by the probability that the two additional jurors contribute enough correct votes to ensure that the total number of correct votes exceeds half of $2n+3$.\n\n By analyzing the terms of this sum, we see that\n \\begin{enumerate}\n \\item When the smaller jury has $n-1$ or fewer correct votes, then the two additional jurors cannot make the total exceed $n+1$ correct votes.\n \\item When the smaller jury has exactly $n$ correct votes, then both additional jurors must be correct to achieve a majority, which occurs with probability $p^2$.\n \\item When the smaller jury has $n+1$ correct votes, then at least one of the additional jurors must be correct, which occurs with probability $1 - (1-p)^2 = p(2-p)$.\n \\item When the smaller jury has over $n+1$ correct votes, then the larger jury will always have a majority of correct votes regardless of the additional jurors.\n \\end{enumerate}\n\\end{proof}\n\n\\begin{lemma}[Expression for increase of accuracy on adding two jurors]\n \\label{lem:expression_for_increase_of_accuracy_on_adding_two_jurors}\n \\lean{jury_probability_recurrence}\n \\uses{lem:breakdown_for_increase_of_accuracy_on_adding_two_jurors}\n By adding two jurors to a jury of size $2n+1$, the increase in accuracy can be expressed as\n \\[\\binom{2n+1}{n} p^n (1-p)^{n+1} p^2 - \\binom{2n+1}{n+1} p^{n+1} (1-p)^{n+1} (1-p)^2\\]\n\\end{lemma}\n\n\\begin{proof}\n\n From \\ref{lem:breakdown_for_increase_of_accuracy_on_adding_two_jurors}\n if we compute the difference in accuracy between the larger and smaller juries,\n we find that it is given by\n the probability that the smaller jury has exactly $n$ correct votes and the two additional jurors are both correct,\n minus the probability that the smaller jury has exactly $n+1$ correct votes and both additional jurors are incorrect.\n\n This comes to\n \\[\\binom{2n+1}{n} p^n (1-p)^{n+1} p^2 - \\binom{2n+1}{n+1} p^{n+1} (1-p)^{n+1} (1-p)^2\\]\n\\end{proof}\n\n\\begin{lemma}[Adding two jurors increases accuracy]\n \\label{lem:adding_two_jurors_increases_accuracy}\n \\lean{jury_majority_decision_probability_succ_lt}\n \\uses{def:jury_accuracy}\n \\uses{lem:expression_for_increase_of_accuracy_on_adding_two_jurors}\n For a jury of size $2n+1$ where each juror has an independent probability $p > 1/2$ of making the correct decision, and another jury of size $2n+3$ formed by adding two jurors with the same accuracy, the probability that the larger jury makes the correct decision is greater than that of the smaller jury.\n\\end{lemma}\n\n\\begin{proof}\n By \\ref{lem:expression_for_increase_of_accuracy_on_adding_two_jurors}, the increase in accuracy when adding two jurors is given by\n \\[\\binom{2n+1}{n} p^n (1-p)^{n+1} p^2 - \\binom{2n+1}{n+1} p^{n+1} (1-p)^{n+1} (1-p)^2\\]\n\n When $p > 0.5$, this expression is positive, showing that the accuracy of the larger jury is greater than that of the smaller jury.\n\\end{proof}\n\n\\begin{theorem}[Condorcet's Jury Theorem]\n \\label{thm:condorcet_jury}\n \\lean{condorcet_jury_theorem}\n \\uses{def:jury_accuracy}\n \\uses{lem:adding_two_jurors_increases_accuracy}\n If each member of a jury of odd size has an independent probability greater than 1/2 of making the correct decision, then as the size of the jury increases, the probability that the majority decision is correct approaches 1.\n\\end{theorem}\n\n\\begin{proof}\n The proof proceeds by induction on the size of the jury. For juries of sizes $2n + 1 < 2m + 1$, we can show by induction on $m-n$ that the accuracy of the larger jury is greater than that of the smaller jury. The base case where $m - n = 1$ is established by \\ref{lem:adding_two_jurors_increases_accuracy}. The inductive step follows similarly by repeatedly applying the lemma.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Real PMF BigOperators ENNReal NNReal Finset\n\nopen scoped Classical\n\n\ntheorem condorcet_jury_theorem (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1)\n (n m : ℕ) (n_lt_m : n < m) :\n jury_majority_decision_probability p hp n < jury_majority_decision_probability p hp m := by sorry"} -{"project_name": "ContinuousMappingAs", "name": "ae_tendsto_comp_of_ae_tendsto_of_forall_continuousAt", "type": "theorem", "title": "Continuous Mapping Theorem (almost sure convergence version)", "informal_statement": "\\leanok\n Let $(X_\\alpha)_{\\alpha \\in A}$ be a net (indexed by a directed set $A$) of $\\genspace$-valued\n random variables converging in probability to a random variable~$X$,\n $X_\\alpha \\tendsas X$ (along $A$).\n If $g \\colon \\genspaceA \\to \\genspaceB$ is a function which is continuous\n at every point of some Borel set $\\genspaceA_0 \\subseteq \\genspaceA$ such that\n $\\PR[X \\in \\genspaceA_0] = 1$,\n then $g(X_\\alpha) \\tendsas g(X)$ (along $A$).", "informal_proof": "\\chapter{The Continuous Mapping Theorem, Almost Sure Version}\n\nThis section contains a proof of the almost sure convergence version of the Continuous Mapping\nTheorem (the simplest of three distinct statements by the same general name).\nSee \\url{https://en.wikipedia.org/wiki/Continuous_mapping_theorem} for more details.\n\nFix a probability space $(\\PRspace,\\PRsigma,\\PR)$ once and for all (implicit\nin the statements below).\n\nLet $\\genspaceA$ and $\\genspaceB$ be two topological spaces,\nequipped with their respective Borel sigma algebras.\n%$\\borelOf{\\genspaceA}$ and $\\borelOf{\\genspaceB}$\n\n\\begin{theorem}[Continuous Mapping Theorem (almost sure convergence version)]\n \\label{thm:cont_map_thm_as}\n \\lean{ae_tendsto_comp_of_ae_tendsto_of_forall_continuousAt}\n \\leanok\n Let $(X_\\alpha)_{\\alpha \\in A}$ be a net (indexed by a directed set $A$) of $\\genspace$-valued\n random variables converging in probability to a random variable~$X$,\n $X_\\alpha \\tendsas X$ (along $A$).\n If $g \\colon \\genspaceA \\to \\genspaceB$ is a function which is continuous\n at every point of some Borel set $\\genspaceA_0 \\subseteq \\genspaceA$ such that\n $\\PR[X \\in \\genspaceA_0] = 1$,\n then $g(X_\\alpha) \\tendsas g(X)$ (along $A$).\n\\end{theorem}\n\n\\begin{proof}\n \\leanok\n\n Let $C$ be the event that $X_\\alpha \\to X$. By assumption, $\\PR[C] = 1$.\n\n Let $S$ be the event that $X \\in \\genspaceA_0$. By assumption, $\\PR[S] = 1$.\n\n Note that $\\PR [C \\cap S] = 1$. For any $\\omega \\in C \\cap S$\n we have $X_\\alpha(\\omega) \\to X(\\omega) \\in \\genspaceA_0$. Since $g$\n is continuous at $X(\\omega) \\in \\genspaceA_0$ by assumption, we get from this that\n $g\\big(X_\\alpha(\\omega)\\big) \\to g\\big(X(\\omega)\\big)$. It follows that\n $\\PR\\Big[ g\\big(X_\\alpha(\\omega)\\big) \\to g\\big(X(\\omega) \\Big] \\ge \\PR[C \\cap S] = 1$,\n so $g(X_\\alpha) \\tendsas g(X)$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen MeasureTheory Filter Topology\n\nopen scoped ENNReal\n\n\ntheorem ae_tendsto_comp_of_ae_tendsto_of_forall_continuousAt {ι : Type*} {F : Filter ι}\n {rvs : ι → Ω → X} {rv : Ω → X} (g_cont : ∀ x ∈ X₀, ContinuousAt g x)\n (rv_supp : ∀ᵐ ω ∂P, rv ω ∈ X₀) (rvs_lim_as : ∀ᵐ ω ∂P, Tendsto (rvs · ω) F (𝓝 (rv ω))) :\n ∀ᵐ ω ∂P, Tendsto (fun i ↦ g (rvs i ω)) F (𝓝 (g (rv ω))) := by sorry"} -{"project_name": "ContinuousMappingLaw", "name": "ProbabilityMeasure.tendsto_map_of_forall_continuousAt", "type": "theorem", "title": "Continuous Mapping Theorem (convergence in distribution version)", "informal_statement": "\\leanok\n Let $(\\mu_n)_{n \\in \\N}$ be a sequence of Borel probability\n measures on $\\genspaceA$ converging weakly to a Borel probability\n measure $\\mu$, i.e., $\\mu_n \\tendsweakly \\mu$.\n Let $g \\colon \\genspaceA \\to \\genspaceB$ be a measurable function.\n Assume that $g$ is continuous\n at every point of some Borel set $\\genspaceA_0 \\subseteq \\genspaceA$ such that\n $\\mu[X \\in \\genspaceA_0] = 1$.\n Then we have $g_* \\mu_n \\tendsweakly g_* \\mu$, where\n $g_*$ denotes the push-forward of measures.", "informal_proof": "\\chapter{The Continuous Mapping Theorem, Convergence in Distribution Version}\n\nThis section contains a proof of the convergence in distribution version of the Continuous Mapping\nTheorem.\nSee \\url{https://en.wikipedia.org/wiki/Continuous_mapping_theorem} and\nBillingsley \"Convergence of Probability Measures\" (2nd ed), Theorem 2.7.\n\nLet $\\genspaceA$ and $\\genspaceB$ be two metric spaces.\n%, equipped with their respective Borel sigma algebras.\n%$\\borelOf{\\genspaceA}$ and $\\borelOf{\\genspaceB}$\n\n\\begin{lemma}[Preimage closure lemma]\n \\label{lem:subset_preimage_closure}\n \\lean{inter_closure_preimage_ss_preimage_closure_of_forall_continuousAt}\n \\leanok\n Let $g \\colon \\genspaceA \\to \\genspaceB$ be a measurable function\n and let $\\genspace_0 \\subseteq \\genspaceA$ be a set such that $g$\n is continuous at every point of $\\genspace_0$.\n Then for any set $B \\subseteq \\genspaceB$ we have\n \\begin{align*}\n \\genspaceA_0 \\cap \\closure{g^{-1}(B)} \\subseteq g^{-1}(\\closure{B}) .\n \\end{align*}\n\\end{lemma}\n\\begin{proof}\n % \\uses{}\n \\leanok\n Suppose $x \\in \\genspaceA_0 \\cap \\closure{g^{-1}(B)}$.\n Since $x \\in \\closure{g^{-1}(B)}$, there exists\n a sequence $(x_n)_{n \\in \\N}$ in $g^{-1}(B)$ such that\n $x_n \\to x$ as $n \\to \\infty$.\n Since $x \\in \\genspaceA_0$, $g$ is continuous at $x$,\n and therefore $g(x_n) \\to g(x)$ as $n \\to \\infty$.\n Since $g(x_n) \\in B$ for all $n$, we have $g(x) \\in \\closure{B}$,\n and therefore $x \\in g^{-1}(\\closure{B})$.\n\\end{proof}\n\n\\begin{theorem}[Continuous Mapping Theorem (convergence in distribution version)]\n \\label{thm:cont_map_thm_law}\n \\lean{ProbabilityMeasure.tendsto_map_of_forall_continuousAt}\n \\leanok\n Let $(\\mu_n)_{n \\in \\N}$ be a sequence of Borel probability\n measures on $\\genspaceA$ converging weakly to a Borel probability\n measure $\\mu$, i.e., $\\mu_n \\tendsweakly \\mu$.\n Let $g \\colon \\genspaceA \\to \\genspaceB$ be a measurable function.\n Assume that $g$ is continuous\n at every point of some Borel set $\\genspaceA_0 \\subseteq \\genspaceA$ such that\n $\\mu[X \\in \\genspaceA_0] = 1$.\n Then we have $g_* \\mu_n \\tendsweakly g_* \\mu$, where\n $g_*$ denotes the push-forward of measures.\n\\end{theorem}\n\\begin{proof}\n \\uses{lem:subset_preimage_closure}\n \\leanok\n By the portmanteau theorem, it suffices to show that for\n any closed set $F \\subseteq \\genspaceB$ we have\n \\begin{align*}\n \\limsup_{n \\to \\infty} g_* \\mu_n (F) \\; \\le \\; g_* \\mu (F) .\n \\end{align*}\n Recall that push-forwards are defined so that, e.g.,\n $g_* \\mu_n (F) = \\mu_n (g^{-1} (F))$.\n\n Calculate, using the assumptions\n $\\mu_n \\tendsweakly \\mu$ (with portmanteau characterization again)\n and $\\mu[\\genspaceA_0^{\\mathrm{c}}] = 0$\n and Lemma~\\ref{lem:subset_preimage_closure}:\n \\begin{align*}\n & \\limsup_{n \\to \\infty} \\mu_n [g^{-1} (F)] \\\\\n \\le \\; & \\limsup_{n \\to \\infty} \\mu_n \\big[ \\closure{g^{-1} (F)} \\big] \\\\\n \\le \\; & \\mu \\big[ \\closure{g^{-1} (F)} \\big] \\\\\n %\\overset{\\text{L \\ref{lem:subset_preimage_closure}}}{\\le} \\;\n = \\;\n & \\mu \\big[ \\genspaceA_0 \\cap \\closure{g^{-1} (F)} \\big] \\\\\n \\le \\; & \\mu \\big[ g^{-1} (\\closure{F}) \\big]\n \\end{align*}\n If $F \\subseteq \\genspaceB$ is closed then\n the last expression is\n $\\mu \\big[ g^{-1} (\\closure{F}) \\big] = g_* \\mu (F)$,\n and the proof is thus complete.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen MeasureTheory ProbabilityTheory Filter Topology ENNReal NNReal\n\nopen scoped ENNReal\n\n\ntheorem ProbabilityMeasure.tendsto_map_of_forall_continuousAt\n (g_cont : ∀ x ∈ X₀, ContinuousAt g x) (g_mble : Measurable g)\n (P_supp : ∀ᵐ x ∂(P.toMeasure), x ∈ X₀) (Ps_lim : Tendsto Ps atTop (𝓝 P)) :\n Tendsto (fun n ↦ (Ps n).map g_mble.aemeasurable) atTop (𝓝 (P.map g_mble.aemeasurable)) := by sorry"} -{"project_name": "CriticalLineTheorem", "name": "critical_line", "type": "theorem", "title": "Critical Line Theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Critical Line Theorem}\n\nThis section contains a (stub of a) proof of the critical line theorem.\nSee \\url{https://en.wikipedia.org/wiki/Riemann_hypothesis#Zeros_on_the_critical_line} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Critical Line Theorem]\n \\label{thm:critical-line-theorem}\n \\lean{critical_line}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set\n\n\ntheorem critical_line : {s : ℂ | riemannZeta s = 0 ∧ s.re = 1 / 2}.Infinite := by sorry"} -{"project_name": "DeBruijnErdos", "name": "SimpleGraph.colorable_of_finitely_colorable", "type": "theorem", "title": "De Bruijn-Erd\\H{o}s Theorem (Graph Coloring)", "informal_statement": "If for an infinite graph $G$, the chromatic number of every finite subgraph is at most a finite integer $k$, then the chromatic number of $G$ is also at most $k$.", "informal_proof": "\n\\chapter{The De Bruijn-Erd\\H{o}s Theorem for Graph Coloring}\n\nThis section contains a proof of the De Bruijn-Erd\\H{o}s theorem for graph coloring. The proof, attributed to Gottschalk (1951), relies on Tychonoff's compactness theorem.\nSee \\url{https://en.wikipedia.org/wiki/De_Bruijn%E2%80%93Erd%C5%91s_theorem_(graph_theory)} for more details.\n\n\\begin{lemma}[The Space of Colorings is Compact]\n \\label{lem:coloring_space_compact}\n \\lean{colorings_space_compact}\n Let $G=(V, E)$ be a graph and let $C$ be a finite set of $k$ colors. The space $X = C^V$ of all functions from the vertex set $V$ to $C$, endowed with the product topology, is a compact topological space.\n\\end{lemma}\n\n\\begin{proof}\nWe equip the finite set of colors $C$ with the discrete topology. In this topology, every subset of $C$ is open. Since $C$ is a finite set, it is compact.\n\nThe space $X = C^V$ is the generalized product of the space $C$ indexed by the vertex set $V$. By Tychonoff's theorem, the product of any collection of compact topological spaces is itself compact with respect to the product topology.\n\nSince $X$ is a product of compact spaces, it is compact.\n\\end{proof}\n\n\\begin{lemma}[Subspaces of Valid Colorings are Closed]\n \\label{lem:valid_colorings_closed}\n \\lean{valid_colorings_is_closed}\n For any finite subgraph $F$ of $G$, the set $X_F \\subseteq X$ consisting of all color assignments that constitute a valid $k$-coloring of $F$ is a closed set in the product topology.\n\\end{lemma}\n\n\\begin{proof}\nA coloring $c \\in X$ is a valid coloring of the finite subgraph $F=(V_F, E_F)$ if and only if for every edge $\\{u, v\\} \\in E_F$, the colors assigned to vertices $u$ and $v$ are different; that is, $c(u) \\neq c(v)$.\n\nThus, the set $X_F$ can be expressed as the intersection of sets:\n$$ X_F = \\bigcap_{\\{u, v\\} \\in E_F} \\{ c \\in X \\mid c(u) \\neq c(v) \\} $$\n\nA finite intersection of closed sets is closed, so it suffices to show that for each edge $\\{u, v\\}$ in the finite subgraph $F$, the set of colorings where $u$ and $v$ have different colors is closed. For a given edge $\\{u, v\\}$, this can itself be expressed as the finite union of sets for particular valid color values. The individual sets are closed in the product topology because they are defined by fixing the values of the coloring function at two coordinates, which corresponds to taking preimages of closed sets under continuous projection maps.\n\n\\end{proof}\n\n\\begin{lemma}[The Finite Intersection Property]\n \\label{lem:fip}\n \\lean{finite_intersection_property}\n The family of sets $\\mathcal{F} = \\{X_F \\mid F \\text{ is a finite subgraph of } G\\}$ has the finite intersection property.\n\\end{lemma}\n\n\\begin{proof}\nTo prove the finite intersection property, we must show that any finite intersection of sets from $\\mathcal{F}$ is non-empty. Consider a finite collection of such sets: $X_{F_1}, X_{F_2}, \\dots, X_{F_n}$. Their intersection is:\n$$ \\bigcap_{i=1}^{n} X_{F_i} $$\nAn element in this intersection is a color assignment that is a valid coloring for every subgraph $F_i$ simultaneously. This is equivalent to being a valid coloring for the union of these subgraphs.\nLet $F_{\\cup} = \\bigcup_{i=1}^{n} F_i$. The union of a finite number of finite graphs is still a finite subgraph of $G$.\n\nThe central premise of the theorem is that every finite subgraph of $G$ is $k$-colorable. Since $F_{\\cup}$ is a finite subgraph of $G$, there must exist at least one valid $k$-coloring for it. This means the set of valid colorings for $F_{\\cup}$, which is precisely $\\bigcap_{i=1}^{n} X_{F_i}$, is non-empty.\n\nThus, the family $\\mathcal{F}$ has the finite intersection property.\n\\end{proof}\n\n\\begin{theorem}[De Bruijn-Erd\\H{o}s Theorem (Graph Coloring)]\n \\label{thm:de_bruijn_erdos}\n \\lean{SimpleGraph.colorable_of_finitely_colorable}\n If for an infinite graph $G$, the chromatic number of every finite subgraph is at most a finite integer $k$, then the chromatic number of $G$ is also at most $k$.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:coloring_space_compact, lem:valid_colorings_closed, lem:fip}\n Let $C$ be a set of $k$ colors.\n By Lemma~\\ref{lem:coloring_space_compact}, the space $X = C^V$ of all possible assignments of colors to the vertices of $G$ is compact.\n By Lemma~\\ref{lem:valid_colorings_closed}, for each finite subgraph $F \\subset G$, the subset $X_F$ of valid $k$-colorings for $F$ is a closed set in $X$.\n By Lemma~\\ref{lem:fip}, the collection of all such closed sets $\\{X_F\\}$ has the finite intersection property.\n\n A fundamental property of compact spaces is that any collection of closed subsets with the finite intersection property has a non-empty intersection. Therefore:\n $$ \\bigcap_{F \\subset G, F \\text{ finite}} X_F \\neq \\emptyset $$\n Let $c$ be a color assignment in this intersection. By being in the intersection, $c \\in X_F$ for every finite subgraph $F$ of $G$.\n\n We claim that $c$ is a valid $k$-coloring for the entire infinite graph $G$. To verify this, we must show that for any edge $\\{u, v\\}$ in $G$, $c(u) \\neq c(v)$.\n Consider an arbitrary edge $\\{u, v\\} \\in E(G)$. The subgraph $F_{uv}$ consisting of just this single edge and its two vertices is a finite subgraph of $G$.\n Since $c$ is in the total intersection, $c$ must be an element of $X_{F_{uv}}$. By definition, this means $c$ is a valid coloring for the subgraph $F_{uv}$, which requires that $c(u) \\neq c(v)$.\n\n Since this holds for every edge in $G$, $c$ is a valid $k$-coloring of $G$. The existence of such a coloring proves that the chromatic number of $G$, $\\chi(G)$, is at most $k$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set Topology Finset\n\n\ntheorem SimpleGraph.colorable_of_finitely_colorable\n (hS : ∀ F, (ValidFiniteColorings k G F).Nonempty) :\n G.Colorable k := by sorry"} -{"project_name": "DefinabilityNaturalsInRationals", "name": "nat_definable_in_rat", "type": "theorem", "title": "First order definability of N in Q", "informal_statement": "TODO", "informal_proof": "\\chapter{First order definability of N in Q}\n\nThis section contains a (stub of a) proof of the first-order definability of $\\mathbb{N}$ in $\\mathbb{Q}$.\nSee \\url{https://www.math.umd.edu/~laskow/713/Spring17/juliarobinson.pdf} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[First order definability of N in Q]\n \\label{thm:definability-naturals-in-rationals}\n \\lean{nat_definable_in_rat}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen FirstOrder FirstOrder.Language FirstOrder.Ring\n\n\ntheorem nat_definable_in_rat :\n (∅ : Set ℚ).Definable₁ Language.ring (Set.range (Nat.cast : ℕ → ℚ)) := by sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "exists_Ioo_subset_diff_self_of_measure_pos", "type": "theorem", "title": "Difference set of positive measure set contains an interval", "informal_statement": "%\\uses{}\n \\leanok\n Let $A \\subset \\mathbb{R}$ be a measurable set of positive Lebesgue measure.\n Then there exists a $\\delta > 0$ such that\n \\begin{align*}\n (-\\delta,\\delta) \\, \\subseteq \\, A - A .\n \\end{align*}", "informal_proof": "\n\\chapter{Difference set of a positive measure set contains an interval}\n\nThis section contains a proof of the fact that the difference set of a positive measure set contains an interval.\nThis proof comes from the Extreme Value Distribution Project from Kalle Kytölä and his students,\nsee \\url{https://kkytola.github.io/ExtremeValueProject/blueprint/}.\n\n\\begin{lemma}[Countably many connected components for an open set]\n \\label{lem:countably-many-connected-components-of-open}\n %\\uses{}\n \\lean{IsOpen.countable_connectedComponentsIn}\n \\leanok\n Let $X$ be a locally connected separable space. Then any open subset $U \\subseteq X$ has at\n most countably many connected components.\n\\end{lemma}\n\\begin{proof}\n % \\uses{}\n \\leanok\n TODO\n\\end{proof}\n\nFor subsets $A, B \\subseteq \\mathbb{R}$, we use the following notation for pointwise\nsum sets and difference sets:\n\\begin{align*}\n A + B & = \\set{ a + b \\; \\big| \\; a \\in A, \\, b \\in B } , \\\\\n A - B & = \\set{ a - b \\; \\big| \\; a \\in A, \\, b \\in B } .\n\\end{align*}\n\nWe denote by $\\Leb$ the Lebesgue measure on $\\mathbb{R}$.\n\n\\begin{lemma}[Finding a connected component with high overlap]\n \\label{lem:exists-high-overlap-connected}\n \\uses{lem:countably-many-connected-components-of-open}\n \\lean{exists_connected_measure_inter_gt_mul_measure}\n \\leanok\n Let $A \\subset \\mathbb{R}$ be a measurable set such that $0 < \\Leb[A] < +\\infty$.\n Then for any $r \\in [0,1)$, there exists a nontrivial connected set $J \\subset \\mathbb{R}$\n such that\n \\begin{align*}\n \\Leb[A \\cap J] \\; > \\; r \\, \\Leb[J] .\n \\end{align*}\n\\end{lemma}\n\\begin{proof}\n % \\uses{}\n % \\leanok\n Assume, without loss of generality, $0 < r < 1$.\n Since the Lebesgue measure is outer regular, we can find an open set $U \\subset \\mathbb{R}$\n such that $A \\subseteq U$ and $\\Leb[U] < r^{-1} \\, \\Leb[A]$.\n\n The open set $U$ has at most countably many connected components\n (which are in fact open intervals); denote\n by $(U_i)_{i \\in I}$ the indexed collection of them.\n\n Note that for at least one index $j \\in I$ we\n have $\\Leb[A \\cap U_j] > r \\Leb[U_j]$,\n because otherwise we get\n \\begin{align*}\n \\Leb[A] = \\Leb[A \\cap U]\n = \\, & \\sum_{i \\in I} \\Leb[A \\cap U_i] \\\\\n \\le \\, & r \\sum_{i \\in I} \\Leb[U_i] \\\\\n = \\, & r \\Leb[U],\n \\end{align*}\n contradicting the choice of $U$.\n\n Now $J = U_j$ has the desired properties.\n\\end{proof}\n\n\\begin{lemma}[Finding an interval with high overlap]\n \\label{lem:exists-high-overlap-interval}\n \\uses{lem:exists-high-overlap-connected}\n \\lean{exists_interval_high_overlap}\n \\leanok\n Let $A \\subset \\mathbb{R}$ be a measurable set such that $0 < \\Leb[A] < +\\infty$.\n Then for any $r \\in [0,1)$, there exists a nontrivial closed interval $[a,b] \\subset \\mathbb{R}$\n such that\n \\begin{align*}\n \\Leb[A \\cap J] \\; > \\; r \\, \\Leb[J] .\n \\end{align*}\n\\end{lemma}\n\\begin{proof}\n This follows directly from Lemma~\\ref{lem:exists-high-overlap-interval}\n by taking the closure of the connected set $J$, which is an interval because any bounded\n connected subset of $\\mathbb{R}$ is an interval.\n\\end{proof}\n\n\n\\begin{theorem}[Difference set of positive measure set contains an interval]\n \\label{thm:difference-set-contains-interval}\n %\\uses{}\n \\lean{exists_Ioo_subset_diff_self_of_measure_pos}\n \\leanok\n Let $A \\subset \\mathbb{R}$ be a measurable set of positive Lebesgue measure.\n Then there exists a $\\delta > 0$ such that\n \\begin{align*}\n (-\\delta,\\delta) \\, \\subseteq \\, A - A .\n \\end{align*}\n\\end{theorem}\n\\begin{proof}\n \\uses{lem:exists-high-overlap-interval}\n % \\leanok\n Pick a measurable subset $A_0 \\subseteq A$ such that\n $0 < \\Leb[A_0] < +\\infty$.\n\n By Lemma~\\ref{lem:exists-high-overlap-interval}, we can find a nontrivial interval~$J$\n such that $\\Leb[A_0 \\cap J] > \\frac{3}{4} \\Leb[J]$.\n Let $\\delta = \\frac{1}{2} \\Leb[J]$.\n We claim that $(-\\delta,\\delta) \\subseteq A_0 - A_0$ (which then\n clearly implies the assertion of the lemma).\n Indeed, suppose $t \\in (-\\delta,\\delta)$.\n Then by Lemma~\\ref{lem:overlapping-union-interval-copies},\n $(t+J) \\cup J$ is an interval of length less than $\\frac{3}{2} \\Leb[J]$.\n Moreover, we have $A_0 \\cap J \\subseteq (t+J) \\cup J$ and\n $t+(A_0 \\cap J) \\subseteq (t+J) \\cup J$. Now note that\n \\begin{align*}\n \\Leb[t + (A_0 \\cap J)] = \\Leb[A_0 \\cap J] > \\frac{3}{4} \\Leb[J] .\n \\end{align*}\n If the sets $t + (A_0 \\cap J)$ and $(A_0 \\cap J)$ were disjoint, then\n the measure of $(A_0 \\cap J) \\cup (t+(A_0 \\cap J))$ would thus be\n greater than $\\frac{3}{2} \\Leb[J]$, which is impossible given the length\n of the interval $(t+J) \\cup J$ is less than $\\frac{3}{2} \\Leb[J]$.\n Therefore there exists a point $a \\in (t + (A_0 \\cap J)) \\cap (A_0 \\cap J)$.\n Denoting $a' = a - t$, we have $a, a' \\in A_0 \\cap J \\subseteq A_0$\n and $t = a - a' \\in A_0 - A_0 \\subseteq A - A$. Since $t \\in (-\\delta,\\delta)$\n was arbitrary, this proves the assertion.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Real Set Pointwise MeasureTheory\n\n\ntheorem exists_Ioo_subset_diff_self_of_measure_pos {A : Set ℝ}\n (A_mble : MeasurableSet A) (A_pos : 0 < volume A) :\n ∃ δ > 0, Ioo (-δ) δ ⊆ A - A := by sorry"} -{"project_name": "DillerDressTheorem", "name": "diller_dress", "type": "theorem", "title": "Diller–Dress theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Diller–Dress theorem}\n\nThis section contains a (stub of a) proof of the Diller–Dress theorem.\nSee \\url{https://en.wikipedia.org/wiki/Pythagorean_field} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Diller–Dress theorem]\n \\label{thm:diller-dress-theorem}\n \\lean{diller_dress}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem diller_dress (K L : Type*) [Field K] [Field L] [Algebra K L] [Module.Finite K L]\n [Pythagorean L] : Pythagorean K := by sorry"} -{"project_name": "Dilworth", "name": "dilworth", "type": "theorem", "title": "Dilworth's Theorem", "informal_statement": "In any finite partially ordered set $P$, the minimum number of chains in a chain partition is equal to the maximum size of an antichain.", "informal_proof": "\\chapter{Dilworth's Theorem}\n\nThis section contains a proof of Dilworth's Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Dilworth%27s_theorem} for more details.\n\n\\begin{definition}[Chain Partition]\n \\label{def:Chain_Partition}\n \\lean{PartialOrder.IsChainPartition}\n A chain partition of a poset $P$ is a collection of disjoint chains whose union is $P$.\n\\end{definition}\n\n\\begin{definition}[Full Antichains]\n \\label{def:Full_Antichain}\n \\lean{PartialOrder.fullAntichains}\n \\uses{def:Chain_Partition}\n We call an antichain $A$ in a poset $P$ a \\textit{full antichain} for a chain partition\n if it intersects every chain in that partition exactly once\n (equivalently, if it has size equal to the number of chains in the partition).\n\\end{definition}\n\n\\begin{definition}[Full Chain Maximizers]\n \\label{def:Full_Chain_Maximizers}\n \\lean{PartialOrder.fullChainMaximizers}\n \\uses{def:Chain_Partition, def:Full_Antichain}\n Given a chain partition of a poset $P$, we choose a set $A$ of \\textit{full chain maximizers} consisting of, from each chain $c_i$, a maximal element $a_i \\in c_i$ that belongs to some full antichain.\n\\end{definition}\n\n\\begin{lemma}[Full Chain Maximizers is an Antichain]\n \\label{lem:Full_Chain_Maximizers_is_an_Antichain}\n \\lean{PartialOrder.isAntichain_fullChainMaximizers}\n \\uses{def:Chain_Partition, def:Full_Antichain, def:Full_Chain_Maximizers}\n Let $P$ be a finite poset. Then the set of full chain maximizers constructed from any chain partition of $P$ comprise an antichain.\n\\end{lemma}\n\n\\begin{proof}\n Suppose, for the sake of contradiction, that $A$ is not an antichain. Then there exist $a_i, a_j \\in A$ with $i \\neq j$ such that $a_i < a_j$. By definition, $a_j$ is an element of some $k$-element antichain $A_j$. Since $A_j$ cannot have more than one element in any chain in $P'$, it must intersect every chain in the partition of $P'$ once. In particular, there exists an element $x \\in C_i \\cap A_j$.\n By the definition of $a_i$ as the maximal element of $C_i$ belonging to any $k$-antichain, and since $x \\in C_i$, we must have $x \\le a_i$.\n By transitivity, $x \\le a_i < a_j$, which implies $x < a_j$.\n However, this is a contradiction, as both $x$ and $a_j$ are elements of the antichain $A_j$, and thus cannot be comparable. Therefore, $A = \\{a_1, \\dots, a_k\\}$ must be an antichain.\n\\end{proof}\n\n\\begin{lemma}[Dilworth's Theorem, Inductive Step Case 1]\n \\label{lem:Dilworth_inductive_step_case1}\n \\lean{PartialOrder.dilworth_induction_greater_width}\n Let $P$ be a finite poset, and let $a$ be a maximal element of $P$. Let $P' = P \\setminus \\{a\\}$. Assume the conclusion of Dilworth's theorem holds for all posets smaller than $P$. If the width of $P$ is one greater than the width of $P'$, i.e., $w(P) = w(P') + 1$, then $P$ can be partitioned into $w(P)$ chains.\n\\end{lemma}\n\\begin{proof}\n By the induction hypothesis, $P'$ can be partitioned into $w(P') = w(P)-1$ chains. The set $\\{a\\}$ forms a new chain, since $a$ is a maximal element. Thus, we can partition $P$ into $(w(P)-1)+1=w(P)$ chains.\n\\end{proof}\n\n\\begin{lemma}[Dilworth's Theorem, Inductive Step Case 2]\n \\label{lem:Dilworth_inductive_step_case2}\n \\lean{PartialOrder.dilworth_induction_equal_width}\n \\uses{lem:Full_Chain_Maximizers_is_an_Antichain}\n Let $P$ be a finite poset, and let $a$ be a maximal element of $P$. Let $P' = P \\setminus \\{a\\}$. Assume Dilworth's theorem holds for all posets smaller than $P$. If the width of $P$ is equal to the width of $P'$, i.e., $w(P) = w(P')$, then $P$ can be partitioned into $w(P)$ chains.\n\\end{lemma}\n\\begin{proof}\n Let $r = w(P) = w(P')$. By the induction hypothesis, $P'$ can be partitioned into $r$ chains $C_1, \\dots, C_r$. Let $A = \\{a_1, \\dots, a_r\\}$ be the antichain of maximal elements from these chains, as constructed in Lemma \\ref{lem:Full_Chain_Maximizers_is_an_Antichain}.\n If $a$ were not comparable to any element in $A$, then $A \\cup \\{a\\}$ would be an antichain of size $r+1$ in $P$, which contradicts $w(P)=r$.\n Therefore, since $a$ is maximal in $P$, it must be greater than some element $a_i \\in A$.\n Let $K = \\{a\\} \\cup \\{x \\in C_i : x \\le a_i\\}$. Since $a > a_i$ and all elements in $C_i$ up to $a_i$ form a chain, $K$ is a new chain in $P$.\n Consider the remaining poset $P \\setminus K$. Any antichain in $P \\setminus K$ can have at most $r-1$ elements. This is because any antichain of size $r$ in $P'$ must contain one element from each chain $C_j$, but we have removed from $C_i$ the element $a_i$ and all elements below it that could have been part of such an antichain.\n By the induction hypothesis, $P \\setminus K$ can be partitioned into $r-1$ chains. Together with the chain $K$, we have a partition of $P$ into $(r-1)+1=r$ chains.\n\\end{proof}\n\n\\begin{theorem}[Dilworth's Theorem]\n \\label{thm:Dilworths_Theorem}\n \\lean{PartialOrder.dilworth}\n In any finite partially ordered set $P$, the minimum number of chains in a chain partition is equal to the maximum size of an antichain.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:Full_Chain_Maximizers_is_an_Antichain, lem:Dilworth_inductive_step_case1, lem:Dilworth_inductive_step_case2}\n\n Let $w(P) = r$ be the size of the largest antichain in $P$. The proof proceeds by induction on the size of the poset, $|P|=n$. The base case, $n=1$, is trivial.\n Assume the theorem holds for all posets with size less than $n$. Let $a$ be a maximal element in $P$, and let $P' = P \\setminus \\{a\\}$. Let $w(P') = k$ be the size of the largest antichain in $P'$. We know that $k \\le r$ and either $k=r$ or $k=r-1$.\n\n Case 1: $k = r-1$. This case is handled by Lemma \\ref{lem:Dilworth_inductive_step_case1}.\n\n Case 2: $k=r$. This case is handled by Lemma \\ref{lem:Dilworth_inductive_step_case2}.\n\n Thus, in both cases, $P$ can be partitioned into $r$ chains.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Finset Nat\n\n\ntheorem dilworth (S : Finset P) :\n IsLeast {k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧\n C.card = k} (width S) := by sorry"} -{"project_name": "ErdosDushnikMillerTheorem", "name": "erdos_dushnik_miller", "type": "theorem", "title": "Erdős–Dushnik–Miller theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Erdős–Dushnik–Miller theorem}\n\nThis section contains a (stub of a) proof of the Erdős–Dushnik–Miller theorem.\nSee \\url{https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Dushnik%E2%80%93Miller_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Erdős–Dushnik–Miller theorem]\n \\label{thm:erdos-dushnik-miller-theorem}\n \\lean{erdos_dushnik_miller}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Cardinal in\n\n\ntheorem erdos_dushnik_miller\n {V : Type*} [Infinite V] (G : SimpleGraph V) :\n (∃ s : Set V, G.IsClique s ∧ #s = #V) ∨\n (∃ s : Set V, G.IsIndepSet s ∧ ℵ₀ ≤ #s) := by sorry"} -{"project_name": "ErdosGallaiTheorem", "name": "ErdosGallaiTheorem", "type": "theorem", "title": "Erdős–Gallai theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Erdős–Gallai theorem}\n\nThis section contains a (stub of a) proof of the Erdős–Gallai theorem.\nSee \\url{https://en.wikipedia.org/wiki/Erdős–Gallai_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Erdős–Gallai theorem]\n \\label{thm:erdos-gallai-theorem}\n \\lean{ErdosGallaiTheorem}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem ErdosGallaiTheorem (d : List ℕ) (hd : d.SortedGE) :\n (∃ V, ∃ fV : Fintype V, ∃ G : SimpleGraph V, ∃ dG : DecidableRel G.Adj, degreeList G = d) ↔\n Even d.sum ∧\n ∀ k ∈ Set.Ioc 0 d.length,\n (d.take k).sum ≤ k * (k - 1) + ((d.drop k).map fun x => min x k).sum := by sorry"} -{"project_name": "ErdosKacTheorem", "name": "erdos_kac", "type": "theorem", "title": "Erdős–Kac theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Erdős–Kac theorem}\n\nThis section contains a (stub of a) proof of the Erdős–Kac theorem.\nSee \\url{https://en.wikipedia.org/wiki/Erdős–Kac_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Erdős–Kac theorem]\n \\label{thm:erdos-kac-theorem}\n \\lean{erdos_kac}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen scoped Classical ArithmeticFunction.omega\n\n\ntheorem erdos_kac (a b : ℝ) (hab : a < b) :\n Filter.Tendsto\n (fun N : ℕ =>\n ((Finset.Icc 1 N |>.filter fun n =>\n a ≤ normalizedOmega n ∧ normalizedOmega n ≤ b).card : ℝ) / (N : ℝ))\n Filter.atTop\n (nhds (stdNormalCDF b - stdNormalCDF a)) := by sorry"} -{"project_name": "FareySequence", "name": "farey_riemann_abs", "type": "theorem", "title": "Farey Sequence", "informal_statement": "TODO", "informal_proof": "\\chapter{Farey Sequence}\n\nThis section contains a (stub of a) proof of a property of the Farey sequence.\nSee \\url{https://en.wikipedia.org/wiki/Farey_sequence} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Farey Sequence]\n \\label{thm:farey-sequence}\n \\lean{farey_riemann_abs}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Rat Set Filter\n\n\ntheorem farey_riemann_abs :\n RiemannHypothesis ↔ ∀ r : ℝ,\n 1 / 2 < r → (fun n ↦ ∑' i : Fin (FareyCard n), |FareyDifference n i|)\n =O[atTop] (fun n ↦ (↑n : ℝ) ^ r) := by sorry"} -{"project_name": "FeitThompsonTheorem", "name": "feit_thompson", "type": "theorem", "title": "Feit–Thompson theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Feit–Thompson theorem}\n\nThis section contains a (stub of a) proof of the Feit–Thompson theorem.\nSee \\url{https://en.wikipedia.org/wiki/Feit–Thompson_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Feit–Thompson theorem]\n \\label{thm:feit-thompson-theorem}\n \\lean{feit_thompson}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set Function Nat\n\n\ntheorem feit_thompson {G : Type u} [Fintype G] [Group G] (h : Odd (Fintype.card G)) :\n IsSolvable G := by sorry"} -{"project_name": "Fifteen", "name": "fifteen_theorem", "type": "theorem", "title": "The 15 Theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{The 15 Theorem}\n\nThis section contains a (stub of a) proof of the 15 Theorem (Conway-Schneeberger, proved by Bhargava in 2000), which states that a positive definite quadratic form with integer matrix coefficients that represents all positive integers up to 15 represents all positive integers.\n\nSee \\url{https://en.wikipedia.org/wiki/15_and_290_theorems} for more details.\n\nTODO: Expand this stubbed file by adding formal definitions and an informal proof.\n\n% TODO: add blueprint\n\n\\begin{theorem}[The 15 Theorem]\n \\label{thm:fifteen}\n \\lean{fifteen_theorem}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Matrix\n\n\ntheorem fifteen_theorem (M : Matrix (Fin n) (Fin n) ℤ)\n (hsymm : M.IsSymm)\n (hpos : M.PosDef)\n (hrep : ∀ m : ℕ, 0 < m → m ≤ 15 → M.represents m) :\n M.Universal := by sorry"} -{"project_name": "FinitelyManyPrimesDimOne", "name": "Ring.krullDimLE_one_of_finite_primeSpectrum", "type": "theorem", "title": "Finitely Many Primes $\\Rightarrow$ Dimension $\\leq 1$ (Stacks 0ALV)", "informal_statement": "\\leanok\nA Noetherian ring with finitely many prime ideals has Krull dimension $\\leq 1$.", "informal_proof": "\\chapter{Finitely Many Primes Implies Dimension \\texorpdfstring{$\\leq 1$}{≤ 1} (Stacks 0ALV)}\n\nThis section contains a proof of the fact that a Noetherian ring with finitely many prime ideals has Krull dimension $\\leq 1$.\nSee \\url{https://stacks.math.columbia.edu/tag/0ALV} for more details.\n\n\\begin{lemma}[Finite spectrum quotient]\n\\label{lem:finite_spectrum_quotient}\n\\lean{PrimeSpectrum.finite_quotient}\n\\leanok\nIf $R$ has finitely many prime ideals, then $R/I$ has finitely many prime ideals for any ideal $I$.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\nThe map $\\operatorname{Spec}(R/I) \\to \\operatorname{Spec}(R)$ induced by the quotient is injective, and an injection from a type into a finite type is finite.\n\\end{proof}\n\n\\begin{lemma}[Prime avoidance for maximal ideals]\n\\label{lem:prime_avoidance_maximal}\n\\lean{Ideal.exists_mem_not_mem_other_primes}\n\\leanok\nIf $\\mathfrak{m}$ is a maximal ideal in a ring with finitely many primes, there exists $y \\in \\mathfrak{m}$ with $y \\notin \\mathfrak{q}$ for every prime $\\mathfrak{q} \\neq \\mathfrak{m}$.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\nSince $\\mathfrak{m}$ is maximal, $\\mathfrak{m} \\not\\subseteq \\mathfrak{q}$ for every other prime $\\mathfrak{q}$ (if $\\mathfrak{m} \\subseteq \\mathfrak{q}$ then $\\mathfrak{m} = \\mathfrak{q}$ by maximality). By prime avoidance applied to the finite collection of other primes, $\\mathfrak{m} \\not\\subseteq \\bigcup \\mathfrak{q}$, so there exists such $y$.\n\\end{proof}\n\n\\begin{lemma}[Domain case: nonzero primes are maximal]\n\\label{lem:nonzero_prime_maximal_domain}\n\\lean{Ideal.IsPrime.isMaximal_of_finite_primeSpectrum}\n\\leanok\nIn a Noetherian domain with finitely many primes, every nonzero prime ideal is maximal.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\n\\uses{lem:prime_avoidance_maximal}\nSuppose $\\mathfrak{p}$ is a nonzero prime that is not maximal. Pick a maximal ideal $\\mathfrak{m} \\supseteq \\mathfrak{p}$. Since $R$ is a domain, $0$ is prime, giving the chain $0 \\subsetneq \\mathfrak{p} \\subseteq \\mathfrak{m}$, so $\\operatorname{height}(\\mathfrak{m}) \\geq 2$.\n\nBy Lemma~\\ref{lem:prime_avoidance_maximal}, pick $y \\in \\mathfrak{m}$ not in any other prime. Then $\\mathfrak{m}$ is the unique minimal prime over $(y)$. By Krull's principal ideal theorem, $\\operatorname{height}(\\mathfrak{m}) \\leq 1$, a contradiction.\n\\end{proof}\n\n\\begin{lemma}[Domain dimension bound]\n\\label{lem:domain_dim_bound}\n\\lean{Ring.krullDimLE_one_of_isDomain_of_finite_primeSpectrum}\n\\leanok\nA Noetherian domain with finitely many primes has Krull dimension $\\leq 1$.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\n\\uses{lem:nonzero_prime_maximal_domain}\nFollows immediately from Lemma~\\ref{lem:nonzero_prime_maximal_domain}: every nonzero prime is maximal, so $\\operatorname{KrullDimLE}\\ 1$ holds by \\texttt{Ring.KrullDimLE.mk₁'}.\n\\end{proof}\n\n\\begin{theorem}[Finitely Many Primes $\\Rightarrow$ Dimension $\\leq 1$ (Stacks 0ALV)]\n\\label{thm:finitely_many_primes_dim_one}\n\\lean{Ring.krullDimLE_one_of_finite_primeSpectrum}\n\\leanok\nA Noetherian ring with finitely many prime ideals has Krull dimension $\\leq 1$.\n\\end{theorem}\n\n\\begin{proof}\n\\leanok\n\\uses{lem:finite_spectrum_quotient, lem:domain_dim_bound}\nBy \\texttt{Ring.KrullDimLE.mk₁}, it suffices to show every prime ideal is either minimal or maximal. Let $I$ be a prime that is not minimal. Pick a minimal prime $\\mathfrak{q} \\leq I$ with $\\mathfrak{q} \\neq I$. The quotient $R/\\mathfrak{q}$ is a Noetherian domain with finitely many primes (Lemma~\\ref{lem:finite_spectrum_quotient}). By Lemma~\\ref{lem:domain_dim_bound}, $R/\\mathfrak{q}$ has dimension $\\leq 1$, so the image of $I$ in $R/\\mathfrak{q}$ --- being a nonzero prime --- is maximal. Pulling back along $R \\to R/\\mathfrak{q}$, $I$ is maximal in $R$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Ideal\n\n\ntheorem Ring.krullDimLE_one_of_finite_primeSpectrum\n [IsNoetherianRing R] [Finite (PrimeSpectrum R)] :\n Ring.KrullDimLE 1 R := by sorry"} -{"project_name": "Fitting", "name": "fitting", "type": "theorem", "title": "Fitting's theorem", "informal_statement": "If $M$ and $N$ are nilpotent normal subgroups of a group $G$, then their product $MN$ is also a nilpotent normal subgroup of $G$; if, moreover, $M$ is nilpotent of class $m$ and $N$ is nilpotent of class $N$, then $MN$ is nilpotent of class at most $m + n$.", "informal_proof": "\\chapter{Fitting's theorem}\n\nThis section contains a proof of Fitting's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Fitting's_theorem} for more details.\n\n\\begin{definition}\n \\label{def:commFin}\n \\lean{commFin}\n Suppose $G$ is a group. We define $[H_0, \\dots, H_n]$ for subgroups $H_0, \\dots, H_n$ of $G$\n inductively by $[H_0] = H_0$ and for $n \\geq 1$,\n \\begin{displaymath}\n [H_0, \\dots, H_n] = [[H_0, \\dots, H_{n-1}], H_n].\n \\end{displaymath}\n Here $[H, K]$ denotes the commutator subgroup, which is generated by\n $\\{[h, k] | h \\in H, k \\in K\\}$, where $[h, k] = hkh^{-1}k^{-1}$.\n\\end{definition}\n\n\\begin{lemma}\n \\label{lem:commFin_normal}\n \\lean{commFin_normal}\n Let $H_0, \\dots, H_n$ be normal subgroups of $G$. Then $[H_0, \\dots, H_n]$ is a normal subgroup of $G$.\n\\end{lemma}\n\\begin{proof}\n By induction on $n$. The inductive step uses the fact that if $H$, $K$ are normal subgroups of\n $G$, then $[H, K]$ is normal too.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:commFin_le}\n \\lean{commFin_le}\n Let $H_0, \\dots, H_n$ be normal subgroups of $G$. Let $I_0 < \\dots < I_k \\leq n$. Then $[H_0, \\dots, H_n] \\subseteq [H_{I_0}, \\dots, H_{I_k}]$.\n\\end{lemma}\n\\begin{proof}\n By induction on $n$. $n=0$ is trivial. Suppose $n \\geq 1$ and the lemma holds for $n - 1$.\n Note that $[H, K] \\subseteq H$ if $H$ is a normal subgroup of $G$.\n If $i_k < n$, then\n \\begin{displaymath}\n [H_0, \\dots, H_n] = [[H_0, \\dots, H_{n-1}], H_n] \\subseteq [H_0, \\dots, H_{n-1}] \\subseteq [H_{I_0}, \\dots, H_{I_k}].\n \\end{displaymath}\n If $i_k = n$, then\n \\begin{displaymath}\n [H_0, \\dots, H_n] = [[H_0, \\dots, H_{n-1}], H_{I_k}] \\subseteq[[H_{I_0}, \\dots, H_{I_{k-1}}], H_{I_k}] = [H_{I_0}, \\dots, H_{I_k}].\n \\end{displaymath}\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:mul_left_distrib}\n \\lean{mul_left_distrib}\n Let $H_0, \\dots, H_n, L$ be normal subgroups of $G$. Then\n \\begin{displaymath}\n [H_0 \\dots H_n, L] = [H_0, L] \\dots [H_n, L].\n \\end{displaymath}\n\\end{lemma}\n\\begin{proof}\n By induction on $n$. We only need to prove the identities for $n=1$.\n Let $h_0 \\in H_0$, $h_1 \\in H_1$, $x \\in L$. Then\n \\begin{displaymath}\n [h_0h_1, x] = h_0h_1xh_1^{-1}h_0^{-1}x^{-1} = [h_0, h_1xh_1^{-1}][h_1, x] \\in [H_0, L] [H_1, L].\n \\end{displaymath}\n So $[H_0H_1, L] \\subseteq [H_0, L][H_1, L]$. The other direction of the inclusion is trivial.\n\\end{proof}\n\n\\begin{theorem}\n \\label{thm:fitting}\n \\lean{fitting}\n \\uses{def:commFin}\n \\uses{lem:commFin_normal}\n \\uses{lem:commFin_le}\n \\uses{lem:mul_left_distrib}\n If $M$ and $N$ are nilpotent normal subgroups of a group $G$, then their product $MN$ is also a nilpotent normal subgroup of $G$; if, moreover, $M$ is nilpotent of class $m$ and $N$ is nilpotent of class $N$, then $MN$ is nilpotent of class at most $m + n$.\n\\end{theorem}\n\\begin{proof}\n For any group $K$, let $\\gamma_i(K)$, $i \\geq 0$ be the lower central series of $K$. Note that, using the notation above, $\\gamma_i(K) = [K, \\dots, K]$ with $i+1$ many $K$'s.\n We claim that $\\gamma_i(MN)$ is a product of terms of the form $[L_0, \\dots, L_i]$ where each $L_j$ is either $M$ or $N$.\n This is proved by induction on $i$. When $i=0$, $\\gamma_0(MN) = MN$ is a product of two terms $M$ and $N$, so the claim is satisfied.\n Suppose the claim holds for $i$. Then\n \\begin{displaymath}\n \\gamma_{i+1}(MN) = [\\gamma_i(MN), MN] = [\\gamma_i(MN), M] [\\gamma_i(MN), N],\n \\end{displaymath}\n the last equality from Lemma~\\ref{lem:mul_left_distrib}. So by induction hypothesis, the claim holds for $i+1$.\n If the nilpotency class of $M$ is $m$ and the nilpotency class of $N$ is $n$, then $\\gamma_m(M)=\\gamma_n(N)=\\{e\\}$.\n By our claim, $\\gamma_{m+n}(MN)$ is a product of terms of the form $[L_0, \\dots, L_{m+n}]$ where each $L_j$ is either $M$ or $N$.\n So at least $m+1$ of $L_j$ are equal to $M$ or at least $n+1$ of $L_j$ are equal to $N$.\n Therefore, by Lemma~\\ref{lem:commFin_le}, either\n \\begin{displaymath}\n [L_0, \\dots, L_{m+n}] \\subseteq [M, \\dots, M] = \\gamma_m(M) = \\{e\\}\n \\end{displaymath}\n with $m+1$ $M$'s in the second term, or\n \\begin{displaymath}\n [L_0, \\dots, L_{m+n}] \\subseteq [N, \\dots, N] = \\gamma_m(N) = \\{e\\}\n \\end{displaymath}\n with $n+1$ $N$'s in the second term.\n Either way, $[L_0, \\dots, L_{m+n}] = \\{e\\}$ and so $\\gamma_{m+n}(MN)=\\{e\\}$. This proves that $MN$ is nilpotent of class at most $m+n$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nset_option maxHeartbeats 1600000 in\n\nset_option maxHeartbeats 800000 in\n\n\nopen scoped commutatorElement\n\nopen Subgroup in\n\n\ntheorem fitting {G : Type*} [Group G] (M N : Subgroup G) (hM₁ : M.Normal) (hN₁ : N.Normal)\n (m n : ℕ)\n (hM₂ : Group.IsNilpotent M) (hM₃ : Group.nilpotencyClass M = m)\n (hN₂ : Group.IsNilpotent N) (hN₃ : Group.nilpotencyClass N = n) :\n ∃ _ : Group.IsNilpotent ↥(M ⊔ N), Group.nilpotencyClass ↥(M ⊔ N) ≤ m + n := by sorry"} -{"project_name": "FrankWolfe", "name": "frank_wolfe_convergence_rate", "type": "theorem", "title": "Convergence rate of Frank-Wolfe algorithm", "informal_statement": "TODO", "informal_proof": "\\chapter{Convergence rate of Frank-Wolfe algorithm}\n\nThis section contains a (stub of a) proof of the convergence rate of the Frank-Wolfe algorithm.\nSee \\url{https://en.wikipedia.org/wiki/Frank%E2%80%93Wolfe_algorithm} for more details.\n\nTODO: Expand this stubbed file by adding an informal proof.\n\n% TODO: add blueprint\n\n\\begin{theorem}[Convergence rate of Frank-Wolfe algorithm]\n \\label{thm:frank-wolfe}\n \\lean{frank_wolfe_convergence_rate}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set\n\n\ntheorem frank_wolfe_convergence_rate\n {D : Set (EuclideanSpace ℝ (Fin d))} {f : EuclideanSpace ℝ (Fin d) → ℝ} {L : NNReal}\n {lmo : EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)}\n {x₀ x_star : EuclideanSpace ℝ (Fin d)}\n (hD_compact : IsCompact D)\n (hD_convex : Convex ℝ D)\n (hf_convex : ConvexOn ℝ D f)\n (hf_diff : Differentiable ℝ f)\n (hf_smooth : LipschitzOnWith L (fderiv ℝ f) D)\n (hx₀_mem : x₀ ∈ D)\n (hx_star_mem : x_star ∈ D)\n (hx_star_min : IsMinOn f D x_star)\n (hlmo_mem : ∀ x ∈ D, lmo x ∈ D)\n (hlmo_min : ∀ x ∈ D, IsMinOn (fun s => fderiv ℝ f x s) D (lmo x))\n : ∃ C : ℝ, 0 < C ∧ ∀ k : ℕ,\n f (frankWolfeSeq lmo x₀ k) - f x_star ≤ C / ((k : ℝ) + 2) := by sorry"} -{"project_name": "FreimanTheorem", "name": "Freiman", "type": "theorem", "title": "Freiman's Theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Freiman's Theorem}\n\nThis section contains a (stub of a) proof of Freiman's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Freiman%27s_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Freiman's Theorem]\n \\label{thm:freiman-theorem}\n \\lean{Freiman}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat Finset Set Pointwise\n\n\ntheorem Freiman (K : ℝ) : ∃ dim size : ℕ,\n ∀ A : Finset ℤ, QuotSum A ≤ K →\n ∃ L : GFLP,\n ↑A ⊆ setOfGFLP L\n ∧ L.dim ≤ dim\n ∧ (setOfGFLP L).ncard ≤ size * A.card := by sorry"} -{"project_name": "FriedlanderIwaniecTheorem", "name": "friedlander_iwaniec", "type": "theorem", "title": "Friedlander--Iwaniec theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Friedlander--Iwaniec theorem}\n\nThis section contains a (stub of a) proof of the Friedlander--Iwaniec theorem.\nSee \\url{https://en.wikipedia.org/wiki/Friedlander%E2%80%93Iwaniec_theorem} for more details.\n\nTODO: Expand this stubbed file by adding an informal proof.\n\n% TODO: add blueprint\n\n\\begin{theorem}[Friedlander--Iwaniec theorem]\n \\label{thm:friedlander-iwaniec-theorem}\n \\lean{friedlander_iwaniec}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem friedlander_iwaniec : {p : ℕ | p.Prime ∧ ∃ a b, p = a ^ 2 + b ^ 4}.Infinite := by sorry"} -{"project_name": "Froda", "name": "Real.countable_not_continuousAt", "type": "theorem", "title": "Froda's Theorem", "informal_statement": "Let $f: \\mathbb{R} \\to \\mathbb{R}$ be a monotone function.\n The set of discontinuities of $f$ is at most countable.", "informal_proof": "\\chapter{Froda's Theorem}\n\nThis section contains a proof of Froda's Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Discontinuities_of_monotone_functions} (\"proof 2\") for more details.\n\n\\begin{lemma}[Monotone functions separate values at discontinuities]\n \\label{lem:Jump_of_Monotone}\n \\lean{jump_discontinuities_of_monotone}\n For a monotone function that is discontinuous at a point $x$,\n the supremum of the values of the function over inputs $y < x$\n is strictly less than the infimum of the values of the function over inputs $z > x$.\n\\end{lemma}\n\n\\begin{proof}\n Suppose the supremum were greater than or equal to this infimum.\n We argue that the function would then be continuous at $x$.\n We let $\\epsilon > 0$ be given, and we show there is a $\\delta > 0$ such that $f$ is within $\\epsilon$ of $f(x)$ on $(x - \\delta, x + \\delta)$.\n Note that there is a $y < x$ such that $f(y) + \\epsilon/2$ is greater than the supremum of the function values to the left of $x$.\n Similarly, there is a $z > x$ such that $f(z) - \\epsilon/2$ less than the infimum of the function values to the right of $x$.\n Using our assumption, these facts give us $f(z) - f(y) < \\epsilon$.\n We may therefore choose $\\delta = \\min(x - y, z - x)$.\n This guarantees that for any $w$ such that $|w - x| < \\delta$,\n we have $f(w)$ is within $\\epsilon$ of both $f(y)$ and $f(z)$,\n and therefore within $\\epsilon$ of $f(x)$.\n\\end{proof}\n\n\\begin{lemma}[Upper and Lower Limits of different values of a Monotone Function]\n \\label{lem:upper_lower}\n \\lean{Monotone.sInf_Ioi_le_sSup_Iio}\n For a monotone function $f$ and inputs $x < y$,\n the infimum of the values of the function over inputs $z > x$\n is less than or equal to the supremum of the values of the function over inputs $z < y$.\n\\end{lemma}\n\n\\begin{proof}\n Consider $z$ such that $x < z < y$.\n We have that $z$ is included in both the set of values to the right of $x$\n and the set of values to the left of $y$.\n Therefore, the infimum of the function values to the right of $x$\n is less than or equal to $f(z)$,\n which is less than or equal to the supremum of the function values to the left of $y$.\n\\end{proof}\n\n\\begin{theorem}[Froda's Theorem]\n \\label{thm:froda}\n \\lean{Real.countable_not_continuousAt}\n \\uses{lem:Jump_of_Monotone}\n \\uses{lem:upper_lower}\n Let $f: \\mathbb{R} \\to \\mathbb{R}$ be a monotone function.\n The set of discontinuities of $f$ is at most countable.\n\\end{theorem}\n\n\\begin{proof}\n Let $D$ be the set of discontinuities of $f$ in $[a, b]$.\n For any $x \\in D$,\n we have that the supremum of the values of the function over inputs $y < x$, which we can denote $f(x^-)$, is strictly less than the infimum of the values of the function over inputs $z > x$ which we can denote $f(x^+)$.\n There is therefore a rational number $q_x$ such that:\n \\[f(x^-) < q_x < f(x^+)\\]\n And since the function is monotone, we have that for any $y < x$ discontinuities,\n $q_y \\leq f(y^+) \\leq f(x^-) < q_x$.\n Therefore, we can use the axiom of choice to construct the mapping $x \\mapsto q_x$, which is injective from the set of discontinuities $D$\n to the set of rational numbers $\\mathbb{Q}$, and $D$ is therefore countable\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set Filter Topology\n\n\ntheorem Real.countable_not_continuousAt (f : ℝ → ℝ) (h_mono : Monotone f) :\n {x | ¬ ContinuousAt f x}.Countable := by sorry"} -{"project_name": "GaussLucas", "name": "Complex.mem_convexHull_roots_of_mem_derivative_roots", "type": "theorem", "title": "Gauss-Lucas", "informal_statement": "\\leanok\n If P is a polynomial with complex coefficients, all roots of P' belong to the convex hull of the set of zeros of P.", "informal_proof": "\\chapter{The Gauss-Lucas Theorem}\n\nThis section contains a proof of the Gauss-Lucas Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Gauss%E2%80%93Lucas_theorem} for more details.\n\n\\begin{lemma}[Logarithmic Derivative of a Complex Polynomial]\n \\label{lem:logDeriv_Polynomial}\n \\lean{logDeriv_Polynomial}\n \\leanok\n The logarithmic derivative of a complex polynomial\n is the sum of the inverses of its factors.\n\\end{lemma}\n\n\\begin{proof}\nLet the polynomial be $P(z) = c \\prod_{i=1}^{n} (z - r_i)$, where $r_i$ are the roots of the polynomial.\nTaking the natural logarithm of both sides gives:\n$$ \\ln P(z) = \\ln c + \\sum_{i=1}^{n} \\ln(z - r_i) $$\nThe logarithmic derivative is the derivative of $\\ln P(z)$, which is $\\frac{P'(z)}{P(z)}$. Differentiating the right-hand side with respect to $z$ yields:\n$$ \\frac{P'(z)}{P(z)} = \\sum_{i=1}^{n} \\frac{1}{z - r_i} $$\nThis proves that the logarithmic derivative is the sum of the inverses of the terms $(z - r_i)$.\n\\end{proof}\n\n\\begin{lemma}[Sum of inverses of polynomial factors on a root]\n \\label{lem:sum_inv_sub_roots_eq_zero}\n \\lean{sum_inv_sub_roots_eq_zero}\n \\leanok\n If $z$ is a root of the derivative of a polynomial $p$, but not a root of $p$ itself,\n then the sum of the inverses of the differences between x and each root of $p$ is zero.\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:logDeriv_Polynomial}\n From Lemma~\\ref{lem:logDeriv_Polynomial}, we have the identity $\\frac{P'(z)}{P(z)} = \\sum_{i=1}^{n} \\frac{1}{z - r_i}$.\n The lemma states that $z$ is a root of the derivative, so $P'(z) = 0$. It also states that $z$ is not a root of $P$ itself, which means $P(z) \\neq 0$.\n Substituting these conditions into the identity gives:\n $$ \\frac{0}{P(z)} = \\sum_{i=1}^{n} \\frac{1}{z - r_i} $$\n Therefore, we must have:\n $$ \\sum_{i=1}^{n} \\frac{1}{z - r_i} = 0 $$\n\\end{proof}\n\n\\begin{lemma}[The weighting of roots has non-zero total weight]\n \\label{lem:sum_norm_sq_sub_inv_nonzero}\n \\lean{sum_norm_sq_sub_inv_nonzero}\n \\leanok\n The weighting which assigns to each root $a$ the value\n $(1 / ‖z - a‖^2)$ has a non-zero total weight.\n\\end{lemma}\n\n\\begin{proof}\n The total weight $W$ is the sum of the individual weights for each root $r_i$ of a polynomial $P$:\n $$ W = \\sum_{i=1}^{n} \\frac{1}{|z - r_i|^2} $$\n This weighting is used in the context where $z$ is a root of $P'$ but not a root of $P$. Therefore, $z \\neq r_i$ for all $i=1, \\dots, n$.\n The term $|z - r_i|$ represents the Euclidean distance between $z$ and $r_i$. Since $z \\neq r_i$, this distance is strictly greater than zero.\n $$ |z - r_i| > 0 $$\n The square of any non-zero real number is strictly positive, so $|z - r_i|^2 > 0$.\n Each term in the sum, $\\frac{1}{|z - r_i|^2}$, is the reciprocal of a strictly positive number, and is therefore strictly positive itself.\n The total weight $W$ is a finite sum of strictly positive real numbers. Such a sum must be strictly positive and therefore cannot be zero.\n\\end{proof}\n\n\\begin{lemma}[The derivative root is a weighted average of roots]\n \\label{lem:deriv_root_as_weighted_average_of_roots}\n \\lean{deriv_root_as_weighted_average_of_roots}\n \\leanok\n If z is a root of the derivative of a polynomial p, but not a root of p itself,\n then it can be expressed as a weighted average of the roots of p.\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:sum_inv_sub_roots_eq_zero, lem:sum_norm_sq_sub_inv_nonzero}\n Starting from the result of Lemma~\\ref{lem:sum_inv_sub_roots_eq_zero}:\n $$ \\sum_{i=1}^{n} \\frac{1}{z - r_i} = 0 $$\n We can rewrite each term in the sum using its complex conjugate:\n $$ \\frac{1}{z - r_i} = \\frac{\\overline{z - r_i}}{|z - r_i|^2} = \\frac{\\bar{z} - \\bar{r_i}}{|z - r_i|^2} $$\n Substituting this back into the sum gives:\n $$ \\sum_{i=1}^{n} \\frac{\\bar{z} - \\bar{r_i}}{|z - r_i|^2} = 0 $$\n We can split the sum into two parts:\n $$ \\sum_{i=1}^{n} \\frac{\\bar{z}}{|z - r_i|^2} - \\sum_{i=1}^{n} \\frac{\\bar{r_i}}{|z - r_i|^2} = 0 $$\n Rearranging the equation to solve for $\\bar{z}$:\n $$ \\bar{z} \\sum_{i=1}^{n} \\frac{1}{|z - r_i|^2} = \\sum_{i=1}^{n} \\frac{\\bar{r_i}}{|z - r_i|^2} $$\n Taking the complex conjugate of the entire equation (and noting that $|z - r_i|^2$ is a real number) yields:\n $$ z \\sum_{i=1}^{n} \\frac{1}{|z - r_i|^2} = \\sum_{i=1}^{n} \\frac{r_i}{|z - r_i|^2} $$\n Let us define positive real weights $w_i = \\frac{1}{|z - r_i|^2}$. The equation becomes $z \\sum_{i=1}^{n} w_i = \\sum_{i=1}^{n} w_i r_i$.\n Solving for $z$, we get:\n $$ z = \\frac{\\sum_{i=1}^{n} w_i r_i}{\\sum_{i=1}^{n} w_i} $$\n This shows that $z$ is a weighted average of the polynomial's roots $r_i$ with positive real coefficients.\n\\end{proof}\n\n\\begin{theorem}[Gauss-Lucas]\n \\label{thm:gauss_lucas}\n \\lean{Complex.mem_convexHull_roots_of_mem_derivative_roots}\n \\leanok\n If P is a polynomial with complex coefficients, all roots of P' belong to the convex hull of the set of zeros of P.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:deriv_root_as_weighted_average_of_roots, lem:sum_norm_sq_sub_inv_nonzero}\n Let $z$ be a root of the derivative, $P'(z)=0$. We want to show that $z$ lies in the convex hull of the set of roots of $P$, denoted $R = \\{r_1, r_2, \\dots, r_n\\}$.\n\n We consider two cases for the root $z$:\n\n \\begin{itemize}\n \\item \\textbf{Case 1: $z$ is also a root of $P$.}\n If $z$ is one of the roots of $P$, then $z \\in R$. A point that belongs to a set of points is, by definition, contained within the convex hull of that set.\n\n \\item \\textbf{Case 2: $z$ is not a root of $P$.}\n In this case, the conditions for Lemma~\\ref{lem:deriv_root_as_weighted_average_of_roots} are met. We can express $z$ as a weighted average:\n $$ z = \\frac{\\sum_{i=1}^{n} w_i r_i}{\\sum_{i=1}^{n} w_i} $$\n where the weights $w_i = 1/|z - r_i|^2$ are positive real numbers.\n If we let $\\lambda_i = \\frac{w_i}{\\sum_{j=1}^{n} w_j}$, then we can write $z = \\sum_{i=1}^{n} \\lambda_i r_i$.\n The coefficients $\\lambda_i$ are positive and they sum to 1 ($\\sum \\lambda_i = 1$). This is the definition of a convex combination of the points $r_i$. Any point that is a convex combination of a set of points lies within their convex hull.\n \\end{itemize}\n In both possible cases, any root of $P'$ must lie within the convex hull of the roots of $P$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Polynomial\n\n\ntheorem Complex.mem_convexHull_roots_of_mem_derivative_roots (p : ℂ[X]) (z : ℂ)\n (z_mem_roots_p_derivative : z ∈ p.derivative.roots) :\n z ∈ convexHull ℝ (p.roots.toFinset : Set ℂ) := sorry"} -{"project_name": "GelfondSchneiderTheorem", "name": "gelfond_scheider", "type": "theorem", "title": "Gelfond–Schneider theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Gelfond–Schneider theorem}\n\nThis section contains a (stub of a) proof of the Gelfond–Schneider theorem.\nSee \\url{https://en.wikipedia.org/wiki/Gelfond%E2%80%93Schneider_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Gelfond–Schneider theorem]\n \\label{thm:gelfond-schneider-theorem}\n \\lean{gelfond_scheider}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set Function\n\n\ntheorem gelfond_scheider (a b : ℝ) (ha_neq : a ≠ 0 ∧ a ≠ 1)\n (ha_alg : IsAlgebraic ℚ a) (hb_alg : IsAlgebraic ℚ b) (hb : Irrational b) :\n Transcendental ℚ b := by sorry"} -{"project_name": "GreenTaoTheorem", "name": "Nat.Prime.greenTao", "type": "theorem", "title": "Green–Tao theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Green–Tao theorem}\n\nThis section contains a (stub of a) proof of the Green–Tao theorem.\nSee \\url{https://en.wikipedia.org/wiki/Green%E2%80%93Tao_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Green–Tao theorem]\n \\label{thm:green-tao-theorem}\n \\lean{Nat.Prime.greenTao}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem Nat.Prime.greenTao (k : ℕ) :\n ∃ a d : ℕ, 0 < d ∧ ∀ i < k, (a + i * d).Prime := by sorry"} -{"project_name": "GrushkoTheorem", "name": "grushko", "type": "theorem", "title": "Grushko theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Grushko theorem}\n\nThis section contains a (stub of a) proof of the Grushko theorem.\nSee \\url{https://en.wikipedia.org/wiki/Grushko_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Grushko theorem]\n \\label{thm:grushko-theorem}\n \\lean{grushko}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Group Monoid.Coprod\n\n\ntheorem grushko {G H : Type*} [Group G] [Group H] [FG G] [FG H] :\n rank (G ∗ H) = rank G + rank H := by sorry"} -{"project_name": "HardyLittlewoodTauberian", "name": "tauberian", "type": "theorem", "title": "Hardy–Littlewood Tauberian theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Hardy–Littlewood Tauberian theorem}\n\nThis section contains a (stub of a) proof of the Hardy–Littlewood Tauberian theorem.\nSee \\url{https://en.wikipedia.org/wiki/Hardy%E2%80%93Littlewood_Tauberian_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Hardy–Littlewood Tauberian theorem]\n \\label{thm:hardy-littlewood-tauberian}\n \\lean{tauberian}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Filter Topology Asymptotics Real\n\n\ntheorem tauberian {a : ℕ → ℝ} (ha : 0 ≤ a)\n (h : (fun (y : ℝ) ↦ ∑' k : ℕ, a k * rexp (-k * y)) ~[𝓝[>] 0] (fun (y : ℝ) ↦ 1 / y)) :\n (fun n ↦ ∑ k ∈ Finset.range n, a k) ~[atTop] (fun n ↦ ↑n) := sorry"} -{"project_name": "HasseTheoremOnEllipticCurves", "name": "HasseBound", "type": "theorem", "title": "Hasse's theorem on elliptic curves", "informal_statement": "TODO", "informal_proof": "\\chapter{Hasse's theorem on elliptic curves}\n\nThis section contains a (stub of a) proof of Hasse's theorem on elliptic curves.\nSee \\url{https://en.wikipedia.org/wiki/Hasse's_theorem_on_elliptic_curves} for more details.\n\nTODO: Expand this stubbed file by adding an informal proof.\n\n% TODO: add blueprint\n\n\\begin{theorem}[Hasse's theorem on elliptic curves]\n \\label{thm:hasse-theorem-on-elliptic-curves}\n \\lean{HasseBound}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem HasseBound (F : Type*) [Finite F] [Field F] (E : WeierstrassCurve.Affine F) :\n abs ((Nat.card <| E.Point : ℝ) - (Nat.card F + 1)) ≤ 2 * Real.sqrt (Nat.card F) := sorry"} -{"project_name": "HeightOnePrimesUfd", "name": "Ideal.ufd_iff_height_one_primes_principal", "type": "theorem", "title": "UFD iff Height-1 Primes Principal (Stacks 0AFT)", "informal_statement": "\\leanok\nA Noetherian domain $R$ is a UFD if and only if every height-$1$ prime ideal of $R$ is principal.", "informal_proof": "\\chapter{Height One Primes and UFDs (Stacks 0AFT)}\n\nThis section contains a proof of the fact that a Noetherian domain $R$ is a UFD if and only if every height-$1$ prime ideal of $R$ is principal.\nSee \\url{https://stacks.math.columbia.edu/tag/0AFT} for more details.\n\n\\begin{lemma}[Height-0 primes are $\\bot$ in a domain]\n\\label{lem:eq_bot_of_primeHeight_zero}\n\\lean{Ideal.eq_bot_of_primeHeight_eq_zero}\n\\leanok\nIn an integral domain, a prime ideal of height $0$ is the zero ideal.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\nIn a domain the only minimal prime is $\\bot$, and height $0$ means the ideal is a minimal prime.\n\\end{proof}\n\n\\begin{lemma}[Height-1 primes are nonzero in a domain]\n\\label{lem:ne_bot_of_primeHeight_one}\n\\lean{Ideal.ne_bot_of_primeHeight_eq_one}\n\\leanok\nIn an integral domain, a prime ideal of height $1$ is nonzero.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\n\\uses{lem:eq_bot_of_primeHeight_zero}\nIf $\\mathfrak{p} = \\bot$ then $\\operatorname{height}(\\mathfrak{p}) = 0 \\neq 1$.\n\\end{proof}\n\n\\begin{lemma}[Unique prime of height 1 above a nonzero prime]\n\\label{lem:eq_of_le_primeHeight_one}\n\\lean{Ideal.eq_of_isPrime_of_le_of_primeHeight_eq_one}\n\\leanok\nIn a domain, if $\\mathfrak{p}$ is a nonzero prime ideal contained in a prime $\\mathfrak{q}$ of height $1$, then $\\mathfrak{p} = \\mathfrak{q}$.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\n\\uses{lem:eq_bot_of_primeHeight_zero}\nIf $\\mathfrak{p} \\subsetneq \\mathfrak{q}$ then $\\operatorname{height}(\\mathfrak{p}) + 1 \\leq \\operatorname{height}(\\mathfrak{q}) = 1$, forcing $\\operatorname{height}(\\mathfrak{p}) = 0$, hence $\\mathfrak{p} = \\bot$ by Lemma~\\ref{lem:eq_bot_of_primeHeight_zero}, contradicting $\\mathfrak{p} \\neq \\bot$.\n\\end{proof}\n\n\\begin{lemma}[Forward: height-1 primes are principal in a UFD]\n\\label{lem:height_one_principal_ufd}\n\\lean{Ideal.isPrincipal_of_primeHeight_eq_one_of_ufd}\n\\leanok\nIn a UFD, every height-$1$ prime ideal is principal.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\n\\uses{lem:ne_bot_of_primeHeight_one, lem:eq_of_le_primeHeight_one}\nSince $\\mathfrak{p} \\neq \\bot$ (Lemma~\\ref{lem:ne_bot_of_primeHeight_one}), there exists a prime element $x \\in \\mathfrak{p}$. Then $\\operatorname{span}\\{x\\}$ is a nonzero prime ideal contained in $\\mathfrak{p}$. By Lemma~\\ref{lem:eq_of_le_primeHeight_one}, $\\operatorname{span}\\{x\\} = \\mathfrak{p}$, so $\\mathfrak{p}$ is principal.\n\\end{proof}\n\n\\begin{lemma}[Reverse: irreducibles are prime when height-1 primes are principal]\n\\label{lem:irreducible_is_prime}\n\\lean{Prime.of_irreducible_of_height_one_principal}\n\\leanok\nIn a Noetherian domain where every height-$1$ prime is principal, every irreducible element is prime.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\nFor irreducible $x$, take a minimal prime $\\mathfrak{q}$ over $(x)$. By Krull's principal ideal theorem, $\\operatorname{height}(\\mathfrak{q}) \\leq 1$. Since $x \\neq 0$, $\\mathfrak{q} \\neq \\bot$, so $\\operatorname{height}(\\mathfrak{q}) = 1$. By hypothesis $\\mathfrak{q} = (y)$. Then $y \\mid x$, and irreducibility gives $(x) = (y) = \\mathfrak{q}$, a prime ideal, so $x$ is prime.\n\\end{proof}\n\n\\begin{theorem}[UFD iff Height-1 Primes Principal (Stacks 0AFT)]\n\\label{thm:ufd_iff_height_one_principal}\n\\lean{Ideal.ufd_iff_height_one_primes_principal}\n\\leanok\nA Noetherian domain $R$ is a UFD if and only if every height-$1$ prime ideal of $R$ is principal.\n\\end{theorem}\n\n\\begin{proof}\n\\leanok\n\\uses{lem:height_one_principal_ufd, lem:irreducible_is_prime}\n\\emph{Forward}: Lemma~\\ref{lem:height_one_principal_ufd}.\n\n\\emph{Reverse}: By Lemma~\\ref{lem:irreducible_is_prime}, every irreducible is prime. Since $R$ is Noetherian, it is a \\texttt{WfDvdMonoid}, so every nonzero non-unit has an irreducible factorization. Since all irreducibles are prime, this gives a UFD.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Ideal\n\n\ntheorem Ideal.ufd_iff_height_one_primes_principal :\n UniqueFactorizationMonoid R ↔\n ∀ (p : Ideal R) [p.IsPrime], p.primeHeight = 1 → p.IsPrincipal := by sorry"} -{"project_name": "Hinge", "name": "hinge_forward", "type": "theorem", "title": "Hinge Theorem with Law of Cosines, Forward", "informal_statement": "Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, and if $C_1 > C_2$, then $c_1 > c_2$.", "informal_proof": "\\chapter{Hinge Theorem}\n\nThis section contains a proof of the Hinge Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Hinge_theorem} for more details.\n\n\\begin{theorem}[Hinge Theorem with Law of Cosines, Forward]\n \\label{thm:hinge_forward}\n \\lean{hinge_forward}\n Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, and if $C_1 > C_2$, then $c_1 > c_2$.\n\\end{theorem}\n\n\\begin{proof}\n Adding the two equations given by the law of cosines and rearranging, we have:\n \\[ c_1^2 - c_2^2 = -2ab(\\cos(C_1) - cos(C_2)) \\]\n The cosine function is strictly decreasing on the interval $[0, \\pi]$. Thus, this value is positive.\n Using the difference of squares factorization, we have:\n \\[ (c_1 - c_2)(c_1 + c_2) > 0 \\]\n Since $c_1 + c_2 > 0$, we conclude that $c_1 - c_2 > 0$, or $c_1 > c_2$\n\\end{proof}\n\n\\begin{theorem}[Hinge Theorem with Law of Cosines, Backward]\n \\label{thm:hinge_backward}\n \\lean{hinge_backward}\n Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, and if $c_1 > c_2$, then $C_1 > C_2$.\n\\end{theorem}\n\n\\begin{proof}\n Adding the two equations given by the law of cosines and rearranging, we have:\n \\[ c_1^2 - c_2^2 = -2ab(\\cos(C_1) - cos(C_2)) \\]\n Since $c_1 > c_2$, the left side is positive.\n Using the difference of squares factorization, we have:\n \\[ (c_1 - c_2)(c_1 + c_2) > 0 \\]\n Since $c_1 + c_2 > 0$, we conclude that $-2ab(\\cos(C_1) - cos(C_2)) > 0$.\n Dividing both sides by the positive number $-2ab$, we have $\\cos(C_1) - \\cos(C_2) < 0$, or $\\cos(C_1) < \\cos(C_2)$.\n The cosine function is strictly decreasing on the interval $[0, \\pi]$. Thus, we conclude that $C_1 > C_2$.\n\\end{proof}\n\n\\begin{theorem}[Hinge Theorem with Law of Cosines]\n \\label{thm:hinge}\n \\uses{thm:hinge_forward, thm:hinge_backward}\n \\lean{hinge_iff}\n Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, then $c_1 > c_2$ if and only if $C_1 > C_2$.\n\\end{theorem}\n\n\\begin{proof}\n This follows directly from Theorems \\ref{thm:hinge_forward} and \\ref{thm:hinge_backward}.\n\\end{proof}\n\n\\begin{theorem}[Hinge Theorem]\n \\label{thm:hinge_geometry}\n \\uses{thm:hinge}\n \\lean{hinge_iff_geometric}\n Let $A, B_1, C_1, B_2, C_2$ be points in Euclidean space such that the distances $AB_1$, $AC_1$, $AB_2$, and $AC_2$ are all nonzero.\n Then the distance $B_1C_1$ is greater than the distance $B_2C_2$ if and only if the angle $B_1AC_1$ is greater than the angle $B_2AC_2$.\n\\end{theorem}\n\n\\begin{proof}\n Let $a = AB_1 = AB_2$, $b = AC_1 = AC_2$, $c_1 = B_1C_1$, and $c_2 = B_2C_2$.\n By the law of cosines, we have:\n \\[ c_1^2 = a^2 + b^2 - 2ab\\cos(\\angle B_1AC_1) \\]\n \\[ c_2^2 = a^2 + b^2 - 2ab\\cos(\\angle B_2AC_2) \\]\n Thus, the conditions of Theorem \\ref{thm:hinge} are satisfied, and the result follows.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Real EuclideanGeometry\n\n\ntheorem hinge_forward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hangle : C₁ > C₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n c₁ > c₂ := by sorry"} -{"project_name": "Hinge", "name": "hinge_backward", "type": "theorem", "title": "Hinge Theorem with Law of Cosines, Backward", "informal_statement": "Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, and if $c_1 > c_2$, then $C_1 > C_2$.", "informal_proof": "\\chapter{Hinge Theorem}\n\nThis section contains a proof of the Hinge Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Hinge_theorem} for more details.\n\n\\begin{theorem}[Hinge Theorem with Law of Cosines, Forward]\n \\label{thm:hinge_forward}\n \\lean{hinge_forward}\n Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, and if $C_1 > C_2$, then $c_1 > c_2$.\n\\end{theorem}\n\n\\begin{proof}\n Adding the two equations given by the law of cosines and rearranging, we have:\n \\[ c_1^2 - c_2^2 = -2ab(\\cos(C_1) - cos(C_2)) \\]\n The cosine function is strictly decreasing on the interval $[0, \\pi]$. Thus, this value is positive.\n Using the difference of squares factorization, we have:\n \\[ (c_1 - c_2)(c_1 + c_2) > 0 \\]\n Since $c_1 + c_2 > 0$, we conclude that $c_1 - c_2 > 0$, or $c_1 > c_2$\n\\end{proof}\n\n\\begin{theorem}[Hinge Theorem with Law of Cosines, Backward]\n \\label{thm:hinge_backward}\n \\lean{hinge_backward}\n Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, and if $c_1 > c_2$, then $C_1 > C_2$.\n\\end{theorem}\n\n\\begin{proof}\n Adding the two equations given by the law of cosines and rearranging, we have:\n \\[ c_1^2 - c_2^2 = -2ab(\\cos(C_1) - cos(C_2)) \\]\n Since $c_1 > c_2$, the left side is positive.\n Using the difference of squares factorization, we have:\n \\[ (c_1 - c_2)(c_1 + c_2) > 0 \\]\n Since $c_1 + c_2 > 0$, we conclude that $-2ab(\\cos(C_1) - cos(C_2)) > 0$.\n Dividing both sides by the positive number $-2ab$, we have $\\cos(C_1) - \\cos(C_2) < 0$, or $\\cos(C_1) < \\cos(C_2)$.\n The cosine function is strictly decreasing on the interval $[0, \\pi]$. Thus, we conclude that $C_1 > C_2$.\n\\end{proof}\n\n\\begin{theorem}[Hinge Theorem with Law of Cosines]\n \\label{thm:hinge}\n \\uses{thm:hinge_forward, thm:hinge_backward}\n \\lean{hinge_iff}\n Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, then $c_1 > c_2$ if and only if $C_1 > C_2$.\n\\end{theorem}\n\n\\begin{proof}\n This follows directly from Theorems \\ref{thm:hinge_forward} and \\ref{thm:hinge_backward}.\n\\end{proof}\n\n\\begin{theorem}[Hinge Theorem]\n \\label{thm:hinge_geometry}\n \\uses{thm:hinge}\n \\lean{hinge_iff_geometric}\n Let $A, B_1, C_1, B_2, C_2$ be points in Euclidean space such that the distances $AB_1$, $AC_1$, $AB_2$, and $AC_2$ are all nonzero.\n Then the distance $B_1C_1$ is greater than the distance $B_2C_2$ if and only if the angle $B_1AC_1$ is greater than the angle $B_2AC_2$.\n\\end{theorem}\n\n\\begin{proof}\n Let $a = AB_1 = AB_2$, $b = AC_1 = AC_2$, $c_1 = B_1C_1$, and $c_2 = B_2C_2$.\n By the law of cosines, we have:\n \\[ c_1^2 = a^2 + b^2 - 2ab\\cos(\\angle B_1AC_1) \\]\n \\[ c_2^2 = a^2 + b^2 - 2ab\\cos(\\angle B_2AC_2) \\]\n Thus, the conditions of Theorem \\ref{thm:hinge} are satisfied, and the result follows.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Real EuclideanGeometry\n\n\ntheorem hinge_backward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hside : c₁ > c₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n C₁ > C₂ := by sorry"} -{"project_name": "Hinge", "name": "hinge_iff_geometric", "type": "theorem", "title": "Hinge Theorem", "informal_statement": "Let $A, B_1, C_1, B_2, C_2$ be points in Euclidean space such that the distances $AB_1$, $AC_1$, $AB_2$, and $AC_2$ are all nonzero.\n Then the distance $B_1C_1$ is greater than the distance $B_2C_2$ if and only if the angle $B_1AC_1$ is greater than the angle $B_2AC_2$.", "informal_proof": "\\chapter{Hinge Theorem}\n\nThis section contains a proof of the Hinge Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Hinge_theorem} for more details.\n\n\\begin{theorem}[Hinge Theorem with Law of Cosines, Forward]\n \\label{thm:hinge_forward}\n \\lean{hinge_forward}\n Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, and if $C_1 > C_2$, then $c_1 > c_2$.\n\\end{theorem}\n\n\\begin{proof}\n Adding the two equations given by the law of cosines and rearranging, we have:\n \\[ c_1^2 - c_2^2 = -2ab(\\cos(C_1) - cos(C_2)) \\]\n The cosine function is strictly decreasing on the interval $[0, \\pi]$. Thus, this value is positive.\n Using the difference of squares factorization, we have:\n \\[ (c_1 - c_2)(c_1 + c_2) > 0 \\]\n Since $c_1 + c_2 > 0$, we conclude that $c_1 - c_2 > 0$, or $c_1 > c_2$\n\\end{proof}\n\n\\begin{theorem}[Hinge Theorem with Law of Cosines, Backward]\n \\label{thm:hinge_backward}\n \\lean{hinge_backward}\n Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, and if $c_1 > c_2$, then $C_1 > C_2$.\n\\end{theorem}\n\n\\begin{proof}\n Adding the two equations given by the law of cosines and rearranging, we have:\n \\[ c_1^2 - c_2^2 = -2ab(\\cos(C_1) - cos(C_2)) \\]\n Since $c_1 > c_2$, the left side is positive.\n Using the difference of squares factorization, we have:\n \\[ (c_1 - c_2)(c_1 + c_2) > 0 \\]\n Since $c_1 + c_2 > 0$, we conclude that $-2ab(\\cos(C_1) - cos(C_2)) > 0$.\n Dividing both sides by the positive number $-2ab$, we have $\\cos(C_1) - \\cos(C_2) < 0$, or $\\cos(C_1) < \\cos(C_2)$.\n The cosine function is strictly decreasing on the interval $[0, \\pi]$. Thus, we conclude that $C_1 > C_2$.\n\\end{proof}\n\n\\begin{theorem}[Hinge Theorem with Law of Cosines]\n \\label{thm:hinge}\n \\uses{thm:hinge_forward, thm:hinge_backward}\n \\lean{hinge_iff}\n Let $a, b, c_1, c_2$ be positive reals and let $C_1, C_2$ be angles such that $0 \\leq C_1, C_2 \\leq \\pi$.\n If $C_1, C_2$ obey the law of cosines for triangles with sides $a, b, c_1$ and $a, b, c_2$ respectively, then $c_1 > c_2$ if and only if $C_1 > C_2$.\n\\end{theorem}\n\n\\begin{proof}\n This follows directly from Theorems \\ref{thm:hinge_forward} and \\ref{thm:hinge_backward}.\n\\end{proof}\n\n\\begin{theorem}[Hinge Theorem]\n \\label{thm:hinge_geometry}\n \\uses{thm:hinge}\n \\lean{hinge_iff_geometric}\n Let $A, B_1, C_1, B_2, C_2$ be points in Euclidean space such that the distances $AB_1$, $AC_1$, $AB_2$, and $AC_2$ are all nonzero.\n Then the distance $B_1C_1$ is greater than the distance $B_2C_2$ if and only if the angle $B_1AC_1$ is greater than the angle $B_2AC_2$.\n\\end{theorem}\n\n\\begin{proof}\n Let $a = AB_1 = AB_2$, $b = AC_1 = AC_2$, $c_1 = B_1C_1$, and $c_2 = B_2C_2$.\n By the law of cosines, we have:\n \\[ c_1^2 = a^2 + b^2 - 2ab\\cos(\\angle B_1AC_1) \\]\n \\[ c_2^2 = a^2 + b^2 - 2ab\\cos(\\angle B_2AC_2) \\]\n Thus, the conditions of Theorem \\ref{thm:hinge} are satisfied, and the result follows.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Real EuclideanGeometry\n\n\ntheorem hinge_iff_geometric (A B₁ B₂ C₁ C₂ : P)\n (hab₁ : dist A B₁ = dist A B₂)\n (hac₁ : dist A C₁ = dist A C₂)\n (hb₁c₁ : B₁ ≠ C₁) (hb₂c₂ : B₂ ≠ C₂)\n (hab₁_ne : A ≠ B₁) (hac₁_ne : A ≠ C₁) :\n angle B₁ A C₁ > angle B₂ A C₂ ↔ dist B₁ C₁ > dist B₂ C₂ := by sorry"} -{"project_name": "HurwitzApproximation", "name": "hurwitz_approximation", "type": "theorem", "title": "Hurwitz's Approximation Theorem", "informal_statement": "For every irrational real number $\\xi$, the set $\\{q \\in \\mathbb{Q} \\mid |\\xi - q| < 1/(\\sqrt{5} \\cdot q.\\mathrm{den}^2)\\}$ is infinite.", "informal_proof": "\\chapter{Hurwitz's Approximation Theorem}\n\nThis section contains a proof of Hurwitz's Approximation Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Hurwitz%27s_theorem_(number_theory)} for more details.\n\n\n\\begin{lemma}[CF of irrational does not terminate]\n \\label{lem:hurwitz_cf_not_term}\n \\lean{cf_irrational_not_terminatedAt}\n If $\\xi$ is irrational, then the generalized continued fraction for $\\xi$ does not terminate at any index $n$.\n\\end{lemma}\n\\begin{proof}\n If the generalized continued fraction for $\\xi$ terminated at $n$, then it would terminate altogether, so we would get a rational $q$ with $\\xi = q$, contradicting irrationality.\n\\end{proof}\n\n\\begin{lemma}[CF denominator is positive]\n \\label{lem:hurwitz_cf_den_pos}\n \\lean{cf_den_pos}\n \\uses{lem:hurwitz_cf_not_term}\n If $\\xi$ is irrational, then the $n$-th denominator of the generalized continued fraction for $\\xi$ is positive.\n\\end{lemma}\n\\begin{proof}\n Since $\\xi$ is irrational, the CF does not terminate at $n-1$ by Lemma~\\ref{lem:hurwitz_cf_not_term}. We have that the $n$th denominator is lower bounded by a Fibonacci number $\\mathrm{fib}(n+1) \\leq B_n$, and Fibonacci numbers are positive for $n \\geq 1$.\n\\end{proof}\n\n\\begin{lemma}[CF denominator recurrence inequality]\n \\label{lem:hurwitz_cf_den_rec}\n \\lean{cf_den_recurrence_ineq}\n \\uses{lem:hurwitz_cf_not_term, lem:hurwitz_cf_den_pos}\n If $\\xi$ is irrational and $B_n$ denotes the $n$-th denominator of the generalized continued fraction for $\\xi$, then $B_n + B_{n+1} \\leq B_{n+2}$ for all $n$.\n\\end{lemma}\n\\begin{proof}\n The recurrence $B_{n+2} = a_{n+2} \\cdot B_{n+1} + B_n$ holds for continued fractions, where $a_{n+2} \\geq 1$ since the partial denominators of the generalized continued fraction for $\\xi$ are at least $1$. Thus $B_{n+2} \\geq B_{n+1} + B_n$.\n\\end{proof}\n\n\\begin{lemma}[CF denominator skip inequality]\n \\label{lem:hurwitz_cf_den_lt_skip}\n \\lean{cf_den_lt_skip}\n \\uses{lem:hurwitz_cf_den_rec, lem:hurwitz_cf_den_pos}\n If $\\xi$ is irrational, then the $n$-th denominator of the generalized continued fraction for $\\xi$ is strictly less than the $(n+2)$-th denominator, for all $n$.\n\\end{lemma}\n\\begin{proof}\n From the recurrence inequality (Lemma~\\ref{lem:hurwitz_cf_den_rec}), $B_n + B_{n+1} \\leq B_{n+2}$, and since $B_{n+1} > 0$ by Lemma~\\ref{lem:hurwitz_cf_den_pos}, we have $B_n < B_{n+2}$.\n\\end{proof}\n\n\\begin{lemma}[Convergent denominator equals CF denominator]\n \\label{lem:hurwitz_conv_den_eq}\n \\lean{convergent_den_eq_cf_den}\n \\uses{lem:hurwitz_cf_not_term, lem:hurwitz_cf_den_pos}\n If $\\xi$ is irrational, then for all $n$, the denominator of the $n$-th convergent equals the $n$-th denominator of the generalized continued fraction for $\\xi$ (as real numbers).\n\\end{lemma}\n\\begin{proof}\n The convergents are integers-valued fractions $A_n / B_n$. The determinant formula $A_n B_{n+1} - B_n A_{n+1} = (-1)^{n+1}$ shows $\\gcd(A_n, B_n) = 1$, so the rational $A_n/B_n$ is already in lowest terms and its denominator is exactly $B_n$.\n\\end{proof}\n\n\\begin{lemma}[Consecutive convergents bracket $\\xi$]\n \\label{lem:hurwitz_bracket}\n \\lean{consecutive_convs_bracket}\n \\uses{lem:hurwitz_cf_not_term, lem:hurwitz_cf_den_pos}\n If $\\xi$ is irrational, then for all $n$, the product $(\\xi - \\xi.\\mathrm{convergent}(n)) \\cdot (\\xi - \\xi.\\mathrm{convergent}(n+1)) < 0$, i.e., consecutive convergents lie on opposite sides of $\\xi$.\n\\end{lemma}\n\\begin{proof}\n The sign of $\\xi - c_n$ is $(-1)^n$ up to a positive factor (involving the fractional part inverse and the CF denominators). Hence consecutive errors alternate in sign, giving a negative product.\n\\end{proof}\n\n\\begin{lemma}[Consecutive convergents difference]\n \\label{lem:hurwitz_conv_diff}\n \\lean{consecutive_convs_diff}\n \\uses{lem:hurwitz_cf_not_term, lem:hurwitz_cf_den_pos}\n If $\\xi$ is irrational, then $|{\\xi.\\mathrm{convergent}(n)} - {\\xi.\\mathrm{convergent}(n+1)}| = 1 / (B_n \\cdot B_{n+1})$ where $B_k$ is the $k$-th denominator of the generalized continued fraction for $\\xi$.\n\\end{lemma}\n\\begin{proof}\n The determinant formula gives $|A_n B_{n+1} - B_n A_{n+1}| = 1$. Writing the convergents as $A_n/B_n$ and $A_{n+1}/B_{n+1}$, their difference has absolute value $1/(B_n B_{n+1})$.\n\\end{proof}\n\n\\begin{lemma}[Triangle identity for convergents]\n \\label{lem:hurwitz_triangle}\n \\lean{triangle_identity}\n \\uses{lem:hurwitz_bracket, lem:hurwitz_conv_diff}\n If $\\xi$ is irrational, then $|\\xi - \\xi.\\mathrm{convergent}(n)| + |\\xi - \\xi.\\mathrm{convergent}(n+1)| = 1/(B_n \\cdot B_{n+1})$.\n\\end{lemma}\n\\begin{proof}\n Since consecutive convergents bracket $\\xi$ (Lemma~\\ref{lem:hurwitz_bracket}), the errors $a = \\xi - c_n$ and $b = \\xi - c_{n+1}$ have opposite signs, so $|a| + |b| = |a - b| = |c_n - c_{n+1}|$. By Lemma~\\ref{lem:hurwitz_conv_diff} this equals $1/(B_n B_{n+1})$.\n\\end{proof}\n\n\\begin{lemma}[Quadratic inequality implies bound by golden ratio]\n \\label{lem:hurwitz_quad_golden}\n \\lean{quadratic_le_golden}\n If $r > 0$ and $r + 1/r \\leq \\sqrt{5}$, then $r \\leq \\varphi$ where $\\varphi = (1+\\sqrt{5})/2$ is the golden ratio.\n\\end{lemma}\n\\begin{proof}\n Multiplying $r + 1/r \\leq \\sqrt{5}$ by $r$ gives $r^2 - \\sqrt{5} r + 1 \\leq 0$. The roots of $t^2 - \\sqrt{5} t + 1 = 0$ are $\\varphi$ and $1/\\varphi$, so this inequality holds iff $1/\\varphi \\leq r \\leq \\varphi$. In particular $r \\leq \\varphi$. This is confirmed by arithmetic using $(\\sqrt{5})^2 = 5$.\n\\end{proof}\n\n\\begin{lemma}[Golden ratio squeeze]\n \\label{lem:hurwitz_ratio_squeeze}\n \\lean{ratio_squeeze}\n If $r \\leq \\varphi$ and $r > 0$, then $\\varphi \\leq 1 + 1/r$.\n\\end{lemma}\n\\begin{proof}\n Since $\\varphi^2 = \\varphi + 1$, we have $\\varphi = 1 + 1/\\varphi$. Because $r \\leq \\varphi$, we get $1/r \\geq 1/\\varphi$, so $1 + 1/r \\geq 1 + 1/\\varphi = \\varphi$.\n\\end{proof}\n\n\n\\begin{lemma}[Golden ratio cannot be ratio of positive integers]\n \\label{lem:hurwitz_golden_not_ratio}\n \\lean{golden_ratio_not_int_ratio}\n There are no positive natural numbers $a, b$ with $b/a = \\varphi$.\n\\end{lemma}\n\\begin{proof}\n If $b/a = \\varphi$ with $a, b$ positive integers, then $\\varphi = b/a$ is rational (a ratio of integers), contradicting the irrationality of $\\varphi$.\n\\end{proof}\n\n\\begin{lemma}[Ratio bound when two consecutive convergents fail Hurwitz]\n \\label{lem:hurwitz_ratio_bound}\n \\lean{ratio_bound_of_not_hurwitz}\n \\uses{lem:hurwitz_cf_den_pos, lem:hurwitz_conv_den_eq, lem:hurwitz_triangle}\n If $\\xi$ is irrational and neither $\\xi.\\mathrm{convergent}(n)$ nor $\\xi.\\mathrm{convergent}(n+1)$ satisfies the Hurwitz bound $|\\xi - q| < 1/(\\sqrt{5} \\cdot q.\\mathrm{den}^2)$, then $B_{n+1}/B_n + B_n/B_{n+1} \\leq \\sqrt{5}$, where $B_k$ is the $k$-th denominator of the generalized continued fraction for $\\xi$.\n\\end{lemma}\n\\begin{proof}\n Let $B = B_n$ and $B' = B_{n+1}$. From the failure hypotheses, $|\\xi - c_n| \\geq 1/(\\sqrt{5} B^2)$ and $|\\xi - c_{n+1}| \\geq 1/(\\sqrt{5} B'^2)$. By the triangle identity (Lemma~\\ref{lem:hurwitz_triangle}), their sum equals $1/(B B')$, so $1/(B B') \\geq 1/(\\sqrt{5} B^2) + 1/(\\sqrt{5} B'^2)$. Multiplying both sides by $\\sqrt{5} B^2 B'^2$ and simplifying yields $B'^2 + B^2 \\leq \\sqrt{5}(B B')$, i.e., $B'/B + B/B' \\leq \\sqrt{5}$.\n\\end{proof}\n\n\\begin{lemma}[Denominator ratio bounded by golden ratio when two fail]\n \\label{lem:hurwitz_ratio_le_golden}\n \\lean{ratio_le_golden_of_not_hurwitz}\n \\uses{lem:hurwitz_ratio_bound, lem:hurwitz_cf_den_pos, lem:hurwitz_quad_golden}\n If $\\xi$ is irrational and neither $\\xi.\\mathrm{convergent}(n)$ nor $\\xi.\\mathrm{convergent}(n+1)$ satisfies the Hurwitz bound, then $B_{n+1}/B_n \\leq \\varphi$.\n\\end{lemma}\n\\begin{proof}\n Let $r = B_{n+1}/B_n$. By Lemma~\\ref{lem:hurwitz_ratio_bound}, $r + 1/r \\leq \\sqrt{5}$. Since $r > 0$, Lemma~\\ref{lem:hurwitz_quad_golden} gives $r \\leq \\varphi$.\n\\end{proof}\n\n\\begin{lemma}[Next ratio bounded below by golden ratio via recurrence]\n \\label{lem:hurwitz_ratio_ge_golden}\n \\lean{ratio_ge_golden_of_recurrence}\n \\uses{lem:hurwitz_cf_den_pos, lem:hurwitz_cf_den_rec, lem:hurwitz_ratio_squeeze}\n If $\\xi$ is irrational and $B_{n+1}/B_n \\leq \\varphi$, then $B_{n+2}/B_{n+1} \\geq \\varphi$.\n\\end{lemma}\n\\begin{proof}\n From the recurrence inequality (Lemma~\\ref{lem:hurwitz_cf_den_rec}), $B_{n+2} \\geq B_{n+1} + B_n$, so $B_{n+2}/B_{n+1} \\geq 1 + B_n/B_{n+1} = 1 + 1/r$ where $r = B_{n+1}/B_n$. Since $r \\leq \\varphi$, Lemma~\\ref{lem:hurwitz_ratio_squeeze} gives $1 + 1/r \\geq \\varphi$. Hence $B_{n+2}/B_{n+1} \\geq \\varphi$.\n\\end{proof}\n\n\\begin{lemma}[Denominator ratio bounded above for shifted pair]\n \\label{lem:hurwitz_ratio_le_golden_prime}\n \\lean{ratio_le_golden_of_not_hurwitz'}\n \\uses{lem:hurwitz_ratio_le_golden}\n If $\\xi$ is irrational and neither $\\xi.\\mathrm{convergent}(n+1)$ nor $\\xi.\\mathrm{convergent}(n+2)$ satisfies the Hurwitz bound, then $B_{n+2}/B_{n+1} \\leq \\varphi$.\n\\end{lemma}\n\\begin{proof}\n Apply Lemma~\\ref{lem:hurwitz_ratio_le_golden} with index $n+1$: if neither convergent $n+1$ nor convergent $n+2$ satisfies the bound, then $B_{n+2}/B_{n+1} \\leq \\varphi$.\n\\end{proof}\n\n\\begin{lemma}[Among three consecutive convergents, one satisfies Hurwitz]\n \\label{lem:hurwitz_three_consec}\n \\lean{three_consecutive_one_hurwitz}\n \\uses{lem:hurwitz_ratio_le_golden, lem:hurwitz_ratio_ge_golden, lem:hurwitz_ratio_le_golden_prime, lem:hurwitz_golden_not_ratio, lem:hurwitz_cf_den_pos}\n If $\\xi$ is irrational, then for every $n \\in \\mathbb{N}$, at least one of $\\xi.\\mathrm{convergent}(n)$, $\\xi.\\mathrm{convergent}(n+1)$, $\\xi.\\mathrm{convergent}(n+2)$ satisfies $|\\xi - q| < 1/(\\sqrt{5} \\cdot q.\\mathrm{den}^2)$.\n\\end{lemma}\n\\begin{proof}\n Suppose for contradiction that all three fail the bound. By Lemma~\\ref{lem:hurwitz_ratio_le_golden} applied to the $(n, n+1)$ pair, $r = B_{n+1}/B_n \\leq \\varphi$. By Lemma~\\ref{lem:hurwitz_ratio_ge_golden}, $r' = B_{n+2}/B_{n+1} \\geq \\varphi$. By Lemma~\\ref{lem:hurwitz_ratio_le_golden_prime} applied to the $(n+1, n+2)$ pair, $r' \\leq \\varphi$. So $r' = \\varphi$ exactly. But $B_{n+1}$ and $B_{n+2}$ are positive integers (the CF denominators are integer-valued), so $B_{n+2}/B_{n+1} = \\varphi$ contradicts Lemma~\\ref{lem:hurwitz_golden_not_ratio}.\n\\end{proof}\n\n\\begin{lemma}[Convergents are injective]\n \\label{lem:hurwitz_conv_injective}\n \\lean{convergents_injective}\n \\uses{lem:hurwitz_bracket, lem:hurwitz_conv_den_eq, lem:hurwitz_cf_den_lt_skip}\n If $\\xi$ is irrational, then the function $n \\mapsto \\xi.\\mathrm{convergent}(n)$ is injective.\n\\end{lemma}\n\\begin{proof}\n Suppose $\\xi.\\mathrm{convergent}(n) = \\xi.\\mathrm{convergent}(m)$ with $n \\neq m$. Consecutive convergents are distinct (from Lemma~\\ref{lem:hurwitz_bracket}, they bracket $\\xi$ and cannot coincide). For $|n - m| \\geq 2$, the CF denominators satisfy $B_n < B_m$ (from Lemma~\\ref{lem:hurwitz_cf_den_lt_skip} by induction) but Lemma~\\ref{lem:hurwitz_conv_den_eq} implies $B_n = B_m$, a contradiction.\n\\end{proof}\n\n\\begin{lemma}[Hurwitz candidate in each window of three]\n \\label{lem:hurwitz_candidate}\n \\lean{hurwitz_candidate}\n \\uses{lem:hurwitz_three_consec}\n If $\\xi$ is irrational, then for every $n \\in \\mathbb{N}$ there exists $k \\in \\{3n, 3n+1, 3n+2\\}$ such that $\\xi.\\mathrm{convergent}(k)$ satisfies the Hurwitz bound.\n\\end{lemma}\n\\begin{proof}\n Apply Lemma~\\ref{lem:hurwitz_three_consec} at index $3n$: one of the three consecutive convergents starting at $3n$ satisfies the bound.\n\\end{proof}\n\n\\begin{lemma}[Infinitely many Hurwitz indices]\n \\label{lem:hurwitz_indices_inf}\n \\lean{hurwitz_indices_infinite}\n \\uses{lem:hurwitz_candidate}\n If $\\xi$ is irrational, then the set $\\{n \\in \\mathbb{N} \\mid |\\xi - \\xi.\\mathrm{convergent}(n)| < 1/(\\sqrt{5} \\cdot (\\xi.\\mathrm{convergent}(n)).\\mathrm{den}^2)\\}$ is infinite.\n\\end{lemma}\n\\begin{proof}\n For any bound $N$, Lemma~\\ref{lem:hurwitz_candidate} applied to $n = N+1$ gives a Hurwitz index $k \\geq 3(N+1) > N$. So the set has no upper bound and is therefore infinite.\n\\end{proof}\n\n\\begin{lemma}[Infinitely many Hurwitz rationals]\n \\label{lem:hurwitz_set_inf}\n \\lean{hurwitz_set_infinite}\n \\uses{lem:hurwitz_indices_inf, lem:hurwitz_conv_injective}\n If $\\xi$ is irrational, then the set $\\{q \\in \\mathbb{Q} \\mid |\\xi - q| < 1/(\\sqrt{5} \\cdot q.\\mathrm{den}^2)\\}$ is infinite.\n\\end{lemma}\n\\begin{proof}\n By Lemma~\\ref{lem:hurwitz_indices_inf} there are infinitely many indices $n$ whose convergent satisfies the Hurwitz bound. Since convergents are injective (Lemma~\\ref{lem:hurwitz_conv_injective}), these give infinitely many distinct rationals in the set. So the Hurwitz set is infinite.\n\\end{proof}\n\n\\begin{theorem}[Hurwitz's Approximation Theorem]\n \\label{thm:hurwitz_approximation}\n \\lean{hurwitz_approximation}\n \\uses{lem:hurwitz_set_inf}\n For every irrational real number $\\xi$, the set $\\{q \\in \\mathbb{Q} \\mid |\\xi - q| < 1/(\\sqrt{5} \\cdot q.\\mathrm{den}^2)\\}$ is infinite.\n\\end{theorem}\n\\begin{proof}\n This is exactly Lemma~\\ref{lem:hurwitz_set_inf}: the set of rationals approximating $\\xi$ to within $1/(\\sqrt{5} \\cdot q.\\mathrm{den}^2)$ is infinite.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Real GenContFract Set\n\n\ntheorem hurwitz_approximation (ξ : ℝ) (hξ : Irrational ξ) :\n { q : ℚ | |ξ - q| < 1 / (sqrt 5 * q.den ^ 2) }.Infinite := by sorry"} -{"project_name": "InverseEigenvalue", "name": "Module.End.inv_eigenvalue_iff", "type": "theorem", "title": "Inverse Eigenvalue Theorem", "informal_statement": "\\leanok\n Let $M$ be a finite $R$-module where $R$ is a commutative ring and let $f$ be an isomorphism from\n $M$ to itself, then $\\lambda \\in R^\\times$ is an eigenvalue of $f$ if and only if\n $\\lambda^{-1}$ is an eigenvalue of $f^{-1}$.", "informal_proof": "\\chapter{Inverse Eigenvalue Theorem}\n\nThis section contains a proof of the Inverse Eigenvalue Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Inverse_eigenvalue_problem} for more details.\n\n\\begin{theorem}\n \\label{thm:InverseEigenLinearEquiv}\n \\lean{Module.End.inv_eigenvalue_iff}\n \\leanok\n Let $M$ be a finite $R$-module where $R$ is a commutative ring and let $f$ be an isomorphism from\n $M$ to itself, then $\\lambda \\in R^\\times$ is an eigenvalue of $f$ if and only if\n $\\lambda^{-1}$ is an eigenvalue of $f^{-1}$.\n\\end{theorem}\n\\begin{proof}\nSuppose $\\lambda \\in R^\\times$ is an eigenvalue of $f$. By definition, there exists a non-zero\nvector $v \\in M$ such that $f(v) = \\lambda \\cdot v$. We can apply $f^{-1}$ to both sides of the eigenvalue\nequation: $$f^{-1}(f(v)) = f^{-1}(\\lambda \\cdot v)$$ which implies\n$f^{-1}(\\lambda \\cdot v) = \\lambda \\cdot f(v) = v$, hence $\\lambda^{-1}$ is an eigenvalue of\n$f^{-1}$ and vice versa.\n\\end{proof}\n\n\n\\begin{theorem}\n \\label{thm:InverseEigenMatrix}\n \\lean{Module.End.inv_eigenvalue_iff}\n \\leanok\n Let $A$ be an $n \\times n$ matrix over a commutative ring $R$ with an inverse $A^{-1}$, then\n $\\lambda \\in R^\\times$ is an eigenvalue of $A$ if and only if $\\lambda^{-1}$ is an eigenvalue\n of $A^{-1}$.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{thm:InverseEigenLinearEquiv}\n This follows directly from Theorem~\\ref{thm:InverseEigenLinearEquiv} by considering the\n $R$-module $R^n$ and the isomorphism induced by the matrix $A$.\n\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem Module.End.inv_eigenvalue_iff {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]\n (r : Rˣ) (f : M ≃ₗ[R] M) : Module.End.HasEigenvalue f.toLinearMap r ↔\n Module.End.HasEigenvalue f⁻¹.toLinearMap r⁻¹.1 := by sorry"} -{"project_name": "JacobiFourSquareTheorem", "name": "jacobi", "type": "theorem", "title": "Jacobi's Four-Square Theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Jacobi's Four-Square Theorem}\n\nThis section contains a (stub of a) proof of Jacobi's four-square theorem.\nSee \\url{https://en.wikipedia.org/wiki/Jacobi%27s_four-square_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Jacobi's Four-Square Theorem]\n \\label{thm:jacobi-four-square-theorem}\n \\lean{jacobi}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem jacobi (n : ℕ) : {a : Fin 4 → ℤ | (↑n : ℤ) = ∑ i : Fin 4, a i}.ncard\n = 8 * ∑' m : {m : ℕ | m ∣ n ∧ ¬ 4 ∣ m}, m.val := by sorry"} -{"project_name": "JacobsonMorozovTheorem", "name": "Jacobson_Morozov", "type": "theorem", "title": "Jacobson-Morozov Theorem", "informal_statement": "Assume that $\\mathfrak{g}$ is a semi-simple Lie algebra. Let $x$ be a non-zero nilpotent element\n of $\\mathfrak{g}$. There exist elements $h, y \\in \\mathfrak{g}$ such that $(x, h, y)$ is an\n $\\mathfrak{sl}_2$-triplet.", "informal_proof": "\\chapter{The Jacobson-Morozov Theorem}\n\nThis section contains a proof of the Jacobson-Morozov Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Jacobson%E2%80%93Morozov_theorem} for more details.\n\n% TODO: This seems unused by the rest of the formalization\n% \\begin{definition}[$\\mathfrak{sl}_2$-Triplet]\n% \\label{def:sl2_triplet}\n% \\mathlibok\n% An $\\mathfrak{sl}_2$-triplet in a Lie algebra $\\mathfrak{g}$ is a sequence of elements $(x, h, y)$ of $\\mathfrak{g}$, distinct from $(0, 0, 0)$, such that\n% $$[h, x] = 2x, \\quad [h, y] = -2y, \\quad [x, y] = -h.$$\n% This defines an injective homomorphism from $\\mathfrak{sl}(2, k)$ to $\\mathfrak{g}$.\n% \\end{definition}\n\n\\begin{lemma}\n \\label{lem:isNilpotent_of_pow_trace_eq_zero}\n \\lean{Module.End.isNilpotent_of_pow_trace_eq_zero}\n Given a field $K$ which is characteristic $0$, let $V$ be a finite-dimensional vector space over\n $K$ and $f$ be a $K$-linear endomorphism of $V$. Then $f$ is nilpotent if and only if\n $\\mathrm{Tr}(f^i) = 0$ for every integer $1 \\leq i \\leq n$ where $n$ is the dimension of $V$.\n\\end{lemma}\n\n\\begin{proof}\n It's known (in mathlib) that $f$ is nilpotent iff the characteristic polynomial of $f$ is of the\n form $x^n$ hence the forward direction is clear.\n The backward direction follows from the fact that $Tr(f^i) = \\sum_{j} \\alpha_j^i$ where\n $\\alpha_j$ are all roots of the characteristic polynomial of $f$, hence every $\\alpha_j$ is\n zero and we are done.\n\\end{proof}\n\n\\begin{lemma}[Nilpotency of a Product of Endomorphisms]\n \\label{lem:nilpotency_of_product}\n \\lean{LieAlgebra.isNilpotent_of_isNilpotent_zero_bracket}\n Let $V$ be a finite-dimensional vector space, and let $A$ and $B$ be endomorphisms of $V$.\n Assume that $A$ is nilpotent and that $[A, [A, B]] = 0$. Then the product $AB$ is nilpotent.\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:isNilpotent_of_pow_trace_eq_zero}\n Let $C = [A, B]$. Since $[A, C] = 0$, we have $[A, BC^p] = [A, B]C^p = C^{p+1}$ for every integer\n $p \\geq 0$. Consequently, $\\mathrm{Tr}(C^p) = 0$ for $p \\geq 1$, which proves that $C$ is nilpotent.\n Now let $\\bar{k}$ be an algebraic closure of $k$, and let $\\lambda \\in \\bar{k}$ and\n $x \\in V \\otimes_k \\bar{k}$ be such that $ABx = \\lambda x$ and $x \\neq 0$. The relation $[[B, A], A] = 0$\n shows that $[B, A^p] = p[B, A]A^{p-1}$ for every integer $p \\geq 0$. Let $r$ be the smallest integer\n such that $A^r x = 0$. Then\n $$\\lambda A^{r-1}x = A^{r-1}ABx = A^r Bx = B A^r x - [B, A^r]x = -r[B, A]A^{r-1}x.$$\n Since $[B, A] = -C$ is nilpotent and $A^{r-1}x \\neq 0$, this proves that $\\lambda = 0$.\n Thus, all the eigenvalues of $AB$ are zero, which implies that $AB$ is nilpotent.\n\\end{proof}\n\n\\begin{lemma}[Existence of the Third Triplet Element]\n \\label{lem:existence_of_third_element}\n \\lean{LieAlgebra.exists_Sl2triple}\n Let $h, x \\in \\mathfrak{g}$ be such that $[h, x] = 2x$ and $h \\in \\mathrm{Im}(\\mathrm{ad}\\,x)$.\n Then there exists an element $y \\in \\mathfrak{g}$ such that $(x, h, y)$ is either $(0, 0, 0)$\n or an $\\mathfrak{sl}_2$-triplet.\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:nilpotency_of_product}\n Let $\\mathfrak{g}' = kh + kx$. Since $x \\in [\\mathfrak{g}', \\mathfrak{g}']$, the endomorphism $\\mathrm{ad}_{\\mathfrak{g}}\\,x$ is nilpotent. Let $\\mathfrak{n} = \\mathrm{Ker}(\\mathrm{ad}\\,x)$. Since $[\\mathrm{ad}\\,h, \\mathrm{ad}\\,x] = \\mathrm{ad}\\,[h, x] = 2\\,\\mathrm{ad}\\,x$, we have $(\\mathrm{ad}\\,h)\\mathfrak{n} \\subset \\mathfrak{n}$.\n\n Let $z \\in \\mathfrak{g}$ be such that $h = -[x, z]$. The eigenvalues of $\\mathrm{ad}\\,h|_{\\mathfrak{n}}$ are non-negative integers. Therefore, the restriction of $\\mathrm{ad}\\,h + 2$ to $\\mathfrak{n}$ is invertible.\n\n Now consider the element $[h, z] + 2z$. We have\n $$[x, [h, z] + 2z] = [[x, h], z] + [h, [x, z]] + 2[x, z] = [-2x, z] + [h, -h] + 2[x, z] = 0.$$\n This means $[h, z] + 2z \\in \\mathfrak{n}$. Since $\\mathrm{ad}\\,h + 2$ is invertible on $\\mathfrak{n}$, there exists an element $z' \\in \\mathfrak{n}$ such that $[h, z'] + 2z' = [h, z] + 2z$. Let $y = z - z'$. Then $[h, y] = -2y$. Since $z' \\in \\mathfrak{n} = \\mathrm{Ker}(\\mathrm{ad}\\,x)$, we have $[x, y] = [x, z - z'] = [x, z] = -h$. Thus, $(x, h, y)$ forms an $\\mathfrak{sl}_2$-triplet (or is $(0,0,0)$ if $x,h,y$ are all zero), completing the proof.\n\\end{proof}\n\n\\begin{theorem}[Jacobson-Morozov Theorem]\n \\label{thm:jacobson_morozov}\n \\lean{Jacobson_Morozov}\n Assume that $\\mathfrak{g}$ is a semi-simple Lie algebra. Let $x$ be a non-zero nilpotent element\n of $\\mathfrak{g}$. There exist elements $h, y \\in \\mathfrak{g}$ such that $(x, h, y)$ is an\n $\\mathfrak{sl}_2$-triplet.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:existence_of_third_element, lem:nilpotency_of_product}\n Let $\\Phi$ be the Killing form of $\\mathfrak{g}$. Let $\\mathfrak{n} = \\mathrm{Ker}((\\mathrm{ad}\\,x)^2)$.\n For any $z \\in \\mathfrak{n}$, we have\n $[\\mathrm{ad}\\,x, [\\mathrm{ad}\\,x, \\mathrm{ad}\\,z]] = \\mathrm{ad}([x, [x, z]]) = 0$.\n Since $\\mathrm{ad}\\,x$ is nilpotent, Lemma \\ref{lem:nilpotency_of_product} implies that\n $(\\mathrm{ad}\\,x) \\circ (\\mathrm{ad}\\,z)$ is nilpotent. Therefore,\n $\\Phi(x, z) = \\mathrm{Tr}(\\mathrm{ad}\\,x \\circ \\mathrm{ad}\\,z) = 0$. This shows that $x$ is\n orthogonal to $\\mathfrak{n}$ with respect to the Killing form $\\Phi$.\n Since $\\Phi$ is non-degenerate and invariant, the orthogonal complement of $\\mathfrak{n}$ is\n the image of $(\\mathrm{ad}\\,x)^2$. Thus, $x$ must be in the image of $(\\mathrm{ad}\\,x)^2$.\n This means there exists an element $y' \\in \\mathfrak{g}$ such that $x = [x, [x, y']]$.\n Let $h = -2[x, y']$. Then we have $[h, x] = -2[[x, y'], x] = 2[x, [x, y']] = 2x$. Also,\n $h = [x, -2y'] \\in \\mathrm{Im}(\\mathrm{ad}\\,x)$. The conditions of Lemma\n \\ref{lem:existence_of_third_element} are now satisfied for $h$ and $x$.\n Since $x$ is non-zero, the triplet cannot be $(0,0,0)$. Therefore, there exists an element\n $y \\in \\mathfrak{g}$ such that $(x, h, y)$ is an $\\mathfrak{sl}_2$-triplet.\n\\end{proof}\n", "code": "import Mathlib\n\n\nset_option maxHeartbeats 800000 in\n\n\nopen Submodule in\n\n\ntheorem Jacobson_Morozov (x : L) [FiniteDimensional ℂ L] [hL : LieAlgebra.IsSemisimple ℂ L]\n (hx0 : x ≠ 0) (hx : IsNilpotent (LieAlgebra.ad ℂ L x)) : ∃ h y : L, IsSl2Triple h x y := by sorry"} -{"project_name": "JonesLemma", "name": "jones", "type": "theorem", "title": "Jones' Lemma", "informal_statement": "Let $X$ be a normal and separable space. Let $Y$ be a discrete and closed subspace of $X$.\n Then $2^{|Y|} \\leq 2^{\\aleph_0}$.", "informal_proof": "\\chapter{Jones' Lemma}\n\nThis section contains a proof of Jones' Lemma.\nSee \\url{https://en.wikipedia.org/wiki/Jones%27_lemma} for more details.\n\n\\begin{theorem}\n \\label{them:jones}\n \\lean{jones}\n Let $X$ be a normal and separable space. Let $Y$ be a discrete and closed subspace of $X$.\n Then $2^{|Y|} \\leq 2^{\\aleph_0}$.\n\\end{theorem}\n\\begin{proof}\n Let $D$ be a countable dense subset of $X$. Since $Y$ is discrete and closed, any $A \\subset Y$\n is closed.\n Since $X$ is normal, for any $A \\subseteq Y$, there exists two disjoint open sets $U_A, V_A$\n such that $A \\subseteq U_A$ and $Y \\setminus A \\subseteq V_A$.\n Therefore, if $A, B \\subseteq Y$ and $A \\neq B$, then $\\bar{U_A} \\neq \\bar{U_B}$.\n For any $A \\subseteq Y$, we define $C_A = U_A \\cap D$.\n Since $D$ is dense, we have $\\bar{U_A} = \\bar{U_A \\cap D} = \\bar{C_A}$ for $A \\subseteq Y$.\n Therefore, if $A, B \\subseteq Y$ and $A \\neq B$, then $C_A \\neq C_B$.\n That means, the map $A \\mapsto C_A$ is an injection from the power set of $Y$ to\n the power set of $D$.\n Therefore, $2^{|Y|} \\leq 2^{|D|} \\leq 2^{\\aleph_0}$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen TopologicalSpace Cardinal Set\n\n\ntheorem jones {X : Type*} [TopologicalSpace X] [SeparableSpace X] [NormalSpace X] {Y : Set X}\n (hc : IsClosed Y) (hd : IsDiscrete Y) : 2 ^ #Y ≤ 𝔠 := by sorry"} -{"project_name": "JordanSchurTheorem", "name": "jordan_schur", "type": "theorem", "title": "Jordan–Schur theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Jordan–Schur theorem}\n\nThis section contains a (stub of a) proof of the Jordan–Schur theorem.\nSee \\url{https://en.wikipedia.org/wiki/Jordan–Schur_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Jordan–Schur theorem]\n \\label{thm:jordan-schur-theorem}\n \\lean{jordan_schur}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Function Set Matrix Group\n\n\ntheorem jordan_schur : ∃ f : ℕ → ℝ, ∀ n : ℕ, ∀ G : Subgroup (GeneralLinearGroup (Fin n) ℂ),\n Finite G → ∃ H : Subgroup G, H.Normal ∧ H.Abelian ∧ H.index ≤ f n := by sorry"} -{"project_name": "Joubert", "name": "exists_generator_of_minpoly_with_some_zero_coeffs", "type": "theorem", "title": "Joubert's Theorem", "informal_statement": "% \\uses{lemma:proposition3}\n If $K$ and $L$ are fields, $L$ is a separable field extension of $K$ of degree $6$, and the characteristic of $K$ is not equal to 2, then $L$ is generated over $K$ by some element $\\lambda$ in $L$, such that the minimal polynomial $p$ of $\\lambda$ has the form $p(t) = t^6 + c_4t^4 + c_2t^2 + c_1t + c_0$, for some constants $c_4, c_2, c_1, c_0$ in $K$.", "informal_proof": "\\chapter{The Joubert's Theorem}\n\nThis section contains a proof of Joubert's theorem.\nSee \\url{https://arxiv.org/pdf/math/0403323} for more details.\n\n% TODO: the following lemmas need to be associated with lean statements, they are commented out for now\n% \\begin{lemma}[Lemma 1]\n% \\label{lemma:lemma1}\n% % \\lean{}\n% Let $\\Phi = (\\varphi_1,\\varphi_2,\\dots,\\varphi_n): \\mathbb{A}^n \\to \\mathbb{A}^n$ be a covariant defined over $K$.\\\\\n% (1)\\; $\\varphi_1$ is invariant under $S_{n-1}\\subset S_n$ acting on the last $n-1$ variables, and $\\varphi_k = (1k)\\varphi_1$ where $(1k)$ denotes the transposition of $1$ and $k$. Conversely, every $S_{n-1}$-invariant polynomial $\\varphi_1$ defines a unique covariant $\\Phi$ whose first component is $\\varphi_1$.\\\\\n% (2)\\; There is a uniquely defined polynomial $\\varphi = \\varphi(f,X) = \\varphi(a_1,\\dots,a_n,X)\\in K[P^n][X]$\n% of degree $ 0$, the following three properties hold:\n \\begin{enumerate}\n \\item We have $\\sum_{n} \\PR(|X_n| > K) \\, < \\, \\infty$.\n \\item The series $\\sum_{n} \\EV \\big[ X_n \\, \\indicOf{|X_n| \\le K} \\big]$ converges.\n \\item We have $\\sum_{n} \\mathrm{Var} \\big( X_n \\, \\indicOf{|X_n| \\le K} \\big) \\, < \\, \\infty$.\n \\end{enumerate}", "informal_proof": "\\chapter{Kolmogorov's Three Series Theorem, necessity part}\n\nThis section contains a proof of the necessity direction of Kolmogorov's Three Series Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Kolmogorov's_three-series_theorem}\nand \\emph{Williams: \"Probability with Martingales\" (Theorem 12.5)} for more details.\n\nBelow, the convergence of a series $\\sum_{n \\in \\N} x_n$ of real numbers\nalways means\n\\emph{conditional convergence}, i.e., the existence of the limit\n\\begin{align*}\n \\lim_{N \\to \\infty} \\sum_{n=0}^{N} x_n\n\\end{align*}\nof its partial sums. (For measure theory purposes, by contrast,\n\\emph{absolute convergence} is a more commonly used notion;\nit amounts to integrability with respect to the counting measure.)\n\n\\begin{lemma}[Compensator martingale]\n \\label{lem:compensator_martingale}\n %\\uses{}\n \\lean{martingale_sq_sum_sub_sum_integral_sq}\n \\leanok\n Let $(X_n)_{n \\in \\N}$ be a sequence of independent, square-integrable,\n zero-mean real-valued random variables.\n Define $M_n = \\sum_{i=0}^{n-1} X_i$ for $n \\in \\N$.\n %Let $(M_n)_{n \\in \\N}$ be a martingale with respect to a\n %filtration $(\\PRsigma_n)_{n \\in \\N}$, such that for all $n$,\n %the increment $M_{n+1} - M_n$ is square-integrable (in $L^2$).\n Then defining the sequence $(s_n)_{n \\in \\N}$\n \\begin{align*}\n s_n \\; = \\; \\sum_{i=0}^{n-1} \\mathrm{Var}(X_n) ,\n \\end{align*}\n and the process $(N_n)_{n \\in \\N}$\n \\begin{align*}\n N_n \\; = \\; M_n^2 - s_n ,\n \\end{align*}\n we have that $(N_n)_{n \\in \\N}$ is a martingale with respect to the\n natural filtration $(\\PRsigma_n)_{n \\in \\N}$ of the sequence $(X_n)_{n \\in \\N}$.\n\\end{lemma}\n\\begin{proof}\n \\uses{lem:martingale_of_partial_sums}\n % \\leanok\n By Lemma~\\ref{lem:martingale_of_partial_sums},\n $(M_n)_{n \\in \\N}$ is a martingale with respect to\n $(\\PRsigma_n)_{n \\in \\N}$.\n\n Note, first, that we have\n \\begin{align*}\n \\EV \\big[ (M_{n+1} - M_n)^2 \\; \\big| \\; \\PRsigma_n \\big]\n \\; = \\; \\EV\\big[ X_n^2 \\; \\big| \\; \\PRsigma_n \\big]\n \\; = \\; \\EV[X_n^2]\n \\; = \\; \\mathrm{Var}(X_n) ,\n \\end{align*}\n by construction of $M$, by independence\n of $X_n$ from $\\PRsigma_n = \\sigma(X_0,\\ldots,X_{n-1})$,\n and by the assumption $\\EV[X_n]=0$.\n\n Since $M_{n}$ is $\\PRsigma_n$-measurable, we have\n \\begin{align*}\n \\EV \\big[ (M_{n+1} - M_n)^2 \\; \\big| \\; \\PRsigma_n \\big]\n \\; = \\; & \\EV \\big[ M_{n+1}^2 - 2 M_{n+1} M_{n} + M_n^2 \\; \\big| \\; \\PRsigma_n \\big] \\\\\n \\; = \\; & \\EV \\big[ M_{n+1}^2 \\big| \\; \\PRsigma_n \\big]\n - 2 M_{n} \\, \\underbrace{\\EV \\big[ M_{n+1} \\big| \\; \\PRsigma_n \\big]}_{= M_n}\n + M_n^2 \\\\\n \\; = \\; & \\EV \\big[ M_{n+1}^2 \\big| \\; \\PRsigma_n \\big] - M_n^2 .\n \\end{align*}\n By unraveling definitions and rearranging, we get the martingale\n property of the process $(N_n)_{n \\in \\N}$:\n \\begin{align*}\n \\EV \\big[ N_{n+1} \\; \\big| \\; \\PRsigma_n \\big]\n \\; = \\; & \\EV \\big[ M_{n+1}^2 \\; \\big| \\; \\PRsigma_n \\big]\n - s_{n+1}\n %- \\underbrace{s_{n+1}}_{= s_n + \\mathrm{Var}(X_n)}\n \\\\\n \\; = \\; & \\Big( M_n^2 + \\EV \\big[ (M_{n+1} - M_n)^2 \\; \\big| \\; \\PRsigma_n \\big] \\Big)\n - \\big( s_{n} + \\mathrm{Var}(X_n) \\big) \\\\\n \\; = \\; & M_n^2 - s_{n} \\\\\n \\; = \\; & N_n .\n \\end{align*}\n\\end{proof}\n\n\\begin{lemma}[Summable variances of bounded independent zero-mean variables]\n \\label{lem:summable_variance_independent_bounded_zero_mean}\n %\\uses{}\n \\lean{tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_integral_zero_of_forall_bounded}\n \\leanok\n Let $K \\in [0,+\\infty)$ and let $(X_n)_{n \\in \\N}$ be a sequence of independent real-valued\n random variables such that\n $|X_n| \\le K$ almost surely and $\\EV[X_n]=0$ for each $n \\in \\N$.\n Suppose that $\\sum_n X_n$ converges almost surely.\n Then we have\n \\begin{align*}\n \\sum_n \\mathrm{Var}(X_n) \\; < \\; \\infty .\n \\end{align*}\n\\end{lemma}\n\\begin{proof}\n \\uses{lem:martingale_of_partial_sums, lem:compensator_martingale}\n % \\leanok\n Denote, for $n \\in \\N$,\n \\begin{align*}\n s_n = \\sum_{i=1}^{n-1} \\mathrm{Var}(X_i) ,\n \\end{align*}\n and $s_\\infty = \\sum_i \\mathrm{Var}(X_i)$.\n We must prove that $s_\\infty < +\\infty$.\n\n By Lemma~\\ref{lem:martingale_of_partial_sums},\n the process $(M_n)_{n \\in \\N}$ defined by\n \\begin{align*}\n M_n \\; := \\; \\sum_{i=0}^{n-1} X_i\n \\end{align*}\n is a martingale with respect to the natural filtration $(\\PRsigma_n)_{n \\in \\N}$\n of the sequence $(X_n)_{n \\in \\N}$.\n\n From the assumption that $\\sum_{i} X_i$ converges almost surely\n we get that $(M_n)_{n \\in \\N}$ in particular is bounded\n almost surely.\n Defining, for $c \\in \\R$, the stopping time\n \\begin{align*}\n T_c \\; := \\; \\inf \\big\\{ n \\in \\N \\; \\big| \\; |M_n| > c \\big\\} ,\n \\end{align*}\n the almost sure boundedness implies that for some sufficiently large $c$,\n we have $\\PR [T_c = \\infty] > 0$.\n Fix such a value $c \\in [0,+\\infty)$.\n\n By Lemma~\\ref{lem:compensator_martingale}, the process $(N_n)_{n \\in \\N}$ defined by\n \\begin{align*}\n N_n \\; := \\; M_n^2 - s_n\n \\end{align*}\n is a martingale, so in particular\n \\begin{align*}\n 0 \\; = \\; & \\EV[N_{n \\wedge T_c}] - \\EV[N_0]\n \\; = \\; \\EV[N_{n \\wedge T_c}]\n \\; = \\; \\EV[M^2_{n \\wedge T_c}] - \\EV[s_{n \\wedge T_c}] .\n \\end{align*}\n By the almost sure bound $|X_i| \\le K$, we have that\n $|M_n^{T_c}| \\le c + K$ almost surely, for any $n$, and we get\n in particular that\n \\begin{align*}\n \\EV[s_{n \\wedge T_c}] = \\EV[M^2_{n \\wedge T_c}] \\le (c + K)^2 ,\n \\end{align*}\n for any $n$.\n But since we chose $c$ so that $\\PR[T_c = \\infty] > 0$,\n with positive probability we have $s_{n \\wedge T_c} \\nearrow s_\\infty$.\n This would contradict $\\EV[s_{n \\wedge T_c}] \\le (c + K)^2$\n if $s_\\infty = +\\infty$. We thus conclude the desired $s_\\infty < +\\infty$.\n\\end{proof}\n\nIt turns out that the assumption of zero-mean is not necessary above.\n\\begin{lemma}[Summable variances of bounded independent variables]\n \\label{lem:summable_variance_independent_bounded}\n %\\uses{}\n \\lean{tsum_evariance_ne_top_of_exists_ae_tendsto_of_forall_bounded}\n \\leanok\n Let $K \\in [0,+\\infty)$ and let $(X_n)_{n \\in \\N}$ be a sequence of independent\n real-valued random variables such that\n $|X_n| \\le K$ almost surely for each $n \\in \\N$.\n Suppose that $\\sum_n X_n$ converges almost surely.\n Then we have that $\\sum_n \\EV [X_n]$ converges and\n $\\sum_n \\mathrm{Var}(X_n) \\; < \\; \\infty$.\n\\end{lemma}\n\\begin{proof}\n \\uses{lem:summable_variance_independent_bounded_zero_mean}\n % \\leanok\n The proof uses a construction of two independent copies of the\n sequence $(X_n)_{n \\in \\N}$.\n To construct the copies, it suffices to take the product of the\n underlying probability space with itself, and equip it with the\n product measure.\n\n So let $(X^{(1)}_n)_{n \\in \\N}$ and $(X^{(2)}_n)_{n \\in \\N}$ be independent,\n following the same distribution as $(X_n)_{n \\in \\N}$.\n\n Denote $Z_n = X^{(1)}_n - X^{(2)}_n$, for $n \\in \\N$.\n\n Note that both series $\\sum_n X^{(1)}_n$ and $\\sum_n X^{(2)}_n$\n converge almost surely, and therefore almost surely they both converge simultaneously.\n Therefore the series $\\sum_n Z_n$ of the differences also\n converges almost surely.\n\n Also almost surely both $X^{(1)}_n \\le K$ and $|X^{(2)}_n| \\le K$\n for all $n$. Thus clearly $|Z_n| \\le 2 K$ almost surely.\n Moreover, we have\n \\begin{align*}\n \\EV[Z_n] = \\EV[X^{(1)}_n] - \\EV[X^{(2)}_n] = \\EV[X_n] - \\EV[X_n] = 0\n \\end{align*}\n and (by independence)\n \\begin{align*}\n \\mathrm{Var}(Z_n)\n \\; = \\; \\mathrm{Var}(X^{(1)}_n - X^{(2)}_n)\n \\; = \\; \\mathrm{Var}(X^{(1)}_n) + \\mathrm{Var}(X^{(2)}_n)\n \\; = \\; 2 \\, \\mathrm{Var}(X_n) .\n \\end{align*}\n Finally, the members of the sequence $(Z_n)_{n \\in \\N}$ are independent.\n\n Lemma~\\ref{lem:summable_variance_independent_bounded_zero_mean}\n now applies to $(Z_n)_{n \\in \\N}$, and yields that\n $\\sum_n \\mathrm{Var}(Z_n) \\; < \\; \\infty$, which in view of\n $\\mathrm{Var}(Z_n) = 2 \\, \\mathrm{Var}(X_n)$ implies\n \\begin{align*}\n \\sum_n \\mathrm{Var}(X_n) \\; < \\; \\infty ,\n \\end{align*}\n which is one of the two parts of our assertion.\n\n Denote\n \\begin{align*}\n Y_n \\; := \\; X_n - \\EV[X_n] ,\n \\end{align*}\n and construct a martingale $(M_n)_{n \\in \\N}$ by\n \\begin{align*}\n M_n \\; := \\; \\sum_{i=0}^{n-1} Y_i .\n \\end{align*}\n From Lemma~\\ref{lem:martingale_of_partial_sums_L2_norm}\n and $\\sum_n \\mathrm{Var}(Y_n) = \\sum_n \\mathrm{Var}(X_n) \\; < \\; \\infty$\n we see that $(M_n)_{n \\in \\N}$ are bounded in $L^2$.\n In particular, the martingale convergence theorem\n gives almost sure limit for $M_n$ as $n \\to \\infty$.\n This means that\n \\begin{align*}\n \\sum_{n} Y_n \\; = \\; \\sum_{n} \\big( X_n - \\EV[X_n] \\big)\n \\end{align*}\n converges almost surely.\n Since $\\sum_n X_n$ was assumed to converge almost surely,\n we get that also $\\sum_n \\EV[X_n] = \\sum_n X_n - \\sum_n (X_n - \\EV[X_n])$\n converges almost surely. This is the other part of the assertion.\n\\end{proof}\n\n\\begin{lemma}[Kolmogorov's Three Series, necessity 1]\n \\label{lem:kolmogorov_three_series_necessity_a}\n %\\uses{}\n \\lean{kolmogorov_three_series_necessity_a}\n \\leanok\n Let $(X_n)_{n \\in \\N}$ be a sequence of independent real-valued random variables\n such that the series $\\sum_{n} X_n$ converges almost surely.\n Then for any $K > 0$, we have $\\sum_{n} \\PR(|X_n| > K) \\, < \\, \\infty$.\n\\end{lemma}\n\\begin{proof}\n % \\uses{}\n % \\leanok\n Fix $K>0$.\n From the assumed almost sure convergence of $\\sum_n X_n$, we get in\n particular that the terms of the series tend to zero almost surely,\n i.e., that $X_n \\to 0$ almost surely. In particular, almost surely,\n $|X_n| > K$ for only finitely many $n$.\n From the (contrapositive of the) Borel-Cantelli lemma for independent\n events we therefore get that $\\sum_{n} \\PR(|X_n| > K)$ must converge.\n\\end{proof}\n\n\\begin{lemma}[Kolmogorov's Three Series, necessity 2]\n \\label{lem:kolmogorov_three_series_necessity_b}\n %\\uses{}\n \\lean{kolmogorov_three_series_necessity_b}\n \\leanok\n Let $(X_n)_{n \\in \\N}$ be a sequence of independent real-valued random variables\n such that the series $\\sum_{n} X_n$ converges almost surely.\n Then for any $K > 0$, the series\n $\\sum_{n} \\EV \\big[ X_n \\, \\indicOf{|X_n| \\le K} \\big]$\n converges, and moreover\n $\\sum_n \\mathrm{Var}(X_n) \\; < \\; \\infty$.\n\\end{lemma}\n\\begin{proof}\n \\uses{lem:summable_variance_independent_bounded}\n % \\leanok\n Fix $K>0$.\n From the assumed almost sure convergence of $\\sum_n X_n$, we get in\n particular that the terms of the series tend to zero almost surely,\n i.e., that $X_n \\to 0$ almost surely. In particular, almost surely,\n $|X_n| > K$ for only finitely many $n$, and\n therefore\n $X_n = X_n \\, \\indicOf{|X_n| \\le K}$ except for finitely many $n$.\n Therefore the convergence of $\\sum_n X_n$ implies the\n convergence of $\\sum_n X_n \\, \\indicOf{|X_n| \\le K}$.\n Lemma~\\ref{lem:summable_variance_independent_bounded}\n now implies both of the assertions.\n\\end{proof}\n\n\\begin{theorem}[Kolmogorov's Three Series, necessity]\n \\label{thm:kolmogorov_three_series_necessity}\n %\\uses{}\n \\lean{kolmogorov_three_series_necessity}\n \\leanok\n Let $(X_n)_{n \\in \\N}$ be a sequence of independent real-valued random variables\n such that the series $\\sum_{n} X_n$ converges almost surely.\n Then for any $K > 0$, the following three properties hold:\n \\begin{enumerate}\n \\item We have $\\sum_{n} \\PR(|X_n| > K) \\, < \\, \\infty$.\n \\item The series $\\sum_{n} \\EV \\big[ X_n \\, \\indicOf{|X_n| \\le K} \\big]$ converges.\n \\item We have $\\sum_{n} \\mathrm{Var} \\big( X_n \\, \\indicOf{|X_n| \\le K} \\big) \\, < \\, \\infty$.\n \\end{enumerate}\n\\end{theorem}\n\\begin{proof}\n \\uses{lem:kolmogorov_three_series_necessity_a,\n lem:kolmogorov_three_series_necessity_b}\n This is just a combination of\n Lemmas~\\ref{lem:kolmogorov_three_series_necessity_a}\n and~\\ref{lem:kolmogorov_three_series_necessity_b}.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\n\ntheorem kolmogorov_three_series_necessity\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s))\n {b : ℝ} (b_pos : 0 < b) :\n (∑' n, P {ω | b < |X n ω|} ≠ ∞) ∧\n (∃ s,\n Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, ((Set.indicator {ω | |X n ω| ≤ b} (X n)) ω) ∂P)\n atTop (𝓝 s)) ∧\n (∑' n, evariance (Set.indicator {ω | |X n ω| ≤ b} (X n)) P ≠ ∞) := by sorry"} -{"project_name": "KolmogorovThreeSeriesSufficient", "name": "kolmogorov_three_series_sufficiency", "type": "theorem", "title": "Kolmogorov's Three Series, sufficiency", "informal_statement": "%\\uses{}\n \\leanok\n Let $(X_n)_{n \\in \\N}$ be a sequence of independent real-valued random variables.\n Suppose that there exists a $K > 0$ such that the following three properties hold:\n \\begin{enumerate}\n \\item We have $\\sum_{n} \\PR(|X_n| > K) \\, < \\, \\infty$.\n \\item The series $\\sum_{n} \\EV \\big[ X_n \\, \\indicOf{|X_n| \\le K} \\big]$ converges.\n \\item We have $\\sum_{n} \\mathrm{Var} \\big( X_n \\, \\indicOf{|X_n| \\le K} \\big) \\, < \\, \\infty$.\n \\end{enumerate}\n Then the series $\\sum_{n} X_n$ converges almost surely.", "informal_proof": "\\chapter{Kolmogorov's Three Series Theorem, sufficiency part}\n\nThis section contains a proof of the sufficiency direction of Kolmogorov's Three Series Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Kolmogorov's_three-series_theorem}\nand \\emph{Williams: \"Probability with Martingales\" (Theorem 12.5)} for more details.\n\nBelow, the convergence of a series $\\sum_{n \\in \\N} x_n$ of real numbers\nalways means\n\\emph{conditional convergence}, i.e., the existence of the limit\n\\begin{align*}\n \\lim_{N \\to \\infty} \\sum_{n=0}^{N} x_n\n\\end{align*}\nof its partial sums. (For measure theory purposes, by contrast,\n\\emph{absolute convergence} is a more commonly used notion;\nit amounts to integrability with respect to the counting measure.)\n\n\\begin{lemma}[Series differing only at finitely many terms]\n \\label{lem:series_of_finitely_differing_terms}\n %\\uses{}\n \\lean{Filter.EventuallyEq.tendsto_sum_range_add_finsum_of_cofinite}\n \\leanok\n Let $(x_n)_{n \\in \\N}$ and $(y_n)_{n \\in \\N}$ be sequences of real numbers\n such that $x_n = y_n$ for all but finitely many $n \\in \\N$.\n Then the series $\\sum_n x_n$ converges if and only if the\n series $\\sum_n y_n$ converges, and in that case, the sums\n of these series are related by\n \\begin{align*}\n \\sum_n x_n = \\sum_n y_n + \\sum_{n \\; : \\; x_n \\ne y_n} (x_n - y_n) ,\n \\end{align*}\n where the last sum only has finitely many nonzero terms.\n\\end{lemma}\n\\begin{proof}\n % \\uses{}\n \\leanok\n By assumption, there exists an $N_0 \\in \\N$ such that\n $x_n = y_n$ for all $n \\ge N_0$. Then the partial sums\n with $N \\ge N_0$ evidently satisfy\n \\begin{align*}\n \\sum_{n=0}^N x_n = \\sum_{n=0}^N y_n + \\sum_{n \\; : \\; x_n \\ne y_n} (x_n - y_n) .\n \\end{align*}\n From here it is clear that the existence of the limits of partial sums\n for the two series are equivalent, and their difference is the\n rightmost finite sum.\n\\end{proof}\n\n\\begin{lemma}[Martingale of partial sums]\n \\label{lem:martingale_of_partial_sums}\n %\\uses{}\n \\lean{sum_terms_mgale}\n \\leanok\n Let $(Y_i)_{i \\in \\N}$ be a sequence of independent real-valued random variables\n of mean zero, $\\EV[Y_i] = 0$ for all $i$.\n Then the process $(M_n)_{n \\in \\N}$ defined by\n \\begin{align*}\n M_n \\; := \\; \\sum_{i=0}^{n-1} Y_i\n \\end{align*}\n is a martingale with respect to the natural filtration $(\\PRsigma_n)_{n \\in \\N}$\n of the sequence $(Y_n)_{n \\in \\N}$ defined by\n $\\PRsigma_n = \\sigma(Y_0, \\ldots, Y_{n-1})$ for $n \\in \\N$.\n\\end{lemma}\n\\begin{proof}\n % \\uses{}\n \\leanok\n Adaptedness and integrability of $M_n$ are clear.\n\n Let $n \\in \\N$.\n By adaptedness, we have $\\EV[M_n \\, | \\, \\PRsigma_n] = M_n$.\n By independence of $(Y_n)_{n \\in \\N}$,\n we have that $Y_n$ is independent of $\\PRsigma_n$, and therefore\n $\\EV[Y_n \\, | \\, \\PRsigma_n] = \\EV[Y_n]$.\n The martingale property of $(M_n)_{n \\in \\N}$ follows from these and the zero-mean\n property $\\EV[Y_n] = 0$, since\n \\begin{align*}\n \\EV[M_{n+1} \\, | \\, \\PRsigma_n]\n \\; = \\; & \\EV[M_n + Y_n \\, | \\, \\PRsigma_n] \\\\\n \\; = \\; & M_n + \\underbrace{\\EV[Y_n \\, | \\, \\PRsigma_n]}_{= \\EV[Y_n] = 0} \\; = \\; M_n .\n \\end{align*}\n\\end{proof}\n\n\\begin{lemma}[$L^2$ norm of martingale of partial sums]\n \\label{lem:martingale_of_partial_sums_L2_norm}\n %\\uses{lem:martingale_of_partial_sums}\n \\lean{eLpNorm_two_sq_sum_terms_eq_sum_evariance}\n \\leanok\n Let $(Y_i)_{i \\in \\N}$ be a sequence of independent square-integrable\n real-valued random variables of mean zero, $\\EV[Y_i] = 0$ for all $i$.\n %Then the martingale $(M_n)_{n \\in \\N}$ defined by\n Then the $L^2$-norm squared of\n \\begin{align*}\n M_n \\; := \\; \\sum_{i=0}^{n-1} Y_i\n \\end{align*}\n %has $L^2$-norms given by\n is given by\n \\begin{align*}\n \\|M_n\\|_2^2 \\; = \\; \\EV[M_n^2] \\; = \\; \\sum_{i=0}^{n-1} \\mathrm{Var}[Y_i] .\n \\end{align*}\n\\end{lemma}\n\\begin{proof}\n % \\uses{}\n \\leanok\n Since $M_n$ is itself clearly zero-mean, we have $\\EV[M_n^2] = \\mathrm{Var}[M_n]$.\n Furthermore, since $M_n = \\sum_{i=0}^{n-1} Y_i$ with independent terms $Y_i$, we have\n $\\mathrm{Var}[M_n] = \\sum_{i=0}^{n-1} \\mathrm{Var}[Y_i]$.\n\\end{proof}\n\n\\begin{theorem}[Kolmogorov's Three Series, sufficiency]\n \\label{thm:kolmogorov_three_series_sufficiency}\n %\\uses{}\n \\lean{kolmogorov_three_series_sufficiency}\n \\leanok\n Let $(X_n)_{n \\in \\N}$ be a sequence of independent real-valued random variables.\n Suppose that there exists a $K > 0$ such that the following three properties hold:\n \\begin{enumerate}\n \\item We have $\\sum_{n} \\PR(|X_n| > K) \\, < \\, \\infty$.\n \\item The series $\\sum_{n} \\EV \\big[ X_n \\, \\indicOf{|X_n| \\le K} \\big]$ converges.\n \\item We have $\\sum_{n} \\mathrm{Var} \\big( X_n \\, \\indicOf{|X_n| \\le K} \\big) \\, < \\, \\infty$.\n \\end{enumerate}\n Then the series $\\sum_{n} X_n$ converges almost surely.\n\\end{theorem}\n\\begin{proof}\n \\uses{lem:series_of_finitely_differing_terms, lem:martingale_of_partial_sums,\n lem:martingale_of_partial_sums_L2_norm}\n \\leanok\n Denote $X_n^K := X_n \\, \\indicOf{|X_n| \\le K}$ for brevity.\n\n Note first that by (1.)\n \\begin{align*}\n \\sum_n \\PR \\big[ X_n \\ne X_n^K \\big] \\; \\le \\; \\sum_n \\PR \\big[ |X_n| > K \\big] \\; < \\; \\infty .\n \\end{align*}\n It follows from the first Borel-Cantelli lemma that, almost surely,\n $X_n = X_n^K$ for all but finitely many $n \\in \\N$, i.e., there\n exists a (random, almost surely finite) $N$ such that\n \\begin{align*}\n X_n = X_n^K \\qquad \\text{ for all $n \\ge N$.}\n \\end{align*}\n Therefore it suffices to prove that $\\sum_{n} X_n^K$ converges almost surely.\n\n Denote $Y_n^K = X_n^K - \\EV[X_n^K]$.\n By (2.) it is enough to prove that the series\n $\\sum_{n} Y_n^K = \\sum_n \\big( X_n^K - \\EV[X_n^K] \\big)$ converges almost surely.\n\n The sequence $(Y_n^K)_{n \\in \\N}$ is a sequence of independent, integrable,\n zero-mean random variables, so the process $(M_n)_{n \\in \\N}$ defined by\n \\begin{align*}\n M_n \\; := \\; \\sum_{i=0}^{n-1} Y_i^K\n \\end{align*}\n is a martingale, and\n \\begin{align*}\n \\EV[M_n^2] \\; = \\; \\mathrm{Var}[M_n] \\; = \\; & \\sum_{i=0}^{n-1} \\mathrm{Var}[Y_i^K]\n = \\; \\sum_{i=0}^{n-1} \\mathrm{Var}[X_i^K] .\n \\end{align*}\n By assumption (3.), the last expression is bounded uniformly in $n$.\n Therefore $(M_n)_{n \\in \\N}$ is a martingale bounded in $L^2$,\n and so by the Martingale Convergence Theorem, it converges almost surely (and in $L^2$).\n Thus the series $\\sum_n Y_n^K$ converges almost surely, and the proof is complete.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\n\ntheorem kolmogorov_three_series_sufficiency\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (b_pos : 0 < b) (sum_pr_gt_finite : ∑' n, P {ω | b < |X n ω|} ≠ ∞)\n (sum_ev_indic_finite : ∃ s,\n Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, ((Set.indicator {ω | |X n ω| ≤ b} (X n)) ω) ∂P)\n atTop (𝓝 s))\n (sum_var_indic_finite : ∑' n, evariance (Set.indicator {ω | |X n ω| ≤ b} (X n)) P ≠ ∞) :\n ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s) := by sorry"} -{"project_name": "KoukoulopoulosMaynard", "name": "koukoulopoulos_maynard", "type": "theorem", "title": "Duffin–Schaeffer conjecture / Koukoulopoulos–Maynard theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Duffin–Schaeffer conjecture / Koukoulopoulos–Maynard theorem}\n\nThis section contains a (stub of a) proof of the Duffin–Schaeffer conjecture.\nSee \\url{https://en.wikipedia.org/wiki/Diophantine_approximation#Khinchin's_theorem_on_metric_Diophantine_approximation_and_extensions}, \\url{https://en.wikipedia.org/wiki/Duffin%E2%80%93Schaeffer_theorem}\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Duffin–Schaeffer conjecture / Koukoulopoulos–Maynard theorem]\n \\label{thm:koukoulopoulos-maynard}\n \\lean{koukoulopoulos_maynard}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen MeasureTheory Set Nat\n\n\ntheorem koukoulopoulos_maynard {f : ℕ → ℝ} (hf : ∀ n, 0 < f n) :\n (∀ᵐ (x : ℝ), {(p, q) : ℕ × ℕ | p.Coprime q ∧ |x - p / (↑q : ℝ)|\n < f q / (↑q : ℝ)}.Finite) ↔ Summable fun n ↦ φ n * f n / (↑n : ℝ) := sorry"} -{"project_name": "Kraft", "name": "kraft", "type": "theorem", "title": "Kraft", "informal_statement": "\\leanok\n Let $\\sigma$ be a finite nonempty alphabet of size $D = |\\sigma|$,\n and let $l_1, \\ldots, l_m$ be natural numbers satisfying\n \\[\n \\sum_{i=1}^{m} D^{-l_i} \\leq 1.\n \\]\n Then there exists a prefix-free code $C$ over $\\sigma$ whose codeword\n lengths are exactly $l_1, \\ldots, l_m$ (as a multiset).", "informal_proof": "\\chapter{Kraft's Theorem}\n\nThis section contains a proof of Kraft's Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Kraft%E2%80%93McMillan_inequality} for more details.\n\nLet $\\sigma$ be a finite nonempty set, which we call the \\emph{alphabet}.\nWe write $D = |\\sigma|$ for the size of the alphabet.\n\n\\begin{definition}[Code]\n \\label{def:Kraft_Code}\n \\lean{Kraft.Code}\n \\leanok\n A \\emph{code} $C$ over the alphabet $\\sigma$ is a finite set of finite strings\n over $\\sigma$. The elements of $C$ are called \\emph{codewords}.\n\\end{definition}\n\n\\begin{definition}[Prefix-free code]\n \\label{def:Prefix_Free_Code}\n \\lean{Kraft.PrefixFree}\n \\uses{def:Kraft_Code}\n \\leanok\n A code $C$ is \\emph{prefix-free} if no codeword is a proper prefix of another:\n whenever $w_1, w_2 \\in C$ and $w_1$ is a prefix of $w_2$, then $w_1 = w_2$.\n\\end{definition}\n\n\\begin{definition}[Kraft sum]\n \\label{def:Kraft_Sum_List}\n \\lean{Kraft.kraftSum}\n \\leanok\n The \\emph{Kraft sum} of a list of natural numbers $l_1, \\ldots, l_m$\n with respect to an alphabet $\\sigma$ of size $D = |\\sigma|$ is\n \\[\n K(l_1, \\ldots, l_m) = \\sum_{i=1}^{m} D^{-l_i}.\n \\]\n For a code $C$ over an alphabet of size $D$, we write\n $K(C) = K(|w_1|, \\ldots, |w_m|)$ where $w_1, \\ldots, w_m$ are the\n codewords of $C$ and $|w_i|$ denotes the length of $w_i$.\n\\end{definition}\n\n\\begin{lemma}[Extensions are disjoint]\n \\label{lem:extensions-disjoint}\n \\lean{Kraft.extensions_disjoint}\n \\uses{def:Kraft_Code, def:Prefix_Free_Code}\n \\leanok\n Let $C$ be a prefix-free code. For any $n \\in \\mathbb{N}$ and distinct\n codewords $w_1, w_2 \\in C$, the sets of their extensions to length $n$\n are disjoint:\n \\[\n \\{v \\in \\sigma^n : w_1 \\text{ is a prefix of } v\\}\n \\cap\n \\{v \\in \\sigma^n : w_2 \\text{ is a prefix of } v\\}\n = \\emptyset.\n \\]\n\\end{lemma}\n\n\\begin{proof}\n \\leanok\n If $v$ has both $w_1$ and $w_2$ as prefixes, then one of $w_1, w_2$\n must be a prefix of the other (since both are prefixes of the same\n string $v$). But $C$ is prefix-free, so this forces $w_1 = w_2$,\n contradicting the assumption that they are distinct.\n\\end{proof}\n\n\\begin{lemma}[Counting blocked strings]\n \\label{lem:count-blocked}\n \\lean{Kraft.card_blocked_eq}\n \\uses{def:Kraft_Code, def:Prefix_Free_Code}\n \\leanok\n Let $C$ be a prefix-free code with all codeword lengths at most $n$.\n The number of strings of length $n$ that have some codeword of $C$\n as a prefix is exactly\n \\[\n \\sum_{w \\in C} D^{n - |w|}.\n \\]\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:extensions-disjoint}\n \\leanok\n Each codeword $w \\in C$ of length $|w| \\leq n$ can be extended in\n $D^{n - |w|}$ ways to a string of length $n$. By\n Lemma~\\ref{lem:extensions-disjoint}, these extension sets are pairwise\n disjoint, so the total count is $\\sum_{w \\in C} D^{n - |w|}$.\n\\end{proof}\n\nThe proof constructs the code greedily, adding codewords one at a time\nfrom longest to shortest. The key ingredient is the following counting\nlemma, which guarantees that a free codeword always exists.\n\n\\begin{lemma}[Existence of a free string]\n \\label{lem:free-string}\n \\lean{Kraft.exists_free_string}\n \\uses{def:Kraft_Code, def:Prefix_Free_Code}\n \\leanok\n Let $C$ be a prefix-free code with all codeword lengths at most $n$. If\n \\[\n \\sum_{w \\in C} D^{-|w|} + D^{-n} \\leq 1,\n \\]\n then there exists a string of length $n$ that is not blocked by $C$\n (i.e., no codeword in $C$ is a prefix of it and it is not a prefix\n of any codeword in $C$).\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:count-blocked}\n \\leanok\n By Lemma~\\ref{lem:count-blocked}, the number of strings of length $n$ that\n have some codeword as a prefix is $\\sum_{w \\in C} D^{n - |w|}$.\n Multiplying the Kraft inequality by $D^n$ gives\n \\[\n \\sum_{w \\in C} D^{n - |w|} + 1 \\leq D^n,\n \\]\n so $\\sum_{w \\in C} D^{n - |w|} < D^n$. Since there are $D^n$ strings\n of length $n$ in total, at least one string $v$ of length $n$ has no\n codeword as a prefix.\n\n It remains to check that $v$ is not a prefix of any codeword $c \\in C$.\n Since $|v| = n \\geq |c|$, the relation $v$ is a prefix of $c$ forces\n $|v| \\leq |c|$, hence $|v| = |c|$, and so $v = c$. But then $c$ is\n a prefix of $v$, which contradicts the fact that no codeword is a prefix\n of $v$.\n\\end{proof}\n\n\\begin{lemma}[Preserving prefix-freeness]\n \\label{lem:insert-prefix-free}\n \\lean{Kraft.prefixFree_insert}\n \\uses{def:Kraft_Code, def:Prefix_Free_Code}\n \\leanok\n Let $C$ be a prefix-free code and let $w$ be a string not blocked by $C$\n and not already in $C$. Then $C \\cup \\{w\\}$ is prefix-free.\n\\end{lemma}\n\n\\begin{proof}\n \\leanok\n Let $w_1, w_2 \\in C \\cup \\{w\\}$ with $w_1$ a prefix of $w_2$.\n If both belong to $C$, prefix-freeness of $C$ gives $w_1 = w_2$.\n If $w_1 = w$ and $w_2 \\in C$, then $w$ is a prefix of $w_2$, so $w$\n is blocked by $C$, a contradiction.\n If $w_1 \\in C$ and $w_2 = w$, then $w_1$ is a prefix of $w$, so\n again $w$ is blocked, a contradiction.\n\\end{proof}\n\n\\begin{theorem}[Kraft]\n \\label{thm:kraft}\n \\lean{Kraft.kraft}\n \\uses{def:Kraft_Code, def:Prefix_Free_Code, def:Kraft_Sum_List}\n \\leanok\n Let $\\sigma$ be a finite nonempty alphabet of size $D = |\\sigma|$,\n and let $l_1, \\ldots, l_m$ be natural numbers satisfying\n \\[\n \\sum_{i=1}^{m} D^{-l_i} \\leq 1.\n \\]\n Then there exists a prefix-free code $C$ over $\\sigma$ whose codeword\n lengths are exactly $l_1, \\ldots, l_m$ (as a multiset).\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:free-string, lem:insert-prefix-free}\n \\leanok\n Sort the lengths in nonincreasing order: $l_1 \\geq l_2 \\geq \\cdots \\geq l_m$.\n This is a permutation of the original list, so the Kraft sum and the\n multiset of lengths are unchanged.\n\n We build the code by induction on $m$. If $m = 0$, the empty code works.\n For the inductive step, suppose that we have lengths $l_1 \\geq l_2 \\geq \\cdots\n \\geq l_m$ with $\\sum D^{-l_i} \\leq 1$.\n\n \\medskip\\noindent\\textbf{Inductive hypothesis.}\n By the inductive hypothesis applied to $l_2, \\ldots, l_m$ (whose Kraft\n sum is at most 1 since we dropped a nonneg\\-ative term), there exists a\n prefix-free code $C'$ with codeword lengths $l_2, \\ldots, l_m$.\n\n \\medskip\\noindent\\textbf{All existing codewords are shorter.}\n Since $l_1 \\geq l_i$ for all $i \\geq 2$ (by sorting), every codeword\n in $C'$ has length at most $l_1$.\n\n \\medskip\\noindent\\textbf{A free string exists.}\n The Kraft sum of $C'$ plus $D^{-l_1}$ equals $\\sum_{i=1}^{m} D^{-l_i}\n \\leq 1$. By Lemma~\\ref{lem:free-string}, there exists a string $w$ of\n length $l_1$ that is not blocked by $C'$.\n\n \\medskip\\noindent\\textbf{Insert and conclude.}\n By Lemma~\\ref{lem:insert-prefix-free}, $C = C' \\cup \\{w\\}$ is\n prefix-free, and its codeword lengths are $l_1, l_2, \\ldots, l_m$.\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem kraft (ls : List ℕ) (hkraft : kraftSum σ ls ≤ 1) :\n ∃ C : Code σ, PrefixFree C ∧\n C.val.map List.length = (ls : Multiset ℕ) := by sorry"} -{"project_name": "KroneckerWeberTheorem", "name": "KroneckerWeber", "type": "theorem", "title": "Kronecker–Weber theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Kronecker–Weber theorem}\n\nThis section contains a (stub of a) proof of the Kronecker–Weber theorem.\nSee \\url{https://en.wikipedia.org/wiki/Kronecker–Weber_theorem} for more details.\n\nTODO: Expand this stubbed file by adding an informal proof.\n\n% TODO: add blueprint\n\n\\begin{theorem}[Kronecker–Weber theorem]\n \\label{thm:kronecker-weber-theorem}\n \\lean{KroneckerWeber}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem KroneckerWeber (F : Type*) [Field F] [NumberField F] [IsAbelianGalois ℚ F] :\n ∃ n, ∃ (K : Type*) (_ : Field K) (_ : Algebra ℚ K) (_ : Algebra F K) (_ : IsScalarTower ℚ F K),\n IsCyclotomicExtension {n} ℚ K := sorry"} -{"project_name": "KrullSeparationLemma", "name": "krull_separation", "type": "theorem", "title": "Krull's separation lemma", "informal_statement": "TODO", "informal_proof": "\\chapter{Krull's separation lemma}\n\nThis section contains a (stub of a) proof of Krull's separation lemma.\nSee \\url{https://en.wikipedia.org/wiki/Krull%27s_separation_lemma} for more details.\n\nTODO: Expand this stubbed file by adding an informal proof.\n\n% TODO: add blueprint\n\n\\begin{theorem}[Krull's separation lemma]\n \\label{thm:krull-separation-lemma}\n \\lean{krull_separation}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Ideal\n\n\ntheorem krull_separation {R : Type u} [Ring R] {M : Submonoid R} {I : Ideal R}\n (h : M.carrier ∩ I.carrier = ∅) :\n ∃ P : Ideal R, IsPrime P ∧ M.carrier ∩ P.carrier = ∅ ∧ I ≤ P := sorry"} -{"project_name": "LagrangeTheorem", "name": "lagrange", "type": "theorem", "title": "Lagrange's theorem (number theory)", "informal_statement": "TODO", "informal_proof": "\\chapter{Lagrange's theorem (number theory)}\n\nThis section contains a (stub of a) proof of Lagrange's theorem (number theory).\nSee \\url{https://en.wikipedia.org/wiki/Lagrange's_theorem_(number_theory)} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Lagrange's theorem (number theory)]\n \\label{thm:lagrange-theorem}\n \\lean{lagrange}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Polynomial Nat\n\n\ntheorem lagrange {p : ℕ} (hp : p.Prime) {f : Polynomial ℤ} (h : ∃ n : ℕ, ¬ (↑p : ℤ) ∣ f.coeff n):\n {n : ℕ | n ≤ p ∧ ↑p ∣ eval (↑n : ℤ) f}.ncard ≤ f.natDegree := sorry"} -{"project_name": "LeCamTheorem", "name": "LeCamTheorem", "type": "theorem", "title": "Le Cam's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Le Cam's theorem}\n\nThis section contains a (stub of a) proof of Le Cam's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Le_Cam's_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Le Cam's theorem]\n \\label{thm:le-cam-theorem}\n \\lean{LeCamTheorem}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem LeCamTheorem (ps : List unitInterval) (hps : ∀ p ∈ ps, 0 ≤ p ∧ p ≤ 1) :\n let mean := (ps.map (fun p => p.val)).sum\n let sum := independentSum (ps.map (fun k => PMF.bernoulliNat_of_unitInterval (k) ) )\n ∑ k ∈ Finset.range (ps.length+1),\n |(sum k).toReal - (Real.exp (-mean) * mean ^ k / k.factorial)| ≤ 2 * (ps.map (fun p => p.val ^ 2)).sum := sorry"} -{"project_name": "LeastCommonMultipleLowerBound", "name": "Nat.LCM_lower_bound", "type": "theorem", "title": "LCM Lower Bound", "informal_statement": "\\leanok\n For any natural number $n \\ge 7$, we have $2^n \\le \\text{LCM}(n)$.", "informal_proof": "\\chapter{The LCM Lower Bound Theorem}\n\nThis section contains a proof of the theorem that for sufficiently large $n$, the LCM of the first $n$ positive integers is greater than $2^n$. This proof is based on the Beta integral and properties of binomial coefficients. It is based on a proof from M. Nair, \"On Chebyshev-type inequalities for primes\", Amer. Math. Monthly 89 (1982).\nSee \\url{https://academicweb.nd.edu/~andyp/notes/AKS.pdf} for more details.\n\n\\begin{lemma}[Beta Integral as Sum]\n \\label{lem:betaIntegral_eq_sum}\n \\lean{Complex.betaIntegral_eq_sum}\n \\leanok\n The beta integral can be expressed as a sum involving binomial coefficients and reciprocals:\n \\[ B(m, j+1) = \\int_0^1 x^{m-1}(1-x)^j dx = \\sum_{k=0}^{j} (-1)^k \\binom{j}{k} \\frac{1}{m+k} \\]\n\\end{lemma}\n\n\\begin{proof}\nThe proof expands $(1-x)^j$ using the binomial theorem and integrates term-by-term:\n\\[ B(m, j+1) = \\int_0^1 x^{m-1}(1-x)^j dx = \\int_0^1 \\sum_{k=0}^{j} (-1)^k \\binom{j}{k} \\frac{1}{m+k} \\]\nEach integral $\\int_0^1 x^{m+k-1} dx = \\frac{1}{m+k}$ is evaluated by taking the antiderivative as a polynomial.\n\\end{proof}\n\n\\begin{lemma}[Binomial Coefficient Divisibility]\n \\label{lem:mul_choose_dvd_LCM}\n \\lean{mul_choose_dvd_LCM}\n \\leanok\n For natural numbers $m, j$ with $m > 0$, we have:\n \\[ m \\binom{m+j}{m} \\mid \\text{LCM}(m+j) \\]\n Where $\\text{LCM}(m+j)$ is the least common multiple of the integers from $1$ to $m+j$.\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:betaIntegral_eq_sum}\nThe proof relates the Beta integral to two different expressions using Lemma~\\ref{lem:betaIntegral_eq_sum}.\nFirst, using the Gamma function:\n\\[ B(m, j+1) = \\frac{1}{m \\binom{m+j}{m}} \\]\nSecond, from Lemma~\\ref{lem:betaIntegral_eq_sum}:\n\\[ B(m, j+1) = \\sum_{k=0}^{j} (-1)^k \\binom{j}{k} \\frac{1}{m+k} \\]\nEquating these expressions and multiplying by $\\text{LCM}(m+j)$ shows that the left-hand side is an integer,\nsince each term on the right is an integer (as $m+k \\le m+j$ implies $m+k \\mid \\text{LCM}(m+j)$).\n\\end{proof}\n\n\\begin{lemma}[Odd LCM Lower Bound]\n \\label{lem:bound_odd_LCM}\n \\lean{bound_odd_LCM}\n \\leanok\n For any natural number $n \\ge 4$:\n \\[ (2n+1) 4^n \\le \\text{LCM}(2n+1) \\]\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:mul_choose_dvd_LCM}\nFrom Lemma~\\ref{lem:mul_choose_dvd_LCM}, we obtain two divisibility relations:\n\\begin{enumerate}\n \\item $n \\binom{2n}{n} \\mid \\text{LCM}(2n)$, which implies $n \\binom{2n}{n} \\mid \\text{LCM}(2n+1)$\n \\item $(2n+1) \\binom{2n}{n} \\mid \\text{LCM}(2n+1)$ (using the binomial identity)\n\\end{enumerate}\nSince $n$ and $2n+1$ are coprime, we have $n(2n+1)\\binom{2n}{n} \\mid \\text{LCM}(2n+1)$.\nThe result follows from the inequality $4^n < n\\binom{2n}{n}$ for $n \\ge 1$.\n\\end{proof}\n\n\\begin{lemma}[LCM Lower Bound for Large Numbers]\n \\label{lem:LCM_lower_bound_9_le}\n \\lean{LCM_lower_bound_9_le}\n \\leanok\n For any natural number $n \\ge 9$, we have $2^n \\le \\text{LCM}(n)$.\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:bound_odd_LCM}\nFor $n \\ge 9$, we write $n$ as either $2k+1$ or $2k+2$ for some $k \\ge 4$.\nIn both cases, we use Lemma~\\ref{lem:bound_odd_LCM} and the monotonicity of LCM\nto show that $\\text{LCM}(n) \\ge (2k+1)4^k \\ge 2^n$.\n\\end{proof}\n\n\\begin{theorem}[LCM Lower Bound]\n \\label{thm:LCM_lower_bound}\n \\lean{Nat.LCM_lower_bound}\n \\leanok\n For any natural number $n \\ge 7$, we have $2^n \\le \\text{LCM}(n)$.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:LCM_lower_bound_9_le}\n For $n \\ge 9$, we apply Lemma~\\ref{lem:LCM_lower_bound_9_le}.\n For $n = 7$ and $n = 8$, the inequality is verified by direct computation:\n $\\text{LCM}(7) = 420 > 128 = 2^7$ and $\\text{LCM}(8) = 840 > 256 = 2^8$.\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem Nat.LCM_lower_bound (n : ℕ) (hn : 7 ≤ n) : 2 ^ n ≤ LCM n := sorry"} -{"project_name": "LevitzkyTheorem", "name": "levitzky_theorem", "type": "theorem", "title": "Levitzky's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Levitzky's theorem}\n\nThis section contains a (stub of a) proof of Levitzky's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Levitzky's_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Levitzky's theorem]\n \\label{thm:levitzky-theorem}\n \\lean{levitzky_theorem}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem levitzky_theorem {R : Type*} [Ring R]\n [IsNoetherianRing (MulOpposite R)]\n (I : Ideal R) (hnil : I.IsNil) :\n IsNilpotent I := by sorry"} -{"project_name": "LinnikTheorem", "name": "linnik", "type": "theorem", "title": "Linnik's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Linnik's theorem}\n\nThis section contains a (stub of a) proof of Linnik's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Linnik's_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Linnik's theorem]\n \\label{thm:linnik-theorem}\n \\lean{linnik}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem linnik : ∃ c L : ℝ, ∀ ⦃a b : ℕ⦄, a.Coprime b → d a b ≤ c * (↑b : ℝ) ^ L := by sorry"} -{"project_name": "LukacsProportionSumIndependenceTheorem", "name": "lukacs_proportion_sum_independence_iff", "type": "theorem", "title": "Lukacs's proportion-sum independence theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Lukacs's proportion-sum independence theorem}\n\nThis section contains a (stub of a) proof of Lukacs's proportion-sum independence theorem.\nSee \\url{https://en.wikipedia.org/wiki/Lukacs's_proportion-sum_independence_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Lukacs's proportion-sum independence theorem]\n \\label{thm:lukacs-proportion-sum-independence-theorem}\n \\lean{lukacs_proportion_sum_independence_iff}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen MeasureTheory ProbabilityTheory\n\n\ntheorem lukacs_proportion_sum_independence_iff\n {Omega : Type*} [MeasurableSpace Omega]\n {P : Measure Omega} [IsProbabilityMeasure P]\n {X Y : Omega → ℝ}\n (hXm : Measurable X) (hYm : Measurable Y)\n (hXY : IndepFun X Y P)\n (hXpos : ∀ᵐ ω ∂P, 0 < X ω)\n (hYpos : ∀ᵐ ω ∂P, 0 < Y ω)\n (hXnd : ¬∃ c, ∀ᵐ ω ∂P, X ω = c)\n (hYnd : ¬∃ c, ∀ᵐ ω ∂P, Y ω = c) :\n IndepFun (fun ω => X ω / (X ω + Y ω)) (fun ω => X ω + Y ω) P ↔\n ∃ alpha gamma r : ℝ,\n 0 < alpha ∧ 0 < gamma ∧ 0 < r ∧\n HasLaw X (gammaMeasure alpha r) P ∧\n HasLaw Y (gammaMeasure gamma r) P := by sorry"} -{"project_name": "LusinTheorem", "name": "lusin", "type": "theorem", "title": "Lusin's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Lusin's theorem}\n\nThis section contains a (stub of a) proof of Lusin's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Lusin%27s_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Lusin's theorem]\n \\label{thm:lusin-theorem}\n \\lean{lusin}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set Function MeasureTheory\n\n\ntheorem lusin {a b ε : ℝ} (ab : a < b) {f : ℝ → ℂ} (f_meas : Measurable f) (εp : 0 < ε) :\n ∃ E ⊆ Icc a b, IsCompact E ∧ Continuous (restrict E f) ∧ b - a - ε < (volume E).toReal := by sorry"} -{"project_name": "McMillan", "name": "mcmillan", "type": "theorem", "title": "McMillan", "informal_statement": "\\leanok\n Every uniquely decodable code $C$ satisfies the Kraft inequality:\n \\[\n K(C) \\leq 1.\n \\]", "informal_proof": "\\chapter{McMillan's Theorem}\n\nThis section contains a proof of McMillan's Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Kraft%E2%80%93McMillan_inequality} for more details.\n\nLet $\\sigma$ be a finite nonempty set, which we call the \\emph{alphabet}.\nWe write $D = |\\sigma|$ for the size of the alphabet.\n\n\\begin{definition}[Code]\n \\label{def:Code}\n \\lean{Code}\n \\leanok\n A \\emph{code} $C$ over the alphabet $\\sigma$ is a finite set of finite strings\n over $\\sigma$. The elements of $C$ are called \\emph{codewords}.\n\\end{definition}\n\n\\begin{definition}[Unique decodability]\n \\label{def:Unique_Decodability}\n \\lean{UniquelyDecodable}\n \\uses{def:Code}\n \\leanok\n A code $C$ is \\emph{uniquely decodable} if whenever two sequences of\n codewords $w_1 \\cdots w_m = w_1' \\cdots w_{m'}'$ produce the same\n concatenated string, the sequences are identical (in particular, $m = m'$\n and $w_i = w_i'$ for all $i$).\n\\end{definition}\n\n\\begin{definition}[Kraft sum]\n \\label{def:Kraft_Sum}\n \\lean{kraftSum}\n \\uses{def:Code}\n \\leanok\n The \\emph{Kraft sum} of a code $C$ over an alphabet of size $D$ is\n \\[\n K(C) = \\sum_{w \\in C} D^{-|w|},\n \\]\n where $|w|$ denotes the length of the codeword $w$.\n\\end{definition}\n\n\\begin{lemma}[Tuple counting bound]\n \\label{lem:count-tuples}\n \\lean{count_tuples_le}\n \\uses{def:Code, def:Unique_Decodability}\n \\leanok\n Let $C$ be a uniquely decodable code and let $n, k$ be natural numbers.\n The number of $n$-tuples $(w_1, \\ldots, w_n) \\in C^n$ whose total length\n $|w_1| + \\cdots + |w_n|$ equals $k$ is at most $D^k$.\n\\end{lemma}\n\n\\begin{proof}\n \\leanok\n Since $C$ is uniquely decodable, concatenation is injective on $n$-tuples:\n distinct $n$-tuples produce distinct strings.\n If the total length equals $k$, then the concatenation is a string\n of length $k$ over $\\sigma$, and there are exactly $D^k$ such strings.\n Since distinct tuples map to distinct strings, the number of tuples is\n at most $D^k$.\n\\end{proof}\n\n\\begin{lemma}[Kraft sum power bound]\n \\label{lem:kraft-pow}\n \\lean{kraftSum_pow_le}\n \\uses{def:Code, def:Unique_Decodability, def:Kraft_Sum}\n \\leanok\n Let $C$ be a uniquely decodable code with a maximum codeword length\n $L = \\max_{w \\in C} |w|$.\n For all $n \\geq 1$,\n \\[\n K(C)^n \\leq nL + 1.\n \\]\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:count-tuples}\n \\leanok\n Write $K = K(C)$.\n Expanding the $n$-th power using the multinomial expansion gives\n \\[\n K^n\n = \\biggl(\\sum_{w \\in C} D^{-|w|}\\biggr)^{\\!n}\n = \\sum_{t \\in C^n} \\prod_{i=1}^{n} D^{-|t_i|}\n = \\sum_{t \\in C^n} D^{-\\ell(t)},\n \\]\n where $\\ell(t) = |t_1| + \\cdots + |t_n|$ is the total length of the\n $n$-tuple $t = (t_1, \\ldots, t_n)$.\n\n Since each codeword has length at most $L$, the total length satisfies\n $0 \\leq \\ell(t) \\leq nL$.\n Grouping tuples by their total length, we obtain\n \\[\n K^n = \\sum_{k=0}^{nL} A(n,k) \\cdot D^{-k},\n \\]\n where $A(n,k) = |\\{t \\in C^n : \\ell(t) = k\\}|$.\n\n By Lemma~\\ref{lem:count-tuples}, $A(n,k) \\leq D^k$, so each summand satisfies\n \\[\n A(n,k) \\cdot D^{-k} \\leq D^k \\cdot D^{-k} = 1.\n \\]\n Since $k$ ranges over $\\{0, 1, \\ldots, nL\\}$, there are $nL + 1$ summands, giving\n \\[\n K^n \\leq \\sum_{k=0}^{nL} 1 = nL + 1.\n \\]\n\\end{proof}\n\nWe also need the following classical inequality.\n\n\\begin{lemma}[Bernoulli's inequality]\n \\label{lem:bernoulli}\n \\lean{bernoulli_ineq}\n \\leanok\n For all $a \\geq 0$ and $n \\in \\mathbb{N}$,\n \\[\n (1 + a)^n \\geq 1 + na.\n \\]\n\\end{lemma}\n\n\\begin{proof}\n \\leanok\n By induction on $n$. The base case $n = 0$ is immediate.\n For the inductive step, assume that $(1+a)^n \\geq 1 + na$. Then\n \\[\n (1+a)^{n+1}\n = (1+a)^n \\cdot (1+a)\n \\geq (1 + na)(1 + a)\n = 1 + (n+1)a + na^2\n \\geq 1 + (n+1)a.\n \\]\n\\end{proof}\n\n\\begin{theorem}[McMillan]\n \\label{thm:mcmillan}\n \\lean{mcmillan}\n \\uses{def:Code, def:Unique_Decodability, def:Kraft_Sum}\n \\leanok\n Every uniquely decodable code $C$ satisfies the Kraft inequality:\n \\[\n K(C) \\leq 1.\n \\]\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:kraft-pow, lem:bernoulli}\n \\leanok\n Suppose for contradiction that $K = K(C) > 1$.\n Set $a = K - 1 > 0$ and $L = \\max_{w \\in C} |w|$.\n\n \\medskip\\noindent\\textbf{Upper bound.}\n By Lemma~\\ref{lem:kraft-pow}, for every $n \\geq 1$,\n \\[\n K^n \\leq nL + 1.\n \\]\n\n \\medskip\\noindent\\textbf{Lower bound.}\n Since $K = 1 + a$, Bernoulli's inequality (Lemma~\\ref{lem:bernoulli}) gives\n $K^N \\geq 1 + Na$ for every $N \\in \\mathbb{N}$.\n Squaring, we obtain\n \\[\n K^{2N} = (K^N)^2 \\geq (1 + Na)^2 = 1 + 2Na + N^2 a^2 \\geq 1 + N^2 a^2.\n \\]\n\n \\medskip\\noindent\\textbf{Contradiction.}\n Combining the upper and lower bounds for $n = 2N$:\n \\[\n 1 + N^2 a^2 \\leq K^{2N} \\leq 2NL + 1,\n \\]\n which gives $N^2 a^2 \\leq 2NL$, and hence $Na^2 \\leq 2L$ for every $N \\geq 1$.\n\n Since $a > 0$, we have $a^2 > 0$.\n By the Archimedean property, there exists $N \\in \\mathbb{N}$ with\n $Na^2 > 2L$, contradicting $Na^2 \\leq 2L$.\n Therefore $K \\leq 1$.\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem mcmillan (C : Code σ) (hC : UniquelyDecodable C) :\n kraftSum C ≤ 1 := by sorry"} -{"project_name": "MergelyanTheorem", "name": "mergelyan", "type": "theorem", "title": "Mergelyan's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Mergelyan's theorem}\n\nThis section contains a (stub of a) proof of Mergelyan's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Mergelyan's_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Mergelyan's theorem]\n \\label{thm:mergelyan-theorem}\n \\lean{mergelyan}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem mergelyan {K : Set ℂ} (K_compact : IsCompact K) (K_conn : IsConnected Kᶜ)\n {f : ℂ → ℂ} (f_cont : ContinuousOn f K) (f_diff : DifferentiableOn ℂ f (interior K)) :\n ∀ ε > 0, ∃ p : Polynomial ℂ, ∀ x ∈ K, ‖f x - p.eval x‖ₑ < ε := by sorry"} -{"project_name": "MertensFirstTheorem", "name": "merten_first", "type": "theorem", "title": "Mertens' First Theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Mertens' First Theorem}\n\nThis section contains a (stub of a) proof of Mertens' first theorem.\nSee \\url{https://en.wikipedia.org/wiki/Mertens%27_theorems} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Mertens' First Theorem]\n \\label{thm:mertens-first-theorem}\n \\lean{merten_first}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat Set\n\n\ntheorem merten_first {n : ℕ} (hn : 2 ≤ n) :\n - Real.log n + ∑' k : PrimesLe n, Real.log k / k ≤ 2 := by sorry"} -{"project_name": "MittagLeffler", "name": "IsMittagLeffler.mapShortExact", "type": "theorem", "title": "Mittag-Leffler", "informal_statement": "\\leanok\nLet\n\\[ 0 \\to A_ i \\xrightarrow {f_ i} B_ i \\xrightarrow {g_ i} C_ i \\to 0 \\]\nbe an exact sequence of directed inverse systems of abelian groups over $I$. Suppose $I$ is countable. If $(A_ i)$ is Mittag-Leffler, then\n\\[ 0 \\to \\mathop{\\mathrm{lim}}\\nolimits A_ i \\to \\mathop{\\mathrm{lim}}\\nolimits B_ i \\to \\mathop{\\mathrm{lim}}\\nolimits C_ i\\to 0 \\]\nis exact.", "informal_proof": "\\chapter{Mittag-Leffler}\n\nThis section contains a proof of the Mittag-Leffler condition for inverse systems.\nSee \\url{https://stacks.math.columbia.edu/tag/0594} for more details.\n\n\\begin{lemma}\n\\label{lemma-ML-limit-nonempty}\n\\lean{nonempty_limit_of_nonempty_obj_of_MiLe}\n\\leanok\nLet $(A_ i, \\varphi _{ji})$ be a directed inverse system over $I$. Suppose $I$ is countable. If $(A_ i, \\varphi _{ji})$ is Mittag-Leffler and the $A_ i$ are nonempty, then $\\mathop{\\mathrm{lim}}\\nolimits A_ i$ is nonempty.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\nLet $i_1, i_2, i_3, \\ldots $ be an enumeration of the elements of $I$. Define inductively a sequence of elements $j_ n \\in I$ for $n = 1, 2, 3, \\ldots $ by the conditions: $j_1 = i_1$, and $j_ n \\geq i_ n$ and $j_ n \\geq j_ m$ for $m < n$. Then the sequence $j_ n$ is increasing and forms a cofinal subset of $I$. Hence we may assume $I =\\{ 1, 2, 3, \\ldots \\} $.\nSo by Example 10.86.2 we are reduced to showing that the limit of an inverse system of nonempty sets with surjective maps indexed by the positive integers is nonempty. This follows from the axiom of choice. $\\square$\n\\end{proof}\n\n\\begin{theorem}\n\\label{lemma-ML-exact-sequence}\n\\lean{IsMittagLeffler.mapShortExact}\n\\leanok\nLet\n\\[ 0 \\to A_ i \\xrightarrow {f_ i} B_ i \\xrightarrow {g_ i} C_ i \\to 0 \\]\nbe an exact sequence of directed inverse systems of abelian groups over $I$. Suppose $I$ is countable. If $(A_ i)$ is Mittag-Leffler, then\n\\[ 0 \\to \\mathop{\\mathrm{lim}}\\nolimits A_ i \\to \\mathop{\\mathrm{lim}}\\nolimits B_ i \\to \\mathop{\\mathrm{lim}}\\nolimits C_ i\\to 0 \\]\nis exact.\n\\end{theorem}\n\n\\begin{proof}\n\\leanok\n\\uses{lemma-ML-limit-nonempty}\nTaking limits of directed inverse systems is left exact, hence we only need to prove surjectivity of $\\mathop{\\mathrm{lim}}\\nolimits B_ i \\to \\mathop{\\mathrm{lim}}\\nolimits C_ i$. So let $(c_ i) \\in \\mathop{\\mathrm{lim}}\\nolimits C_ i$. For each $i \\in I$, let $E_ i = g_ i^{-1}(c_ i)$, which is nonempty since $g_ i: B_ i \\to C_ i$ is surjective. The system of maps $\\varphi _{ji}: B_ j \\to B_ i$ for $(B_ i)$ restrict to maps $E_ j \\to E_ i$ which make $(E_ i)$ into an inverse system of nonempty sets.\nIt is enough to show that $(E_ i)$ is Mittag-Leffler. For then Lemma 10.86.3 would show $\\mathop{\\mathrm{lim}}\\nolimits E_ i$ is nonempty, and taking any element of $\\mathop{\\mathrm{lim}}\\nolimits E_ i$ would give an element of $\\mathop{\\mathrm{lim}}\\nolimits B_ i$ mapping to $(c_ i)$.\nBy the injection $f_ i: A_ i \\to B_ i$ we will regard $A_ i$ as a subset of $B_ i$. Since $(A_ i)$ is Mittag-Leffler, if $i \\in I$ then there exists $j \\geq i$ such that $\\varphi _{ki}(A_ k) = \\varphi _{ji}(A_ j)$ for $k \\geq j$. We claim that also $\\varphi _{ki}(E_ k) = \\varphi _{ji}(E_ j)$ for $k \\geq j$. Always $\\varphi _{ki}(E_ k) \\subset \\varphi _{ji}(E_ j)$ for $k \\geq j$.\nFor the reverse inclusion let $e_ j \\in E_ j$, and we need to find $x_ k \\in E_ k$ such that $\\varphi _{ki}(x_ k) = \\varphi _{ji}(e_ j)$. Let $e'_ k \\in E_ k$ be any element, and set $e'_ j = \\varphi _{kj}(e'_ k)$. Then $g_ j(e_ j - e'_ j) = c_ j - c_ j = 0$, hence $e_ j - e'_ j = a_ j \\in A_ j$. Since $\\varphi _{ki}(A_ k) = \\varphi _{ji}(A_ j)$, there exists $a_ k \\in A_ k$ such that $\\varphi _{ki}(a_ k) = \\varphi _{ji}(a_ j)$. Hence\n\\[ \\varphi _{ki}(e'_ k + a_ k) = \\varphi _{ji}(e'_ j) + \\varphi _{ji}(a_ j) = \\varphi _{ji}(e_ j), \\]\nso we can take $x_ k = e'_ k + a_ k$. $\\square$\n\\end{proof}\n", "code": "import Mathlib\n\n\nset_option backward.isDefEq.respectTransparency false in\n\n\nopen CategoryTheory Limits Functor\n\nopen ShortComplex Opposite in\n\n\ntheorem IsMittagLeffler.mapShortExact (S : ShortComplex (Iᵒᵖ ⥤ Ab)) (hS : S.ShortExact)\n (hA : (S.X₁ ⋙ forget Ab).IsMittagLeffler) : (S.map lim).ShortExact := by sorry"} -{"project_name": "MycielskiTheorem", "name": "mycielski", "type": "theorem", "title": "Mycielski's theorem", "informal_statement": "For any $n$, there exists a triangle-free graph with chromatic number at least $n$.", "informal_proof": "\\chapter{Mycielski's theorem}\n\nThis section contains a proof of the theorem, due to Tutte, Zykov, and Mycielski, that there exist triangle-free graphs with arbitrarily large chromatic number.\nSee \\url{https://en.wikipedia.org/wiki/Graph_coloring#Graphs_with_high_chromatic_number} for more details.\n\n\n\\begin{definition}\n \\label{def:mycielskian}\n \\lean{SimpleGraph.mycielskian}\n Given a graph $G$, the \\textit{Mycielskian} of $G$ is the graph $\\mu(G)$ defined as follows:\n The vertex set consists of\n \\begin{itemize}\n \\item A vertex $v_i$ for each vertex $v_i$ of $G$,\n \\item A vertex $u_i$ for each vertex $v_i$ of $G$, and\n \\item A vertex $w$.\n \\end{itemize}\n The edge set consists of\n \\begin{itemize}\n \\item An edge $v_i v_j$ for each edge $v_i v_j$ of $G$,\n \\item An edge $v_i u_j$ for each edge $v_i v_j$ of $G$,\n \\item An edge $u_i w$ for each vertex $v_i$ of $G$.\n \\end{itemize}\n\\end{definition}\n\n\\begin{lemma}\n \\label{lem:mycielskian-triangle-free}\n \\lean{SimpleGraph.mycielskian_cliqueFree}\n \\uses{def:mycielskian}\n If $G$ is a triangle-free graph, then $\\mu(G)$ is also triangle-free.\n\\end{lemma}\n\n\\begin{proof}\n Suppose for the sake of contradiction that $\\mu(G)$ contains a triangle.\n Since $w$ is only adjacent to the vertices $u_i$, it cannot be part of the triangle.\n Therefore, the triangle must consist of vertices from the sets $\\{v_i\\}$ and $\\{u_i\\}$.\n If the tirangle consists of three vertices from the set $\\{v_i\\}$, then it corresponds to a triangle in $G$, which is a contradiction.\n If the triangle consists of two vertices $\\{v_i, v_j\\}$ and one vertex from the set $\\{u_k\\}$, then since the edges between the vertices $v_i$ and $u_j$ correspond to edges in $G$, this also corresponds to a triangle $v_i v_j v_k$ in $G$, which is a contradiction.\n The triangle cannot consist of two or more vertices from the set $\\{u_i\\}$, since there are no edges between vertices in the set $\\{u_i\\}$.\n Thus, $\\mu(G)$ is triangle-free.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:mycielskian-chromatic-number}\n \\lean{SimpleGraph.mycielskian_colorable_pred}\n \\uses{def:mycielskian}\n If $G$ is a triangle-free graph with chromatic number $n$, then $\\mu(G)$ has chromatic number at least $n+1$.\n\\end{lemma}\n\n\\begin{proof}\n Suppose for the sake of contradiction that $\\mu(G)$ can be colored with $n$ colors by a coloring $c$.\n Without loss of generality, we can assume that $w$ is colored with color $n$.\n Therefore the vertices $u_i$ must be colored with colors from the set $\\{1, 2, \\ldots, n-1\\}$.\n We now define a coloring $c'$ of $G$ with $n-1$ colors as follows:\n \\begin{itemize}\n \\item For each vertex $v_i$ of $G$, if coloring of $c(v_i)$ in $\\mu(G)$ is not $k$, then we color $c'(v_i) = c(v_i)$ in $G$ with this color.\n \\item If the coloring $c(v_i)$ in $\\mu(G)$ is $k$, then we color $c'(v_i)$ equal to $v(u_i)$ in $\\mu(G)$.\n \\end{itemize}\n This is then a coloring of $G$ with $n-1$ colors, since $k$ is not used.\n Moreover, it is a proper coloring, since if $v_i$ and $v_j$ are adjacent in $G$,\n \\begin{itemize}\n \\item If the colorings $c(v_i)$ and $c(v_j)$ in $\\mu(G)$ are both not $k$, then $c(v_i) = c'(v_i) \\neq c'(v_j) = c(v_j)$, since $v_i, v_j$ are adjacent in $\\mu(G)$.\n \\item If (WLOG) the coloring $c(v_i)$ in $\\mu(G)$ is $k$ and the coloring $c(v_j)$ in $\\mu(G)$ is not $k$,\n then $c'(v_i) = c(u_i) \\neq c(v_j) = c'(v_j)$, since $u_i, v_j$ are adjacent in $\\mu(G)$.\n \\item If the colorings $c(v_i)$ and $c(v_j)$ in $\\mu(G)$ are both $k$, then we contradict the fact that $v_i$ and $v_j$ are adjacent and thus cannot be colored with the same color $k$.\n \\end{itemize}\n Thus we have a proper coloring of $G$ with $n-1$ colors, which contradicts the fact that $G$ has chromatic number $n$.\n\n\\end{proof}\n\n\\begin{theorem}[Mycielski's theorem]\n \\label{thm:mycielski}\n \\lean{SimpleGraph.mycielski}\n \\uses{lem:mycielskian-triangle-free, lem:mycielskian-chromatic-number}\n For any $n$, there exists a triangle-free graph with chromatic number at least $n$.\n\\end{theorem}\n\n\\begin{proof}\n By induction on $n$.\n For $n=0$, we can take an empty graph, which is triangle-free and has chromatic number $0$.\n Given a triangle-free graph $G$ with chromatic number at least $n$, we can take $\\mu(G)$, which is triangle-free and has chromatic number at least $n+1$.\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem mycielski (n : ℕ) :\n ∃ (W : Type) (H : SimpleGraph W), H.CliqueFree 3 ∧ (n : ℕ∞) ≤ H.chromaticNumber := by sorry"} -{"project_name": "NagellLutzTheorem", "name": "NagellLutz1", "type": "theorem", "title": "", "informal_statement": "", "informal_proof": "", "code": "import Mathlib\n\n\ntheorem NagellLutz1 {E : WeierstrassCurve.Affine ℚ}\n (h1 : E.IsIntegral ℤ) (h2 : E.Δ ≠ 0) {x y : ℚ} (h : E.Nonsingular x y)\n (hx : 0 < addOrderOf (WeierstrassCurve.Affine.Point.some x y h)) :\n x ∈ (algebraMap ℤ ℚ).range ∧ y ∈ (algebraMap ℤ ℚ).range := sorry"} -{"project_name": "NagellLutzTheorem", "name": "NagellLutz2", "type": "theorem", "title": "Nagell–Lutz theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Nagell–Lutz theorem}\n\nThis section contains a (stub of a) proof of the Nagell–Lutz theorem.\nSee \\url{https://en.wikipedia.org/wiki/Nagell–Lutz_theorem} for more details.\n\nTODO: Expand this stubbed file by adding an informal proof.\n\n% TODO: add blueprint\n\n\\begin{theorem}[Nagell–Lutz theorem]\n \\label{thm:nagell-lutz-theorem}\n \\lean{NagellLutz2}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem NagellLutz2 {E : WeierstrassCurve.Affine ℚ}\n (h1 : E.IsIntegral ℤ)\n (h2 : E.Δ ≠ 0) {x y : ℚ} (h : E.Nonsingular x y)\n (hx : 0 < addOrderOf (WeierstrassCurve.Affine.Point.some x y h)) :\n (y = 0 ∧ addOrderOf (WeierstrassCurve.Affine.Point.some x y h) = 2) ∨\n (NagellLutz1 h1 h2 h hx).2.choose ^ 2 ∣ (E.Δ_integral_of_isIntegral ℤ).choose := sorry"} -{"project_name": "NonSquareFreeWeird", "name": "weird_squarefree_infinite", "type": "theorem", "title": "Infinitely many weird numbers with non-squarefree odd part", "informal_statement": "There are infinitely many weird numbers with non-squarefree odd part.", "informal_proof": "\\chapter{Weird Numbers that are Multiples of Prime Powers}\n\nThis section contains a proof of a theorem about weird numbers that are multiples of prime powers.\nSee \\url{https://mathoverflow.net/questions/505954/on-the-non-squarefree-odd-part-of-a-weird-number} for more details.\n\n\\begin{definition}[odd part of a number]\n \\label{def:odd_part}\n \\lean{Nat.oddPart}\n The odd part of a natural number $n$ is $n$ divided by the largest power of $2$ which divides $n$.\n\\end{definition}\n\n\\begin{theorem}[Positive multiples of abundant numbers are abundant]\n \\label{thm:abundant_multiple}\n \\lean{Abundant.mul_of_pos}\n For any abundant number $n$ and any positive integer $m$, the number $nm$ is abundant.\n\\end{theorem}\n\n\\begin{proof}\n A number is abundant if the sum of its proper divisors is larger than the number itself.\n The proper divisors of $nm$ include all numbers of the form $d m$ where $d$ is a proper divisor of $n$.\n The sum of these divisors is $m$ times the sum of the proper divisors of $n$,\n which is larger than $n$ since $n$ is abundant.\n Thus the sum of the proper divisors of $nm$ is larger than $nm$,\n so $nm$ is abundant.\n\\end{proof}\n\n\\begin{theorem}[Product of weird number with prime]\n \\label{thm:weird_multiple}\n \\lean{Weird.mul_prime_large}\n For any prime $p$, and weird number $n$ (with $k$-free part $a$),\n if $p$ is larger than $\\sigma_1(a)$, the number $np$ is weird.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{thm:abundant_multiple}\n\n Given the assumptions, suppose that $np$ were not weird.\n Since $np$ is a positive multiple of the abundant number $n$, it is itself abundant by Theorem~\\ref{thm:abundant_multiple}.\n Thus $np$ must be pseudoperfect; there is a subset $S$ of these factors which sum to $np$.\n\n Consider that the factors of the number $np$ will be of the form $dp^e$ where $d | a$ and $0 \\le e \\le k+1$.\n Consider the subset $S_1$ of elements of $S$ of the form $dp^{e}$ for positive $e$.\n The members of $S_1$ do not comprise all of $S$ and themselves sum to $np$, or else the corresponding subset $S_1 / p$ of divisors of $n$ would sum to $n$ and $n$ would be pseudoperfect and therefore not weird.\n Thus $S_1$ sums to less than $np^k$ (so that the total is not too large),\n and since each member of the set is a multiple of $p$, they sum a multiple of $p$ less than $np$,\n and the subset of elements of $S$ with $e = 0$ must therefore sum to at least $p$.\n But the sum of all divisors of this form comes to $\\sigma_1(a) (1 + p + \\dots + p^{k-1}) = \\sigma_1(n) \\frac{p^k - 1}{p - 1}$.\n For $p$ at least $\\sigma_1(n) + 1$, we have $\\sigma_1(n) \\frac{p^k - 1}{p - 1} \\le p^k - 1 < p^k$,\n so $p^k$ will be larger than this sum, which is a contradiction.\n\n\\end{proof}\n\n\\begin{theorem}[Product of weird number with prime power]\n \\label{thm:weird_multiple_pow}\n \\lean{Weird.mul_prime_pow_large}\n For any prime $p$, and $p$-free weird number $n$,\n if $p$ is larger than $\\sigma_1(n)$, the number $np^k$ is weird for any nonnegative integer $k$.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{thm:weird_multiple}\n\n The proof follows by induction on $k$.\n\n In the base case $k = 0$, the statement reduces to the weirdness of $n$ itself, which is given.\n\n In the inductive step, assume the statement holds for $k$, and consider $k+1$.\n By the inductive hypothesis, $ap^k$ is weird.\n Applying Theorem~\\ref{thm:weird_multiple} with $np^k$ in place of $n$ and $p$ in place of $p$,\n we note that the $k$-free part of $ap^k$ is still $a$, and\n we conclude that $np^{k+1}$ is weird.\n\n\\end{proof}\n\n\\begin{theorem}[Infinitely many weird numbers with non-squarefree odd part]\n \\label{thm:weird_non_squarefree_odd_part}\n \\lean{weird_squarefree_infinite}\n \\uses{def:odd_part}\n There are infinitely many weird numbers with non-squarefree odd part.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{thm:weird_multiple_pow}\n From Theorem~\\ref{thm:weird_multiple_pow}, for any $N$,\n taking $k = 2$ and $n = 70$ (a weird number)\n gives infinitely many weird numbers of the form $70 p^2$, where $p$ is prime sufficiently large compared to $N$.\n Each such number has a non-squarefree odd part, since $p^2$ is divisible by this odd part.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat ArithmeticFunction.sigma\n\n\ntheorem weird_squarefree_infinite : ∀ N, ∃ n > N, Weird n ∧ ¬ Squarefree (n.oddPart) := by sorry"} -{"project_name": "OreTheorem", "name": "ore_maximal_hamiltonian_cycle_free_graph", "type": "lemma", "title": "Ore's theorem", "informal_statement": "If $G$ is a finite simple graph on $n \\geq 3$ vertices that is not Hamiltonian, but adding any edge to $G$ creates a Hamiltonian graph,\n then $\\deg v + \\deg w \\leq n - 1$ for any pair of distinct non-adjacent vertices $v$ and $w$.", "informal_proof": "\\chapter{Ore's theorem}\n\nThis section contains a (stub of a) proof of Ore's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Ore's_theorem} for more details.\n\n\\begin{lemma}\n \\label{ore-maximal-hamiltonian-cycle-free-graph}\n \\lean{ore_maximal_hamiltonian_cycle_free_graph}\n If $G$ is a finite simple graph on $n \\geq 3$ vertices that is not Hamiltonian, but adding any edge to $G$ creates a Hamiltonian graph,\n then $\\deg v + \\deg w \\leq n - 1$ for any pair of distinct non-adjacent vertices $v$ and $w$.\n\\end{lemma}\n\n\\begin{proof}\n Let $v$ and $w$ be any distinct non-adjacent vertices in $G$.\n Since adding the edge $vw$ creates a Hamiltonian graph, there is a Hamiltonian cycle in $G + vw$ that contains the edge $vw$.\n Removing the edge $vw$ from this cycle gives a Hamiltonian path in $G$ with endpoints $v$ and $w$.\n Let the vertices of this path be $v = v_0, v_1, \\ldots, v_{n-1} = w$ in order.\n For any $v_i, v_{i+1}$, we cannot have that both $v_i$ is adjacent to $w$ and $v_{i+1}$ is adjacent to $v$, since then we could construct a Hamiltonian cycle in $G$ by going from $v$ to $v_i$, then to $w$, then to $v_{i+1}$ backwards through the path, and then back to $v$.\n Therefore,reorganizing the sum of the degrees of $v$ and $w$ by these edges, we get that $\\deg v + \\deg w$ is at most the number of vertices in the path, which is $n - 1$.\n\\end{proof}\n\n\\begin{theorem}[Ore's theorem]\n \\label{ore-theorem}\n \\lean{ore_theorem}\n \\uses{ore-maximal-hamiltonian-cycle-free-graph}\n If $G$ is a finite simple graph on $n \\geq 3$ vertices such that $\\deg v + \\deg w \\geq n$ for every pair of distinct non-adjacent vertices $v$ and $w$, then $G$ is Hamiltonian.\n\\end{theorem}\n\n\\begin{proof}\n By contraposition, it suffices to show that if $G$ is not Hamiltonian,\n then there exist distinct non-adjacent vertices $v$ and $w$ such that $\\deg v + \\deg w \\leq n - 1$.\n This follows from Lemma~\\ref{ore-maximal-hamiltonian-cycle-free-graph},\n since if $G$ is not Hamiltonian,\n we can add edges to $G$ that do not create a Hamiltonian graph until we get a maximal Hamiltonian-cycle-free graph,\n and then apply the lemma to that graph, at which point any distinct non-adjacent vertices $v$ and $w$ that we get from the lemma are also non-adjacent in $G$, and have lower degree in $G$ than they do in the maximal Hamiltonian-cycle-free graph, so they also satisfy $\\deg v + \\deg w \\leq n - 1$ in $G$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nlemma ore_maximal_hamiltonian_cycle_free_graph {α : Type*} [Fintype α] [DecidableEq α]\n (G : SimpleGraph α) [DecidableRel G.Adj]\n (hn : 3 ≤ Fintype.card α)\n (hG : ¬ G.IsHamiltonian)\n (hMax : ∀ (H : SimpleGraph α) [DecidableRel H.Adj], G < H → H.IsHamiltonian) :\n ∀ v w : α, v ≠ w → ¬ G.Adj v w → G.degree v + G.degree w ≤ Fintype.card α - 1 := by sorry"} -{"project_name": "OreTheorem", "name": "ore_theorem", "type": "theorem", "title": "Ore's theorem", "informal_statement": "If $G$ is a finite simple graph on $n \\geq 3$ vertices such that $\\deg v + \\deg w \\geq n$ for every pair of distinct non-adjacent vertices $v$ and $w$, then $G$ is Hamiltonian.", "informal_proof": "\\chapter{Ore's theorem}\n\nThis section contains a (stub of a) proof of Ore's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Ore's_theorem} for more details.\n\n\\begin{lemma}\n \\label{ore-maximal-hamiltonian-cycle-free-graph}\n \\lean{ore_maximal_hamiltonian_cycle_free_graph}\n If $G$ is a finite simple graph on $n \\geq 3$ vertices that is not Hamiltonian, but adding any edge to $G$ creates a Hamiltonian graph,\n then $\\deg v + \\deg w \\leq n - 1$ for any pair of distinct non-adjacent vertices $v$ and $w$.\n\\end{lemma}\n\n\\begin{proof}\n Let $v$ and $w$ be any distinct non-adjacent vertices in $G$.\n Since adding the edge $vw$ creates a Hamiltonian graph, there is a Hamiltonian cycle in $G + vw$ that contains the edge $vw$.\n Removing the edge $vw$ from this cycle gives a Hamiltonian path in $G$ with endpoints $v$ and $w$.\n Let the vertices of this path be $v = v_0, v_1, \\ldots, v_{n-1} = w$ in order.\n For any $v_i, v_{i+1}$, we cannot have that both $v_i$ is adjacent to $w$ and $v_{i+1}$ is adjacent to $v$, since then we could construct a Hamiltonian cycle in $G$ by going from $v$ to $v_i$, then to $w$, then to $v_{i+1}$ backwards through the path, and then back to $v$.\n Therefore,reorganizing the sum of the degrees of $v$ and $w$ by these edges, we get that $\\deg v + \\deg w$ is at most the number of vertices in the path, which is $n - 1$.\n\\end{proof}\n\n\\begin{theorem}[Ore's theorem]\n \\label{ore-theorem}\n \\lean{ore_theorem}\n \\uses{ore-maximal-hamiltonian-cycle-free-graph}\n If $G$ is a finite simple graph on $n \\geq 3$ vertices such that $\\deg v + \\deg w \\geq n$ for every pair of distinct non-adjacent vertices $v$ and $w$, then $G$ is Hamiltonian.\n\\end{theorem}\n\n\\begin{proof}\n By contraposition, it suffices to show that if $G$ is not Hamiltonian,\n then there exist distinct non-adjacent vertices $v$ and $w$ such that $\\deg v + \\deg w \\leq n - 1$.\n This follows from Lemma~\\ref{ore-maximal-hamiltonian-cycle-free-graph},\n since if $G$ is not Hamiltonian,\n we can add edges to $G$ that do not create a Hamiltonian graph until we get a maximal Hamiltonian-cycle-free graph,\n and then apply the lemma to that graph, at which point any distinct non-adjacent vertices $v$ and $w$ that we get from the lemma are also non-adjacent in $G$, and have lower degree in $G$ than they do in the maximal Hamiltonian-cycle-free graph, so they also satisfy $\\deg v + \\deg w \\leq n - 1$ in $G$.\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem ore_theorem {α : Type*} [Fintype α] [DecidableEq α] (G : SimpleGraph α)\n [DecidableRel G.Adj]\n (hn : 3 ≤ Fintype.card α)\n (h : ∀ v w : α, v ≠ w → ¬G.Adj v w → Fintype.card α ≤ G.degree v + G.degree w) :\n G.IsHamiltonian := by sorry"} -{"project_name": "PicardTheorem", "name": "picard", "type": "theorem", "title": "Picard theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Picard theorem}\n\nThis section contains a (stub of a) proof of the Picard theorem.\nSee \\url{https://en.wikipedia.org/wiki/Picard_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Picard theorem]\n \\label{thm:picard-theorem}\n \\lean{picard}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Function Set\n\n\ntheorem picard {f : ℂ → ℂ} (f_diff : Differentiable ℂ f) (f_ne_const : ∀ a : ℂ, ∃ b : ℂ, f b ≠ a) :\n ∃ x : ℂ, {x}ᶜ ⊆ range f := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "polygonal_number_theorem_odd", "type": "theorem", "title": "Polygonal Number Theorem (Odd Case)", "informal_statement": "Let $m \\ge 3$ be an odd integer. If $N \\ge 28m^3$, then $N$ is the sum of four polygonal numbers of order $m+2$. That is, there exist $k_1, k_2, k_3, k_4$ such that\n $$ N = p_m(k_1) + p_m(k_2) + p_m(k_3) + p_m(k_4). $$", "informal_proof": "\\chapter{The Polygonal Number Theorem}\n\nThis section contains a proof of the Polygonal Number Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Fermat_polygonal_number_theorem} for more details.\n\n\\begin{definition}[Polygonal Number]\n \\label{def:polygonal_number}\n \\lean{pol_num}\n For any integer $m \\ge 1$ and $k \\ge 0$, the $k$-th polygonal number of order $m+2$ is defined as\n $$ p_m(k) = \\frac{m k (k-1)}{2} + k. $$\n\\end{definition}\n\n\\begin{theorem}[Gauss's Theorem]\n \\label{thm:sum_of_three_triangles}\n \\lean{sum_of_three_triangles}\n \\uses{def:polygonal_number}\n Every nonnegative integer $N$ is the sum of three triangular numbers. That is, there exist nonnegative integers $k_1, k_2, k_3$ such that\n $$ N = p_1(k_1) + p_1(k_2) + p_1(k_3). $$\n\\end{theorem}\n\n\\begin{proof}\n Consider the integer $8N+3$. Since $8N+3 \\equiv 3 \\pmod 8$, by Legendre's three-square theorem (Theorem 1.5 in the source text), it can be written as the sum of three squares. Moreover, since $x^2 \\equiv 0, 1, 4 \\pmod 8$, the only way three squares sum to $3 \\pmod 8$ is if all three are odd. Thus, there exist nonnegative integers $k_1, k_2, k_3$ such that:\n $$ 8N+3 = (2k_1+1)^2 + (2k_2+1)^2 + (2k_3+1)^2 $$\n Expanding the squares:\n $$ 8N+3 = (4k_1^2 + 4k_1 + 1) + (4k_2^2 + 4k_2 + 1) + (4k_3^2 + 4k_3 + 1) $$\n $$ 8N+3 = 4(k_1^2+k_1) + 4(k_2^2+k_2) + 4(k_3^2+k_3) + 3 $$\n Subtracting 3 and dividing by 8 yields:\n $$ N = \\frac{k_1(k_1+1)}{2} + \\frac{k_2(k_2+1)}{2} + \\frac{k_3(k_3+1)}{2} $$\n which is the sum of three triangular numbers $p_1(k_1) + p_1(k_2) + p_1(k_3)$.\n\\end{proof}\n\n\\begin{lemma}[Interval Bounds]\n \\label{lem:lemma1}\n \\lean{lemma1aAux, lemma1b}\n Let $m \\ge 3$ and $N \\ge 2m$. Let $L$ be the length of the interval\n $$ I = \\left(\\frac{1}{2} + \\sqrt{\\frac{6N}{m}-3}, \\quad \\frac{2}{3} + \\sqrt{\\frac{8N}{m}-8}\\right). $$\n Then the following hold:\n \\begin{enumerate}\n \\item If $N \\ge 108m$, then $L > 4$.\n \\item For any real $l \\ge 3$, if $N \\ge 7 l^2 m^3$, then $L > lm$.\n \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n The proof is a calculation of the difference between the endpoints. Let $x = N/m$. The condition $N \\ge 108m$ implies $x$ is sufficiently large such that the difference of the square roots exceeds $4 - (2/3 - 1/2)$. Specifically, expanding the inequality $\\sqrt{8x-8} - \\sqrt{6x-3} > l - 1/6$ leads to a quadratic inequality in $x$ which holds under the given bounds. The second part follows similarly by scaling $l$.\n\\end{proof}\n\n\\begin{lemma}[Coefficients of Representation]\n \\label{lem:lemma2}\n \\lean{lemma2a, lemma2b}\n \\uses{lem:lemma1}\n Let $m \\ge 3$ and $N \\ge 2m$. Let $a, b, r$ be nonnegative integers such that $0 \\le r < m$ and\n $$ N = \\frac{m}{2}(a-b) + b + r. $$\n Suppose $b$ lies in the interval $I$ defined in Lemma \\ref{lem:lemma1}. Then $a$ and $b$ satisfy the inequalities:\n $$ b^2 < 4a \\quad \\text{and} \\quad 3a < b^2 + 2b + 4. $$\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:lemma1}\n From the equation for $N$, we express $a$ as:\n $$ a = \\left(1 - \\frac{2}{m}\\right)b + \\frac{2(N-r)}{m}. $$\n Substituting this into the inequality $b^2 < 4a$ gives a quadratic inequality in $b$:\n $$ b^2 - 4\\left(1 - \\frac{2}{m}\\right)b - \\frac{8(N-r)}{m} < 0. $$\n The roots of the corresponding equation are approximately $2(1-2/m) \\pm \\sqrt{\\dots}$. The upper bound of the interval $I$ is chosen specifically to be less than the positive root, ensuring the inequality holds.\n Similarly, substituting $a$ into $3a < b^2 + 2b + 4$ yields:\n $$ b^2 - \\left(1 - \\frac{6}{m}\\right)b - \\left(\\frac{6(N-r)}{m} - 4\\right) > 0. $$\n The lower bound of $I$ is chosen to be greater than the positive root of this quadratic, ensuring the second inequality holds.\n\\end{proof}\n\n\\begin{lemma}[Cauchy's Lemma]\n \\label{lem:lemma3}\n \\lean{lemma3}\n \\uses{lem:lemma2}\n Let $a$ and $b$ be odd positive integers satisfying:\n $$ b^2 < 4a \\quad \\text{and} \\quad 3a < b^2 + 2b + 4. $$\n Then there exist nonnegative integers $s, t, u, v$ such that\n $$ a = s^2 + t^2 + u^2 + v^2 \\quad \\text{and} \\quad b = s + t + u + v. $$\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:lemma2}\n Since $a$ and $b$ are odd, $b^2 \\equiv 1 \\pmod 8$ and $4a \\equiv 4 \\pmod 8$. Thus, $4a - b^2 \\equiv 3 \\pmod 8$. By Legendre's three-square theorem (Theorem 1.5), there exist odd integers $x, y, z$ such that:\n $$ 4a - b^2 = x^2 + y^2 + z^2. $$\n We define $s, t, u, v$ by the linear transformation:\n $$ s = \\frac{b+x+y+z}{4}, \\quad t = \\frac{b+x-y-z}{4}, \\quad u = \\frac{b-x+y-z}{4}, \\quad v = \\frac{b-x-y+z}{4}. $$\n Since $x, y, z, b$ are all odd, their sums and differences are even, and by checking modulo 4 (using $x^2+y^2+z^2+b^2 = 4a \\equiv 0 \\pmod 4$), one verifies these are integers. It is straightforward to verify $s+t+u+v = b$ and $s^2+t^2+u^2+v^2 = a$.\n To ensure non-negativity, we use the bound on the sum of three squares. The maximum value of $x+y+z$ subject to $x^2+y^2+z^2 = K$ is $\\sqrt{3K}$. Here $K = 4a-b^2$. The condition $v \\ge 0$ requires $b \\ge x+y-z$, which is satisfied if $b + \\min(z) \\ge x+y$. A more careful analysis using the inequality $3a < b^2+2b+4$ shows that $b$ is sufficiently large relative to $\\sqrt{4a-b^2}$ to ensure $v \\ge 0$.\n\\end{proof}\n\n\\begin{theorem}[Polygonal Number Theorem (Odd Case)]\n \\label{thm:polygonal_number_theorem_odd}\n \\lean{polygonal_number_theorem_odd}\n \\uses{def:polygonal_number, thm:sum_of_three_triangles, lem:lemma1, lem:lemma2, lem:lemma3}\n Let $m \\ge 3$ be an odd integer. If $N \\ge 28m^3$, then $N$ is the sum of four polygonal numbers of order $m+2$. That is, there exist $k_1, k_2, k_3, k_4$ such that\n $$ N = p_m(k_1) + p_m(k_2) + p_m(k_3) + p_m(k_4). $$\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:lemma1, lem:lemma2, lem:lemma3}\n By Lemma \\ref{lem:lemma1}, the length of the interval $I$ is greater than $m$. Since $m$ is odd, $I$ contains a complete set of residues modulo $m$, and specifically, it must contain an odd integer $b$ such that $N \\equiv b \\pmod m$.\n Let $r=0$. Define $a$ by the relation in Lemma \\ref{lem:lemma2}: $N = \\frac{m}{2}(a-b) + b$. Since $N \\equiv b \\pmod m$ and $m$ is odd, $N-b$ is divisible by $m$, and the parity of $a$ can be controlled or shown to be odd.\n Since $b \\in I$, Lemma \\ref{lem:lemma2} implies $b^2 < 4a$ and $3a < b^2+2b+4$.\n Applying Lemma \\ref{lem:lemma3}, we find $s, t, u, v$ such that $a = s^2+t^2+u^2+v^2$ and $b = s+t+u+v$.\n Substituting these into the equation for $N$:\n \\begin{align*}\n N &= \\frac{m}{2}\\left((s^2+t^2+u^2+v^2) - (s+t+u+v)\\right) + (s+t+u+v) \\\\\n &= \\left(\\frac{m}{2}(s^2-s) + s\\right) + \\left(\\frac{m}{2}(t^2-t) + t\\right) + \\dots \\\\\n &= p_m(s) + p_m(t) + p_m(u) + p_m(v).\n \\end{align*}\n\\end{proof}\n\n\\begin{theorem}[Polygonal Number Theorem (Even Case)]\n \\label{thm:polygonal_number_theorem_even}\n \\lean{polygonal_number_theorem_even}\n \\uses{def:polygonal_number, thm:polygonal_number_theorem_odd, lem:lemma1, lem:lemma2, lem:lemma3}\n Let $m \\ge 3$ be an even integer. If $N \\ge 28m^3$, then $N$ is the sum of five polygonal numbers of order $m+2$. Specifically:\n $$ N = \\sum_{i=1}^4 p_m(k_i) \\quad \\text{or} \\quad N = \\sum_{i=1}^4 p_m(k_i) + 1. $$\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:lemma1, lem:lemma2, lem:lemma3}\n Since the length of $I$ is greater than $2m$ (by Lemma \\ref{lem:lemma1} with appropriate $N$), $I$ contains $m$ consecutive odd integers. These form a complete set of residues modulo $m$ (since $(2, m) \\ne 1$ is not required for the set of odd numbers to cover residues if the interval is long enough? No, actually, if $m$ is even, odd numbers only cover odd residues. However, we can shift).\n\n If $N$ is odd, we choose an odd $b \\in I$ such that $N \\equiv b \\pmod m$. We proceed as in Theorem \\ref{thm:polygonal_number_theorem_odd} to represent $N$ as a sum of 4 polygonal numbers.\n\n If $N$ is even, then $N-1$ is odd. We choose an odd $b \\in I$ such that $N-1 \\equiv b \\pmod m$. We then represent $N-1$ as a sum of 4 polygonal numbers. Since $1 = p_m(1)$, adding this to the sum gives a representation of $N$ as a sum of 5 polygonal numbers.\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem polygonal_number_theorem_odd (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 28 * m ^ 3) (hm2 : Odd m) :\n ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num m k4 := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "polygonal_number_theorem_even'", "type": "lemma", "title": "", "informal_statement": "", "informal_proof": "", "code": "import Mathlib\n\n\nlemma polygonal_number_theorem_even' (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 7 * m ^ 3) (hN' : Odd N)\n (hm2 : Even m) : ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num\n m k4 := by sorry"} -{"project_name": "PrekopaLeindler", "name": "prekopa_leindler_dim1", "type": "lemma", "title": "Main Theorem: Prékopa-Leindler inequality in dimension 1", "informal_statement": "Let $0 < \\lambda < 1$ and let $f, g, h$ be nonnegative integrable functions on $\\mathbb{R}$ satisfying\n \\[ h\\big((1-\\lambda)x + \\lambda y\\big) \\;\\ge\\; f(x)^{1-\\lambda} g(y)^{\\lambda} \\tag{10}\\]\n for all $x,y \\in \\mathbb{R}$. Then\n \\[\n \\int_{\\mathbb{R}} h(x)\\,dx \\;\\ge\\;\n \\left( \\int_{\\mathbb{R}} f(x)\\,dx \\right)^{1-\\lambda}\n \\left( \\int_{\\mathbb{R}} g(x)\\,dx \\right)^{\\lambda}.\n \\tag{12}\n \\]", "informal_proof": "\n\\chapter{The Prékopa-Leindler Inequality (dimension 1)}\n\nThis section contains a proof of the Prékopa-Leindler inequality.\nSee \\url{https://en.wikipedia.org/wiki/Pr%C3%A9kopa%E2%80%93Leindler_inequality} for more details.\n\n\\section{Brunn-Minkowski Inequality in Dimension 1}\n\n\\begin{lemma}[One-dimensional Brunn-Minkowski inequality]\n \\label{lem:one_dim_BMInequality}\n \\lean{one_dim_BMInequality}\n Let $A, B, C$ be nonempty measurable sets in $\\mathbb{R}$ such that $A + B \\subseteq C$. Then\n \\[\n \\text{vol}(A) + \\text{vol}(B) \\le \\text{vol}(C).\n \\]\n\\end{lemma}\n\\begin{proof}\n The proof proceeds by several reductions. First, if either $A$ or $B$ has infinite measure, the result follows from monotonicity.\n\n For the finite case, we reduce to compact sets by approximation using mathlib lemmas. Given $\\varepsilon > 0$, find compact sets $S \\subseteq A$ and $T \\subseteq B$ such that $\\text{vol}(A \\setminus S) < \\varepsilon/2$ and $\\text{vol}(B \\setminus T) < \\varepsilon/2$. Then\n \\[\n \\text{vol}(A) < \\text{vol}(S) + \\varepsilon/2, \\quad \\text{vol}(B) < \\text{vol}(T) + \\varepsilon/2.\n \\]\n\n For compact sets, we use a direct geometric argument. Define $A_t = \\inf B +_v A$ and $B_t = \\sup A +_v B$. These sets are disjoint except at a single point, so $\\text{vol}(A_t \\cap B_t) = 0$. Since both are translates contained in $C$, we have\n \\[\n \\text{vol}(A_t) + \\text{vol}(B_t) = \\text{vol}(A_t \\cup B_t) \\le \\text{vol}(C).\n \\]\n By translation invariance, $\\text{vol}(A_t) = \\text{vol}(A)$ and $\\text{vol}(B_t) = \\text{vol}(B)$.\n\\end{proof}\n\n\\begin{lemma}[Brunn-Minkowski for null-measurable sets]\n \\label{lem:one_dim_BMInequality_of_nullmeasurable}\n \\lean{one_dim_BMInequality_of_nullmeasurable}\n \\uses{lem:one_dim_BMInequality}\n The Brunn-Minkowski inequality holds for nonempty null-measurable sets in $\\mathbb{R}$.\n\\end{lemma}\n\\begin{proof}\n For null-measurable sets $A, B$, find measurable subsets $A_m \\subseteq A$ and $B_m \\subseteq B$ that agree with $A$ and $B$ almost everywhere. Apply Lemma~\\ref{lem:one_dim_BMInequality} to $A_m$ and $B_m$, and use the fact that null-measurable sets have the same measure as their measurable cores.\n\\end{proof}\n\n\\section{Definitions and Basic Properties}\n\n\\begin{definition}[Prékopa-Leindler condition]\n \\label{def:PL_dim1_cond}\n \\lean{PL_dim1_cond}\n For functions $f, g, h : \\mathbb{R} \\to \\mathbb{R}$ and $t \\in [0,1]$, we say the \\emph{Prékopa-Leindler condition} holds if\n \\[\n f(x)^{1-t} \\cdot g(y)^t \\le h(x + y)\n \\]\n for all $x, y \\in \\mathbb{R}$.\n\\end{definition}\n\n\\begin{lemma}[Swapping in PL condition]\n \\label{lem:PL_dim1_cond_swap}\n \\lean{PL_dim1_cond_swap}\n \\uses{def:PL_dim1_cond}\n The PL condition is symmetric: if $f, g, h$ satisfy the condition for parameter $t$, then $g, f, h$ satisfy it for parameter $1-t$.\n\\end{lemma}\n\\begin{proof}\n This follows from commutativity of addition and multiplication: $f(x)^{1-t} g(y)^t = g(y)^t f(x)^{1-t}$ and $x + y = y + x$.\n\\end{proof}\n\n\\begin{definition}[Prékopa-Leindler conclusion]\n \\label{def:PL_dim1_conclusion}\n \\lean{PL_dim1_conclusion}\n For functions $f, g, h : \\mathbb{R} \\to \\mathbb{R}$ and $t \\in [0,1]$, the \\emph{Prékopa-Leindler conclusion} states\n \\[\n \\left(\\int f\\right)^{1-t} \\left(\\int g\\right)^t \\le (1-t)^{1-t} t^t \\int h.\n \\]\n\\end{definition}\n\n\\begin{lemma}[Swapping in PL conclusion]\n \\label{lem:PL_dim1_conclusion_swap}\n \\lean{PL_dim1_conclusion_swap}\n \\uses{def:PL_dim1_conclusion}\n The PL conclusion is symmetric with respect to swapping $f \\leftrightarrow g$ and $t \\leftrightarrow 1-t$.\n\\end{lemma}\n\\begin{proof}\n Direct verification using commutativity of multiplication.\n\\end{proof}\n\n\\begin{definition}[Essentially bounded function]\n \\label{def:IsEssBdd}\n \\lean{IsEssBdd}\n A function $f$ is \\emph{essentially bounded} with respect to measure $\\mu$ if it is bounded above almost everywhere.\n\\end{definition}\n\n\\section{Normalized Functions}\n\n\\begin{lemma}[Volume inequality for normalized superlevel sets]\n \\label{lem:fgh_nor_splsets_vol_le}\n \\lean{fgh_nor_splsets_vol_le}\n \\uses{def:PL_dim1_cond, lem:one_dim_BMInequality_of_nullmeasurable}\n Under appropriate normalization and boundedness conditions, the volumes of superlevel sets of normalized functions satisfy a Brunn-Minkowski type inequality.\n\\end{lemma}\n\\begin{proof}\n This combines the superlevel subset property (Lemma~\\ref{lem:superlevel_subset}) with the one-dimensional Brunn-Minkowski inequality (Lemma~\\ref{lem:one_dim_BMInequality_of_nullmeasurable}). The normalization ensures that we work with functions whose essential suprema are well-behaved.\n\\end{proof}\n\n\\section{Main Theorem and Its Variants}\n\n\\begin{lemma}[Pr\\'ekopa-Leindler for essentially bounded functions]\n \\label{lem:Prekopa_leindler_dim1_essBdd}\n \\lean{prekopa_leindler_dim1_essBdd}\n \\uses{def:PL_dim1_cond, def:PL_dim1_conclusion, lem:fgh_nor_splsets_vol_le}\n The Pr\\'ekopa-Leindler inequality holds when both $f$ and $g$ are essentially bounded.\n\\end{lemma}\n\\begin{proof}\n The proof uses the layer cake representation and the normalized volume inequality. We normalize $f$ and $g$ by their essential suprema, apply the volume inequality to superlevel sets, and integrate using the layer cake formula. The weighted arithmetic-geometric mean inequality provides the final step.\n\\end{proof}\n\n\\begin{lemma}[Extension from bounded $g$]\n \\label{lem:Prekopa_leindler_dim1_from_g_essBdd}\n \\lean{prekopa_leindler_dim1_from_g_essBdd}\n \\uses{def:PL_dim1_cond, def:PL_dim1_conclusion}\n If Pr\\'ekopa-Leindler holds for all essentially bounded $g$, then it holds for all integrable $g$.\n\\end{lemma}\n\\begin{proof}\n Approximate $g$ by truncated functions $g_n = \\min(g, n)$. These are essentially bounded, so the inequality holds for each $g_n$. Take the limit as $n \\to \\infty$ using monotone convergence.\n\\end{proof}\n\n\\begin{lemma}[Extension from bounded $f$]\n \\label{lem:Prekopa_leindler_dim1_from_f_essBdd}\n \\lean{prekopa_leindler_dim1_from_f_essBdd}\n \\uses{def:PL_dim1_cond, def:PL_dim1_conclusion, lem:PL_dim1_cond_swap, lem:PL_dim1_conclusion_swap, lem:Prekopa_leindler_dim1_from_g_essBdd}\n If Pr\\'ekopa-Leindler holds for all essentially bounded $f$, then it holds for all integrable $f$.\n\\end{lemma}\n\\begin{proof}\n Similar to the previous lemma, using the symmetry property (Lemma~\\ref{lem:PL_dim1_cond_swap}).\n\\end{proof}\n\n\\begin{lemma}[Prékopa-Leindler with bounded $f$]\n \\label{lem:prekopa_leindler_dim1_f_essBdd}\n \\lean{prekopa_leindler_dim1_f_essBdd}\n \\uses{def:IsEssBdd, def:PL_dim1_cond, def:PL_dim1_conclusion, lem:Prekopa_leindler_dim1_from_g_essBdd, lem:Prekopa_leindler_dim1_essBdd}\n The Prékopa-Leindler inequality holds when $f$ is essentially bounded.\n\\end{lemma}\n\\begin{proof}\n Combine Lemma~\\ref{lem:Prekopa_leindler_dim1_essBdd} with Lemma~\\ref{lem:Prekopa_leindler_dim1_from_g_essBdd}.\n\\end{proof}\n\n\\begin{theorem}[Main Theorem: Prékopa-Leindler inequality in dimension 1]\n \\label{lem:PL_ineq_dim1}\n \\lean{prekopa_leindler_dim1}\n \\uses{def:PL_dim1_cond, def:PL_dim1_conclusion, lem:Prekopa_leindler_dim1_from_f_essBdd, lem:prekopa_leindler_dim1_f_essBdd}\n Let $0 < \\lambda < 1$ and let $f, g, h$ be nonnegative integrable functions on $\\mathbb{R}$ satisfying\n \\[ h\\big((1-\\lambda)x + \\lambda y\\big) \\;\\ge\\; f(x)^{1-\\lambda} g(y)^{\\lambda} \\tag{10}\\]\n for all $x,y \\in \\mathbb{R}$. Then\n \\[\n \\int_{\\mathbb{R}} h(x)\\,dx \\;\\ge\\;\n \\left( \\int_{\\mathbb{R}} f(x)\\,dx \\right)^{1-\\lambda}\n \\left( \\int_{\\mathbb{R}} g(x)\\,dx \\right)^{\\lambda}.\n \\tag{12}\n \\]\n\\end{theorem}\n\\begin{proof}\n If $\\int_{\\mathbb{R}} f(x)\\,dx = 0$ or $\\int_{\\mathbb{R}} g(x)\\,dx = 0$ the Prékopa–Leindler inequality (12) holds trivially. We thus assume $\\int_{\\mathbb{R}} f(x)\\,dx = F > 0$ and $\\int_{\\mathbb{R}} g(x)\\,dx = G > 0$.\n Define the auxiliary functions $u,v : [0,1] \\to \\mathbb{R}$ such that $u(t)$ and $v(t)$ are the smallest numbers satisfying\n \\[\n \\frac{1}{F}\\int_{-\\infty}^{u(t)} f(x)\\,dx\n = \\frac{1}{G}\\int_{-\\infty}^{v(t)} g(x)\\,dx\n = t.\n \\tag{13}\n \\]\n Since $f$ and $g$ are nonnegative, $u$ and $v$ are strictly increasing functions and hence are differentiable almost everywhere. Note that $u$ and $v$ do not have to be continuous everywhere. Taking the derivative of (13) with respect to $t$ gives for almost every $t$:\n \\[\n \\frac{f(u(t))u'(t)}{F} = \\frac{g(v(t))v'(t)}{G} = 1.\n \\tag{14}\n \\]\n Let $w(t) = (1-\\lambda)u(t) + \\lambda v(t)$. By (14), for almost every $t \\in (0,1)$ we have $f(u(t)) \\neq 0 \\neq g(v(t))$, and thus also\n \\[\n \\begin{aligned}\n w'(t) &= (1-\\lambda)u'(t) + \\lambda v'(t) \\\\\n &\\ge u'(t)^{1-\\lambda} v'(t)^{\\lambda} \\\\\n &= \\left( \\frac{F}{f(u(t))} \\right)^{1-\\lambda}\n \\left( \\frac{G}{g(v(t))} \\right)^{\\lambda},\n \\end{aligned}\n \\tag{15}\n \\]\n where we used Young’s inequality in the first step and (14) in the second step.\n By assumption (10), (15), $h \\ge 0$ and $w$ being strictly increasing we have\n \\[\n \\int_{\\mathbb{R}} h(x)\\,dx\n \\;\\ge\\; \\int_{0}^{1} h(w(t))w'(t)\\,dt\n \\]\n \\[\n \\;\\ge\\; \\int_{0}^{1} f(u(t))^{1-\\lambda} g(v(t))^{\\lambda}\n \\left( \\frac{F}{f(u(t))} \\right)^{1-\\lambda}\n \\left( \\frac{G}{g(v(t))} \\right)^{\\lambda} dt\n \\]\n \\[\n = F^{1-\\lambda} G^{\\lambda}\n = \\left(\\int_{\\mathbb{R}} f(x)\\,dx\\right)^{1-\\lambda}\n \\left(\\int_{\\mathbb{R}} g(x)\\,dx\\right)^{\\lambda}.\n \\]\n\\end{proof}\n", "code": "import Mathlib\n\n\nset_option maxHeartbeats 400000 in\n\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\n\nopen scoped Topology in\n\n\nlemma prekopa_leindler_dim1\n {t : ℝ} (h0t : 0 < t) (ht1 : t < 1) {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf_nonneg : 0 ≤ f)\n (hf_integrable : Integrable f) (hg_nonneg : 0 ≤ g) (hg_integrable : Integrable g)\n (hh_nonneg : 0 ≤ h) (hh_integrable : Integrable h) (hfgh_pow_le : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := sorry"} -{"project_name": "ProthTheorem", "name": "proth", "type": "theorem", "title": "Proth's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Proth's theorem}\n\nThis section contains a (stub of a) proof of Proth's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Proth's_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Proth's theorem]\n \\label{thm:proth-theorem}\n \\lean{proth}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem proth {n : ℕ} (h : IsProth n) : n.Prime ↔ ∃ a : ℕ, a ^ ((n - 1) / 2) ≡ -1 [ZMOD n] := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "smallest_period_div", "type": "theorem", "title": "Smallest period divisor identity", "informal_statement": "For $n > 0$,\n \\[\n \\bigl(b(n+1) : \\mathbb{R}\\bigr)\n = (2n+1)^{-1} \\cdot \\sum_{j=0}^{a(n)-1} \\bigl(2^j \\bmod (2n+1)\\bigr),\n \\]\n where $a(n) = A002326(n) = \\inf\\{m > 0 : (2n+1) \\mid 2^m - 1\\}$ and $b = A179382$.", "informal_proof": "\\chapter{Closed Form for Smallest Period of Pseudo-Arithmetic Progression}\n\nThis section contains a proof of the closed-form identity for A179382, the number of odd residues in a pseudo-arithmetic progression.\nSee \\url{https://mathoverflow.net/questions/507658/closed-form-for-a179382} for more details.\n\n% TODO some lemmas here could be golfed away for succinctness\n\n\n\\begin{lemma}[Residue bound]\n \\label{lem:pap_residue_lt}\n \\lean{residue_lt}\n For all $j, n : \\mathbb{N}$, $2^j \\bmod (2n+1) < 2n+1$.\n\\end{lemma}\n\\begin{proof}\n This follows from positivity of $2n+1$.\n\\end{proof}\n\n\\begin{lemma}[Double residue bound]\n \\label{lem:pap_two_mul_residue_lt}\n \\lean{two_mul_residue_lt}\n \\uses{lem:pap_residue_lt}\n For all $j, n : \\mathbb{N}$, $2 \\cdot (2^j \\bmod (2n+1)) < 2 \\cdot (2n+1)$.\n\\end{lemma}\n\\begin{proof}\n Multiply the residue bound from the previous lemma by 2 on both sides.\n\\end{proof}\n\n\\begin{lemma}[Division algorithm for doubled residue]\n \\label{lem:pap_div_algo_two_mul_residue}\n \\lean{div_algo_two_mul_residue}\n For all $j, n : \\mathbb{N}$,\n \\[\n 2 \\cdot (2^j \\bmod (2n+1)) = (2n+1) \\cdot \\Bigl\\lfloor \\tfrac{2 \\cdot (2^j \\bmod (2n+1))}{2n+1} \\Bigr\\rfloor + \\bigl(2 \\cdot (2^j \\bmod (2n+1))\\bigr) \\bmod (2n+1).\n \\]\n\\end{lemma}\n\\begin{proof}\n This is the Euclidean division identity applied to $2 \\cdot (2^j \\bmod (2n+1))$ divided by $2n+1$.\n\\end{proof}\n\n\\begin{lemma}[Quotient is at most one]\n \\label{lem:pap_quotient_le_one}\n \\lean{quotient_le_one}\n \\uses{lem:pap_two_mul_residue_lt}\n For all $j, n : \\mathbb{N}$, $\\lfloor 2 \\cdot (2^j \\bmod (2n+1)) / (2n+1) \\rfloor \\leq 1$.\n\\end{lemma}\n\\begin{proof}\n Since $2 \\cdot (2^j \\bmod (2n+1)) < 2 \\cdot (2n+1)$, the quotient under division by $2n+1$ is strictly less than 2, hence at most 1.\n\\end{proof}\n\n\\begin{lemma}[Double-residue mod equals next residue]\n \\label{lem:pap_two_mul_residue_mod}\n \\lean{two_mul_residue_mod}\n For all $j, n : \\mathbb{N}$,\n \\[\n \\bigl(2 \\cdot (2^j \\bmod (2n+1))\\bigr) \\bmod (2n+1) = 2^{j+1} \\bmod (2n+1).\n \\]\n\\end{lemma}\n\\begin{proof}\n Use $2^{j+1} = 2 \\cdot 2^j$ and the multiplicativity of the modulo operation.\n\\end{proof}\n\n\\begin{lemma}[Quotient equals parity: case less than]\n \\label{lem:pap_quotient_eq_parity_case_lt}\n \\lean{quotient_eq_parity_case_lt}\n For $j, n : \\mathbb{N}$ with $n > 0$ and $2 \\cdot (2^j \\bmod (2n+1)) < 2n+1$,\n \\[\n \\Bigl\\lfloor \\tfrac{2 \\cdot (2^j \\bmod (2n+1))}{2n+1} \\Bigr\\rfloor\n = \\bigl(2 \\cdot (2^j \\bmod (2n+1))\\bigr) \\bmod (2n+1) \\bmod 2.\n \\]\n\\end{lemma}\n\\begin{proof}\n When $2r_j < 2n+1$, the quotient is 0, and the remainder equals $2r_j$. Since $r_j$ is a natural number, $2r_j$ is even, so $2r_j \\bmod 2 = 0$. Both sides equal 0.\n\\end{proof}\n\n\\begin{lemma}[Quotient equals parity: case at least]\n \\label{lem:pap_quotient_eq_parity_case_ge}\n \\lean{quotient_eq_parity_case_ge}\n \\uses{lem:pap_two_mul_residue_lt, lem:pap_quotient_le_one}\n For $j, n : \\mathbb{N}$ with $n > 0$ and $2n+1 \\leq 2 \\cdot (2^j \\bmod (2n+1))$,\n \\[\n \\Bigl\\lfloor \\tfrac{2 \\cdot (2^j \\bmod (2n+1))}{2n+1} \\Bigr\\rfloor\n = \\bigl(2 \\cdot (2^j \\bmod (2n+1))\\bigr) \\bmod (2n+1) \\bmod 2.\n \\]\n\\end{lemma}\n\\begin{proof}\n When $2n+1 \\leq 2r_j < 2(2n+1)$, the quotient equals 1. The remainder is $2r_j - (2n+1)$, which is even minus odd, hence odd, so its parity is 1. Both sides equal 1.\n\\end{proof}\n\n\\begin{lemma}[Quotient equals parity of next residue]\n \\label{lem:pap_quotient_eq_parity}\n \\lean{quotient_eq_parity}\n \\uses{lem:pap_quotient_eq_parity_case_lt, lem:pap_quotient_eq_parity_case_ge}\n For all $j, n : \\mathbb{N}$ with $n > 0$,\n \\[\n \\Bigl\\lfloor \\tfrac{2 \\cdot (2^j \\bmod (2n+1))}{2n+1} \\Bigr\\rfloor\n = \\bigl(2 \\cdot (2^j \\bmod (2n+1))\\bigr) \\bmod (2n+1) \\bmod 2.\n \\]\n\\end{lemma}\n\\begin{proof}\n Split on whether $2 \\cdot (2^j \\bmod (2n+1)) < 2n+1$ or $\\geq 2n+1$, applying the two case lemmas.\n\\end{proof}\n\n\\begin{lemma}[The period set is nonempty]\n \\label{lem:pap_order_set_nonempty}\n \\lean{order_set_nonempty}\n For $n > 0$, the set $\\{m \\in \\mathbb{N} \\mid 0 < m \\text{ and } (2n+1) \\mid 2^m - 1\\}$ is nonempty.\n\\end{lemma}\n\\begin{proof}\n Since $\\gcd(2, 2n+1) = 1$ (as $2n+1$ is odd), the element 2 is a unit in $\\mathbb{Z}/(2n+1)\\mathbb{Z}$. The order of this unit is positive and satisfies $2^{\\mathrm{ord}} \\equiv 1 \\pmod{2n+1}$, placing it in the set.\n\\end{proof}\n\n\\begin{lemma}[$a(n)$ is positive]\n \\label{lem:pap_a_pos}\n \\lean{a_pos}\n \\uses{lem:pap_order_set_nonempty}\n For $n > 0$, $0 < a(n)$.\n\\end{lemma}\n\\begin{proof}\n Because the period set is nonempty, the infimum exists and belongs to the set and therefore satisfies the positivity condition.\n\\end{proof}\n\n\\begin{lemma}[$2^{a(n)} \\equiv 1 \\pmod{2n+1}$]\n \\label{lem:pap_pow_a_mod_eq_one}\n \\lean{pow_a_mod_eq_one}\n \\uses{lem:pap_order_set_nonempty}\n For $n > 0$, $2^{a(n)} \\bmod (2n+1) = 1$.\n\\end{lemma}\n\\begin{proof}\n $a(n)$ belongs to the period set, so $(2n+1) \\mid 2^{a(n)} - 1$. Since $2^{a(n)} \\geq 1$, this divisibility gives $2^{a(n)} \\equiv 1 \\pmod{2n+1}$.\n\\end{proof}\n\n\\begin{lemma}[Shifted sum equality]\n \\label{lem:pap_sum_shift_eq}\n \\lean{sum_shift_eq}\n For $k > 0$ and any $f : \\mathbb{N} \\to \\mathbb{N}$ with $f(k) = f(0)$,\n \\[\n \\sum_{j=0}^{k-1} f(j+1) = \\sum_{j=0}^{k-1} f(j).\n \\]\n\\end{lemma}\n\\begin{proof}\n Reindex to write both sums in terms of $\\sum_{j=0}^{k} f(j)$, then use $f(k) = f(0)$ to equate the boundary terms.\n\\end{proof}\n\n\\begin{lemma}[Residue sum is shift-invariant]\n \\label{lem:pap_sum_residue_shift}\n \\lean{sum_residue_shift}\n \\uses{lem:pap_a_pos, lem:pap_pow_a_mod_eq_one, lem:pap_sum_shift_eq}\n For $n > 0$,\n \\[\n \\sum_{j=0}^{a(n)-1} \\bigl(2^{j+1} \\bmod (2n+1)\\bigr) = \\sum_{j=0}^{a(n)-1} \\bigl(2^j \\bmod (2n+1)\\bigr).\n \\]\n\\end{lemma}\n\\begin{proof}\n Apply the shifted sum lemma with $f(j) = 2^j \\bmod (2n+1)$ and $k = a(n)$. The boundary condition $f(a(n)) = f(0)$ follows from $2^{a(n)} \\bmod (2n+1) = 1 = 2^0 \\bmod (2n+1)$.\n\\end{proof}\n\n\\begin{lemma}[Parity sum is shift-invariant]\n \\label{lem:pap_sum_parity_shift}\n \\lean{sum_parity_shift}\n \\uses{lem:pap_a_pos, lem:pap_pow_a_mod_eq_one, lem:pap_sum_shift_eq}\n For $n > 0$,\n \\[\n \\sum_{j=0}^{a(n)-1} \\bigl(2^{j+1} \\bmod (2n+1)\\bigr) \\bmod 2\n = \\sum_{j=0}^{a(n)-1} \\bigl(2^j \\bmod (2n+1)\\bigr) \\bmod 2.\n \\]\n\\end{lemma}\n\\begin{proof}\n Apply the shifted sum lemma with $f(j) = (2^j \\bmod (2n+1)) \\bmod 2$. The boundary condition holds because $2^{a(n)} \\bmod (2n+1) = 1$ and $2^0 \\bmod (2n+1) = 1$, so both parities are 1.\n\\end{proof}\n\n\\begin{lemma}[Summed division algorithm]\n \\label{lem:pap_sum_two_mul_residue}\n \\lean{sum_two_mul_residue}\n \\uses{lem:pap_div_algo_two_mul_residue}\n For $n > 0$,\n \\[\n \\sum_{j=0}^{a(n)-1} 2 \\cdot (2^j \\bmod (2n+1))\n = (2n+1) \\cdot \\sum_{j=0}^{a(n)-1} \\Bigl\\lfloor \\tfrac{2 \\cdot (2^j \\bmod (2n+1))}{2n+1} \\Bigr\\rfloor\n + \\sum_{j=0}^{a(n)-1} \\bigl(2 \\cdot (2^j \\bmod (2n+1))\\bigr) \\bmod (2n+1).\n \\]\n\\end{lemma}\n\\begin{proof}\n Sum the division algorithm identity over $j = 0, \\ldots, a(n)-1$, factor the constant $(2n+1)$ out of the first sum, and apply linearity of summation.\n\\end{proof}\n\n\\begin{lemma}[Factor 2 from residue sum]\n \\label{lem:pap_sum_two_mul_residue_lhs}\n \\lean{sum_two_mul_residue_lhs}\n For all $n : \\mathbb{N}$,\n \\[\n \\sum_{j=0}^{a(n)-1} 2 \\cdot (2^j \\bmod (2n+1)) = 2 \\cdot \\sum_{j=0}^{a(n)-1} \\bigl(2^j \\bmod (2n+1)\\bigr).\n \\]\n\\end{lemma}\n\\begin{proof}\n Factor the constant 2 out of the sum.\n\\end{proof}\n\n\\begin{lemma}[$b(n+1)$ unfolds to parity sum]\n \\label{lem:pap_b_unfold}\n \\lean{b_unfold}\n For $n \\geq 1$,\n \\[\n b(n+1) = \\sum_{j \\in \\mathrm{range}(a(n))} \\bigl(2^j \\bmod (2n+1)\\bigr) \\bmod 2.\n \\]\n\\end{lemma}\n\\begin{proof}\n Write $n = k+1$ for $k \\geq 0$. Then $n+1 = k+2$, which matches the third pattern branch of the definition of $A179382$, giving the stated sum.\n\\end{proof}\n\n\\begin{lemma}[Quotient sum equals shifted parity sum]\n \\label{lem:pap_sum_quotient_eq_sum_parity}\n \\lean{sum_quotient_eq_sum_parity}\n \\uses{lem:pap_quotient_eq_parity, lem:pap_two_mul_residue_mod}\n For $n > 0$,\n \\[\n \\sum_{j=0}^{a(n)-1} \\Bigl\\lfloor \\tfrac{2 \\cdot (2^j \\bmod (2n+1))}{2n+1} \\Bigr\\rfloor\n = \\sum_{j=0}^{a(n)-1} \\bigl(2^{j+1} \\bmod (2n+1)\\bigr) \\bmod 2.\n \\]\n\\end{lemma}\n\\begin{proof}\n For each $j$, apply the quotient-parity lemma and then substitute $(2 \\cdot (2^j \\bmod (2n+1))) \\bmod (2n+1) = 2^{j+1} \\bmod (2n+1)$ using the double-residue mod lemma.\n\\end{proof}\n\n\\begin{lemma}[Quotient sum equals $b(n+1)$]\n \\label{lem:pap_sum_quotient_eq_b}\n \\lean{sum_quotient_eq_b}\n \\uses{lem:pap_sum_quotient_eq_sum_parity, lem:pap_sum_parity_shift, lem:pap_b_unfold}\n For $n > 0$,\n \\[\n \\sum_{j=0}^{a(n)-1} \\Bigl\\lfloor \\tfrac{2 \\cdot (2^j \\bmod (2n+1))}{2n+1} \\Bigr\\rfloor = b(n+1).\n \\]\n\\end{lemma}\n\\begin{proof}\n Chain the equality through the shifted parity sum lemma and the unfolding of $b(n+1)$.\n\\end{proof}\n\n\\begin{lemma}[Double-mod residue sum equals residue sum]\n \\label{lem:pap_sum_two_mul_mod_eq_sum_residue}\n \\lean{sum_two_mul_mod_eq_sum_residue}\n \\uses{lem:pap_two_mul_residue_mod, lem:pap_sum_residue_shift}\n For $n > 0$,\n \\[\n \\sum_{j=0}^{a(n)-1} \\bigl(2 \\cdot (2^j \\bmod (2n+1))\\bigr) \\bmod (2n+1)\n = \\sum_{j=0}^{a(n)-1} \\bigl(2^j \\bmod (2n+1)\\bigr).\n \\]\n\\end{lemma}\n\\begin{proof}\n Rewrite each term using the double-residue mod lemma to obtain $\\sum 2^{j+1} \\bmod (2n+1)$, then apply the shift-invariance of the residue sum.\n\\end{proof}\n\n\\begin{lemma}[Core natural number identity]\n \\label{lem:pap_nat_identity}\n \\lean{nat_identity}\n \\uses{lem:pap_sum_two_mul_residue, lem:pap_sum_two_mul_residue_lhs, lem:pap_sum_quotient_eq_b, lem:pap_sum_two_mul_mod_eq_sum_residue}\n For $n > 0$,\n \\[\n (2n+1) \\cdot b(n+1) = \\sum_{j=0}^{a(n)-1} \\bigl(2^j \\bmod (2n+1)\\bigr).\n \\]\n\\end{lemma}\n\\begin{proof}\n Set $S = \\sum_{j} r_j$ where $r_j = 2^j \\bmod (2n+1)$. The summed division algorithm gives $2S = (2n+1) \\cdot b(n+1) + S$. Subtracting $S$ from both sides yields the identity.\n\\end{proof}\n\n\\begin{theorem}[Smallest period divisor identity]\n \\label{thm:pap_smallest_period_div}\n \\lean{smallest_period_div}\n \\uses{lem:pap_nat_identity}\n For $n > 0$,\n \\[\n \\bigl(b(n+1) : \\mathbb{R}\\bigr)\n = (2n+1)^{-1} \\cdot \\sum_{j=0}^{a(n)-1} \\bigl(2^j \\bmod (2n+1)\\bigr),\n \\]\n where $a(n) = A002326(n) = \\inf\\{m > 0 : (2n+1) \\mid 2^m - 1\\}$ and $b = A179382$.\n\\end{theorem}\n\\begin{proof}\n From the core natural number identity, $(2n+1) \\cdot b(n+1) = \\sum r_j$ in $\\mathbb{N}$. Cast to $\\mathbb{R}$, then divide both sides by the nonzero value $(2n+1 : \\mathbb{R})$ using the real cast non-zero lemma.\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem smallest_period_div {n : ℕ} (hn : 0 < n) :\n (↑(b (n + 1)) : ℝ) = (2 * n + 1 : ℝ)⁻¹ * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := by sorry"} -{"project_name": "RamanujanNagellEquation", "name": "ramanujan_nagell", "type": "theorem", "title": "Ramanujan–Nagell equation", "informal_statement": "TODO", "informal_proof": "\\chapter{Ramanujan–Nagell equation}\n\nThis section contains a (stub of a) proof of the Ramanujan–Nagell equation.\nSee \\url{https://en.wikipedia.org/wiki/Ramanujan%E2%80%93Nagell_equation} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Ramanujan–Nagell equation]\n \\label{thm:ramanujan-nagell-equation}\n \\lean{ramanujan_nagell}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat Set\n\n\ntheorem ramanujan_nagell (n : ℕ) (hn : 3 ≤ n):\n (∃ x, 2 ^ n - 7 = x ^ 2) ↔ n ∈ ({3, 4, 5, 7, 15} : Set ℕ) := by sorry"} -{"project_name": "RiemannSeries", "name": "riemann_summation_atbot", "type": "theorem", "title": "Riemann series theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Riemann series theorem}\n\nThis section contains a (stub of a) proof of the Riemann series theorem.\nSee \\url{https://en.wikipedia.org/wiki/Riemann_series_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Riemann series theorem]\n \\label{thm:riemann-series}\n \\lean{riemann_summation_atbot}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Filter Function Topology\n\n\ntheorem riemann_summation_atbot {a : ℕ → ℝ}\n (h : convergentSeries a) (h' : ¬ convergentSeries (fun n ↦ |a n|)) :\n ∃ p : ℕ → ℕ, Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop atBot := sorry"} -{"project_name": "RisingSunLemma", "name": "risingsun", "type": "theorem", "title": "Rising Sun Lemma", "informal_statement": "Let $a < b$ be real numbers and let $g : \\mathbb{R} \\to \\mathbb{R}$ be continuous. With $S(a,b,g)$ and $E(a,b,g)$ as defined above, there exists $k : \\mathbb{N} \\to \\mathbb{R} \\times \\mathbb{R}$ such that for all $i \\ne j$:\n \\begin{enumerate}\n \\item The intervals $(k(i)_1, k(i)_2)$ and $(k(j)_1, k(j)_2)$ are disjoint.\n \\item $E(a,b,g) = \\bigcup_n (k(n)_1, k(n)_2)$.\n \\item For each $n$, if $k(n)_1 \\ne a$ then $g(k(n)_1) = g(k(n)_2)$.\n \\item For each $n$, if $k(n)_1 = a$ and $a \\in S(a,b,g)$ then $g(a) < g(k(n)_2)$.\n \\item For each $n$ and $x \\in (k(n)_1, k(n)_2)$, $g(x) < g(k(n)_2)$.\n \\end{enumerate}", "informal_proof": "\\chapter{Rising Sun Lemma}\n\nThis section contains a proof of the Rising Sun Lemma.\nSee \\url{https://en.wikipedia.org/wiki/Rising_sun_lemma} for more details.\n\n\\begin{definition}[Shadow set S]\n \\label{def:S_def}\n \\lean{S}\n For real numbers $a < b$ and a function $g : \\mathbb{R} \\to \\mathbb{R}$, define\n \\[\n S(a,b,g) = \\{ x \\in [a,b] \\mid \\exists\\, y \\in [a,b],\\; x < y \\text{ and } g(x) < g(y) \\}.\n \\]\n\\end{definition}\n\n\\begin{definition}[Rising set E]\n \\label{def:E_def}\n \\lean{E}\n \\uses{def:S_def}\n Define $E(a,b,g) = (a,b) \\cap S(a,b,g)$, the set of points in the open interval $(a,b)$ that are ``shadowed'' from the right.\n\\end{definition}\n\n\\begin{lemma}[E is a subset of the open interval]\n \\label{lem:E_subset_Ioo}\n \\lean{E_subset_Ioo}\n \\uses{def:E_def}\n $E(a,b,g) \\subseteq (a,b)$.\n\\end{lemma}\n\\begin{proof}\n Immediate from the definition $E = (a,b) \\cap S(a,b,g) \\subseteq (a,b)$.\n\\end{proof}\n\n\\begin{lemma}[Witness for membership in E]\n \\label{lem:E_mem_witness}\n \\lean{E_mem_witness}\n \\uses{def:E_def}\n If $x \\in E(a,b,g)$ then there exists $y \\in [a,b]$ with $x < y$ and $g(x) < g(y)$.\n\\end{lemma}\n\\begin{proof}\n Direct from the definition: $x \\in E$ means $x \\in (a,b)$ and $x \\in S$, and $x \\in S$ gives the desired witness $y$.\n\\end{proof}\n\n\\begin{lemma}[E is open]\n \\label{lem:E_isOpen}\n \\lean{E_isOpen}\n \\uses{def:E_def, lem:E_subset_Ioo}\n If $g$ is continuous and $a < b$, then $E(a,b,g)$ is open.\n\\end{lemma}\n\\begin{proof}\n We write $E = \\bigcup_{y \\in [a,b]} \\bigl((a,y) \\cap \\{x \\mid g(x) < g(y)\\}\\bigr)$.\n Each set $(a,y)$ is open and each preimage $\\{x \\mid g(x) < g(y)\\}$ is open by continuity of $g$.\n A union of open sets is open.\n\\end{proof}\n\n\\begin{lemma}[Nonempty open preconnected bounded subset of R is an open interval]\n \\label{lem:open_preconnected_subset_Ioo_eq_Ioo}\n \\lean{open_preconnected_subset_Ioo_eq_Ioo}\n If $C \\subseteq (a,b)$ is nonempty, open, and preconnected, then $C = (\\inf C, \\sup C)$.\n\\end{lemma}\n\\begin{proof}\n Since $C \\subseteq (a,b)$, it is bounded above and below.\n The set $C$ is connected, hence order-connected, so it contains the open interval $(\\inf C, \\sup C)$.\n For the reverse inclusion, if $\\inf C \\in C$ then openness gives a point of $C$ strictly below $\\inf C$, a contradiction; likewise $\\sup C \\notin C$.\n Thus $C = (\\inf C, \\sup C)$.\n\\end{proof}\n\n\\begin{lemma}[Infimum of a component is at least a]\n \\label{lem:component_sInf_ge}\n \\lean{component_sInf_ge}\n \\uses{lem:E_subset_Ioo}\n If $C$ is nonempty and $C \\subseteq E(a,b,g)$, then $a \\le \\inf C$.\n\\end{lemma}\n\\begin{proof}\n Every element of $C$ is in $E \\subseteq (a,b)$, so every element exceeds $a$. Hence $a \\le \\inf C$.\n\\end{proof}\n\n\\begin{lemma}[Supremum of a component is at most b]\n \\label{lem:component_sSup_le}\n \\lean{component_sSup_le}\n \\uses{lem:E_subset_Ioo}\n If $C$ is nonempty and $C \\subseteq E(a,b,g)$, then $\\sup C \\le b$.\n\\end{lemma}\n\\begin{proof}\n Every element of $C$ is in $E \\subseteq (a,b)$, so every element is less than $b$. Hence $\\sup C \\le b$.\n\\end{proof}\n\n\\begin{lemma}[Infimum strictly less than supremum for nonempty open preconnected bounded set]\n \\label{lem:component_sInf_lt_sSup}\n \\lean{component_sInf_lt_sSup}\n If $C \\subseteq (a,b)$ is nonempty, open, and preconnected, then $\\inf C < \\sup C$.\n\\end{lemma}\n\\begin{proof}\n Take $x \\in C$. Since $C$ is open, there is an interval $(l,u) \\ni x$ contained in $C$.\n Pick $y \\in (x,u) \\subset C$ and $z \\in (l,x) \\subset C$.\n Then $\\inf C \\le z < y \\le \\sup C$, giving $\\inf C < \\sup C$.\n\\end{proof}\n\n\\begin{lemma}[Components of E are countable]\n \\label{lem:E_components_countable}\n \\lean{E_components_countable}\n \\uses{lem:E_isOpen}\n The collection of distinct nonempty connected components of $E(a,b,g)$ is countable.\n\\end{lemma}\n\\begin{proof}\n The components are pairwise disjoint (distinct connected components are disjoint) and each is open and nonempty.\n Such a family in the separable space $\\mathbb{R}$ is countable.\n\\end{proof}\n\n\\begin{lemma}[E equals the union of its connected components]\n \\label{lem:E_eq_iUnion_connectedComponents}\n \\lean{E_eq_iUnion_connectedComponents}\n $E(a,b,g) = \\bigcup_{x \\in E} \\mathrm{connectedComponentIn}(E(a,b,g), x)$.\n\\end{lemma}\n\\begin{proof}\n Every $x \\in E$ belongs to its own connected component, and every connected component is a subset of $E$.\n\\end{proof}\n\n\\begin{lemma}[Right endpoint is not in E]\n \\label{lem:right_endpoint_not_in_E}\n \\lean{right_endpoint_not_in_E}\n \\uses{lem:E_isOpen}\n Let $(c,d)$ be a connected component of $E(a,b,g)$ with $a \\le c$, $d \\le b$. Then $d \\notin E(a,b,g)$.\n\\end{lemma}\n\\begin{proof}\n Suppose $d \\in E$. Since $E$ is open (Lemma~\\ref{lem:E_isOpen}), the connected component of $d$ in $E$ is an open neighborhood of $d$.\n Then the component of any point $m \\in (c,d)$ near $d$ would equal the component of $d$, placing $d$ inside the open interval $(c,d)$—a contradiction since $d \\notin (c,d)$.\n\\end{proof}\n\n\\begin{lemma}[Right endpoint is not in S when d < b]\n \\label{lem:right_endpoint_not_in_S}\n \\lean{right_endpoint_not_in_S}\n \\uses{lem:right_endpoint_not_in_E, lem:E_subset_Ioo}\n Under the same hypotheses, if $d < b$, then for all $y \\in [a,b]$ with $d < y$, $g(d) \\ge g(y)$.\n\\end{lemma}\n\\begin{proof}\n Since $d \\in (a,b)$ (as $d > c \\ge a$ and $d < b$) and $d \\notin E$ (Lemma~\\ref{lem:right_endpoint_not_in_E}), we have $d \\notin S$.\n So there is no $y > d$ in $[a,b]$ with $g(d) < g(y)$, i.e., $g(d) \\ge g(y)$ for all such $y$.\n\\end{proof}\n\n\\begin{lemma}[Right endpoint dominates to the right]\n \\label{lem:right_endpoint_dominates}\n \\lean{right_endpoint_dominates}\n \\uses{lem:right_endpoint_not_in_S}\n Under the same hypotheses, for all $y \\in [d,b]$, $g(d) \\ge g(y)$.\n\\end{lemma}\n\\begin{proof}\n For $y = d$ the inequality is trivial. For $y > d$, if $d < b$ apply Lemma~\\ref{lem:right_endpoint_not_in_S}. If $d = b$ there is no $y \\in [d,b]$ with $y > d$, so the result holds vacuously.\n\\end{proof}\n\n\\begin{lemma}[The maximizer on {[x,d]} is the right endpoint d]\n \\label{lem:maximizer_eq_right_endpoint}\n \\lean{maximizer_eq_right_endpoint}\n \\uses{lem:E_mem_witness, lem:right_endpoint_dominates}\n Let $x \\in (c,d)$ and let $z \\in [x,d]$ be a maximizer of $g$ on $[x,d]$. Then $z = d$.\n\\end{lemma}\n\\begin{proof}\n Suppose $z \\ne d$, so $z < d$. Then $z \\in (c,d) \\subseteq E$, so by Lemma~\\ref{lem:E_mem_witness} there exists $y \\in [a,b]$ with $z < y$ and $g(z) < g(y)$.\n If $y \\le d$, this contradicts $z$ being a maximizer on $[x,d]$ (since $y \\in [z,d] \\subseteq [x,d]$).\n If $y > d$, then $g(d) \\ge g(y) > g(z)$ by Lemma~\\ref{lem:right_endpoint_dominates}, so $g(d) > g(z)$, contradicting maximality at $z$ since $d \\in [x,d]$.\n\\end{proof}\n\n\\begin{lemma}[Property 5: g(x) < g(d) for x in the component]\n \\label{lem:g_lt_g_right_endpoint}\n \\lean{g_lt_g_right_endpoint}\n \\uses{lem:E_mem_witness, lem:maximizer_eq_right_endpoint, lem:right_endpoint_dominates}\n For $x \\in (c,d)$, $g(x) < g(d)$.\n\\end{lemma}\n\\begin{proof}\n Since $x \\in E$, Lemma~\\ref{lem:E_mem_witness} gives $y \\in [a,b]$ with $x < y$ and $g(x) < g(y)$.\n The extreme value theorem gives a maximizer $z \\in [x,d]$ of $g$; by Lemma~\\ref{lem:maximizer_eq_right_endpoint}, $z = d$.\n If $y \\le d$: $g(x) < g(y) \\le g(d)$.\n If $y > d$: $g(x) < g(y) \\le g(d)$ by Lemma~\\ref{lem:right_endpoint_dominates}.\n In both cases $g(x) < g(d)$.\n\\end{proof}\n\n\\begin{lemma}[Left endpoint is not in E]\n \\label{lem:left_endpoint_not_in_E}\n \\lean{left_endpoint_not_in_E}\n \\uses{lem:E_isOpen}\n Under the same component hypotheses, $c \\notin E(a,b,g)$.\n\\end{lemma}\n\\begin{proof}\n Suppose $c \\in E$. Since $E$ is open (Lemma~\\ref{lem:E_isOpen}), the connected component of $c$ contains an open neighborhood of $c$.\n A point $m \\in (c, c+\\varepsilon)$ in that neighborhood would share the same component as $c$, so the component of $m$ (which equals $(c,d)$) would contain $c$—but $c \\notin (c,d)$, a contradiction.\n\\end{proof}\n\n\\begin{lemma}[Left endpoint not in S implies dominance]\n \\label{lem:left_not_in_S_imp_ge}\n \\lean{left_not_in_S_imp_ge}\n \\uses{lem:E_subset_Ioo}\n If $c \\ne a$ and $c \\notin E$, then for all $y \\in [a,b]$ with $c < y$, $g(c) \\ge g(y)$.\n\\end{lemma}\n\\begin{proof}\n Since $c \\ne a$ and $c \\in (a, b)$ (as $a \\le c < d \\le b$ and $c \\ne a$), if $c \\notin E$ then $c \\notin S$.\n So there is no $y > c$ in $[a,b]$ with $g(c) < g(y)$, giving $g(c) \\ge g(y)$ for all such $y$.\n\\end{proof}\n\n\\begin{lemma}[g(c) is at least g(d) when c is not a]\n \\label{lem:g_left_ge_g_right}\n \\lean{g_left_ge_g_right}\n \\uses{lem:left_not_in_S_imp_ge}\n If $c \\ne a$ and $c \\notin E$, then $g(c) \\ge g(d)$.\n\\end{lemma}\n\\begin{proof}\n Apply Lemma~\\ref{lem:left_not_in_S_imp_ge} with $y = d \\in [a,b]$ and $c < d$.\n\\end{proof}\n\n\\begin{lemma}[g(c) is at most g(d) by continuity]\n \\label{lem:g_left_le_g_right}\n \\lean{g_left_le_g_right}\n \\uses{lem:g_lt_g_right_endpoint}\n $g(c) \\le g(d)$.\n\\end{lemma}\n\\begin{proof}\n By Lemma~\\ref{lem:g_lt_g_right_endpoint}, $g(x) < g(d)$ for all $x \\in (c,d)$.\n By continuity of $g$ at $c$ and the right-limit, $g(c) = \\lim_{x \\to c^+} g(x) \\le g(d)$.\n\\end{proof}\n\n\\begin{lemma}[Property 3: g(c) = g(d) when c is not a]\n \\label{lem:left_ne_a_imp_g_eq}\n \\lean{left_ne_a_imp_g_eq}\n \\uses{lem:left_endpoint_not_in_E, lem:g_left_le_g_right, lem:g_left_ge_g_right}\n If $c \\ne a$, then $g(c) = g(d)$.\n\\end{lemma}\n\\begin{proof}\n By Lemma~\\ref{lem:left_endpoint_not_in_E}, $c \\notin E$.\n By Lemma~\\ref{lem:g_left_ge_g_right}, $g(c) \\ge g(d)$.\n By Lemma~\\ref{lem:g_left_le_g_right}, $g(c) \\le g(d)$.\n Therefore $g(c) = g(d)$.\n\\end{proof}\n\n\\begin{lemma}[g(a) is at most g(d) by continuity from the right]\n \\label{lem:g_a_le_g_right}\n \\lean{g_a_le_g_right}\n \\uses{lem:g_lt_g_right_endpoint}\n If $c = a$, then $g(a) \\le g(d)$.\n\\end{lemma}\n\\begin{proof}\n For all $x \\in (a,d) = (c,d)$, $g(x) < g(d)$ by Lemma~\\ref{lem:g_lt_g_right_endpoint}.\n By continuity of $g$ at $a$ and the right-limit, $g(a) \\le g(d)$.\n\\end{proof}\n\n\\begin{lemma}[Property 4: g(a) < g(d) when c = a and a is in S]\n \\label{lem:left_eq_a_imp_g_lt}\n \\lean{left_eq_a_imp_g_lt}\n \\uses{lem:g_lt_g_right_endpoint, lem:g_a_le_g_right, lem:right_endpoint_dominates}\n If $c = a$ and $a \\in S(a,b,g)$, then $g(a) < g(d)$.\n\\end{lemma}\n\\begin{proof}\n Since $a \\in S$, there exists $y \\in [a,b]$ with $a < y$ and $g(a) < g(y)$.\n By Lemma~\\ref{lem:g_a_le_g_right}, $g(a) \\le g(d)$.\n For strict inequality: if $y \\le d$, then either $y = d$ giving $g(a) < g(d)$ directly, or $y \\in (a,d) = (c,d)$ giving $g(a) < g(y) < g(d)$ by Lemma~\\ref{lem:g_lt_g_right_endpoint}.\n If $y > d$, then $g(d) \\ge g(y) > g(a)$ by Lemma~\\ref{lem:right_endpoint_dominates}.\n\\end{proof}\n\n\\begin{lemma}[Build the collection of component intervals]\n \\label{lem:build_component_intervals}\n \\lean{build_component_intervals}\n \\uses{lem:E_isOpen, lem:open_preconnected_subset_Ioo_eq_Ioo, lem:component_sInf_ge, lem:component_sSup_le, lem:component_sInf_lt_sSup, lem:E_components_countable, lem:E_subset_Ioo, lem:E_eq_iUnion_connectedComponents}\n There exists a countable set $I \\subseteq \\mathbb{R} \\times \\mathbb{R}$ of pairs $(c,d)$ with $a \\le c < d \\le b$, such that the intervals $(c,d)$ are pairwise disjoint, their union equals $E(a,b,g)$, each interval $(c,d) \\subseteq E(a,b,g)$, and for each $x \\in (c,d)$, the connected component of $x$ in $E$ equals $(c,d)$.\n\\end{lemma}\n\\begin{proof}\n For each point $x \\in E$, its connected component $C_x = \\mathrm{connectedComponentIn}(E, x)$ is nonempty, open, preconnected, and contained in $(a,b)$ (Lemma~\\ref{lem:E_subset_Ioo}).\n By Lemma~\\ref{lem:open_preconnected_subset_Ioo_eq_Ioo}, $C_x = (\\inf C_x, \\sup C_x)$.\n The infimum is $\\ge a$ (Lemma~\\ref{lem:component_sInf_ge}), the supremum is $\\le b$ (Lemma~\\ref{lem:component_sSup_le}), and $\\inf C_x < \\sup C_x$ (Lemma~\\ref{lem:component_sInf_lt_sSup}).\n Setting $I = \\{(\\inf C_x, \\sup C_x) \\mid x \\in E\\}$, pairwise disjointness follows from distinct components being disjoint, the union property from Lemma~\\ref{lem:E_eq_iUnion_connectedComponents}, and countability from Lemma~\\ref{lem:E_components_countable}.\n\\end{proof}\n\n\\begin{lemma}[Assemble the enumeration from the component collection]\n \\label{lem:risingsun_of_components}\n \\lean{risingsun_of_components}\n \\uses{lem:build_component_intervals}\n Given a countable pairwise-disjoint collection $I$ of intervals covering $E$, satisfying Properties 3, 4, and 5, there exists $k : \\mathbb{N} \\to \\mathbb{R} \\times \\mathbb{R}$ enumerating the intervals (with degenerate pairs for unused indices) satisfying all five properties of the Rising Sun Lemma.\n\\end{lemma}\n\\begin{proof}\n Since $I$ is countable, it is encodable. Define $k(n)$ to be the $n$-th element of $I$ under the encoding, or the default pair $(a+1, a+1)$ for indices without a preimage.\n Degenerate pairs produce empty intervals, so pairwise disjointness, the union, and the three properties are verified by case analysis on whether $k(n)$ comes from $I$ or is the default.\n\\end{proof}\n\n\\begin{theorem}[Rising Sun Lemma]\n \\label{thm:risingsun}\n \\lean{risingsun}\n \\uses{lem:build_component_intervals, lem:risingsun_of_components, lem:left_ne_a_imp_g_eq, lem:left_eq_a_imp_g_lt, lem:g_lt_g_right_endpoint}\n Let $a < b$ be real numbers and let $g : \\mathbb{R} \\to \\mathbb{R}$ be continuous. With $S(a,b,g)$ and $E(a,b,g)$ as defined above, there exists $k : \\mathbb{N} \\to \\mathbb{R} \\times \\mathbb{R}$ such that for all $i \\ne j$:\n \\begin{enumerate}\n \\item The intervals $(k(i)_1, k(i)_2)$ and $(k(j)_1, k(j)_2)$ are disjoint.\n \\item $E(a,b,g) = \\bigcup_n (k(n)_1, k(n)_2)$.\n \\item For each $n$, if $k(n)_1 \\ne a$ then $g(k(n)_1) = g(k(n)_2)$.\n \\item For each $n$, if $k(n)_1 = a$ and $a \\in S(a,b,g)$ then $g(a) < g(k(n)_2)$.\n \\item For each $n$ and $x \\in (k(n)_1, k(n)_2)$, $g(x) < g(k(n)_2)$.\n \\end{enumerate}\n\\end{theorem}\n\\begin{proof}\n Build the collection $I$ of component intervals using Lemma~\\ref{lem:build_component_intervals}.\n Property 3 for each component $(c,d) \\in I$ with $c \\ne a$ follows from Lemma~\\ref{lem:left_ne_a_imp_g_eq}.\n Property 4 for components with $c = a$ follows from Lemma~\\ref{lem:left_eq_a_imp_g_lt}.\n Property 5 for each $x \\in (c,d)$ follows from Lemma~\\ref{lem:g_lt_g_right_endpoint}.\n Assemble the enumeration $k$ using Lemma~\\ref{lem:risingsun_of_components}.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set TopologicalSpace Real\n\n\ntheorem risingsun {a b : ℝ} (ab : a < b) {g : ℝ → ℝ} (hg : Continuous g) :\n ∃ k : ℕ → ℝ × ℝ, ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅\n ∧ E a b g = ⋃ n : ℕ, Ioo (k n).1 (k n).2\n ∧ (∀ n : ℕ, (k n).1 ≠ a → g (k n).1 = g (k n).2)\n ∧ (∀ n : ℕ, (k n).1 = a → a ∈ Shadow a b g → g a < g (k n).2)\n ∧ (∀ n : ℕ, ∀ x : ℝ, x ∈ Ioo (k n).1 (k n).2 → g x < g (k n).2) := by sorry"} -{"project_name": "RobinTheorem", "name": "robin", "type": "theorem", "title": "Robin's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Robin's theorem}\n\nThis section contains a (stub of a) proof of Robin's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Divisor_function} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Robin's theorem]\n \\label{thm:robin-theorem}\n \\lean{robin}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen ArithmeticFunction.sigma Real\n\n\ntheorem robin : RiemannHypothesis ↔ ∀ n > 5040,\n σ 1 n < exp (eulerMascheroniConstant) * n * log (log n) := by sorry"} -{"project_name": "RothTheorem", "name": "roth", "type": "theorem", "title": "Roth's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Roth's theorem}\n\nThis section contains a (stub of a) proof of Roth's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Roth%27s_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Roth's theorem]\n \\label{thm:roth-theorem}\n \\lean{roth}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen ENNReal Set\n\n\ntheorem roth {x : ℝ} (hx_irr : Irrational x) (hx_alg : IsAlgebraic ℚ x) :\n IrrationalityMeasure x = 2 := sorry"} -{"project_name": "RoucheCapelli", "name": "rouche_capelli", "type": "theorem", "title": "Rouché--Capelli", "informal_statement": "A system of linear equations $Ax = b$ is consistent (has at least one solution) if and only if\n $\\mathrm{rank}(A) = \\mathrm{rank}([A \\mid b])$.", "informal_proof": "\\chapter{Rouché--Capelli Theorem}\n\nThis section contains a proof of the Rouché--Capelli theorem, which characterizes solvability of a linear system $Ax = b$ in terms of matrix ranks.\nSee \\url{https://en.wikipedia.org/wiki/Rouch\\%C3\\%A9\\%E2\\%80\\%93Capelli_theorem} for background.\n\n\\begin{definition}[System of Linear Equations]\n \\label{def:SystemOfLinearEquations}\n \\lean{SystemOfLinearEquations}\n A system of $m$ linear equations in $n$ unknowns is a pair $(A, b)$ where $A$ is an $m \\times n$\n coefficient matrix over a field $K$ and $b : \\mathrm{Fin}\\,m \\to K$ is the constant vector.\n\\end{definition}\n\n\\begin{definition}[Augmented Matrix]\n \\label{def:AugmentedMatrix}\n \\lean{AugmentedMatrix}\n \\uses{def:SystemOfLinearEquations}\n For a system $(A, b)$, the augmented matrix $[A \\mid b]$ is the $m \\times (n+1)$ matrix whose\n first $n$ columns are those of $A$ and whose last column is $b$.\n\\end{definition}\n\n\\begin{definition}[Column Space]\n \\label{def:ColumnSpace}\n \\lean{ColumnSpace}\n The column space of an $m \\times n$ matrix $A$ over a field $K$ is the submodule\n $\\mathrm{span}_K\\bigl(\\mathrm{range}(\\lambda j.\\,A^T j)\\bigr)$ of $K^m$.\n\\end{definition}\n\n\\begin{definition}[Matrix Rank]\n \\label{def:MatrixRank}\n \\lean{MatrixRank}\n \\uses{def:ColumnSpace}\n The rank of a matrix $A$ is the $K$-dimension of its column space:\n $\\mathrm{rank}(A) = \\mathrm{finrank}_K(\\mathrm{ColumnSpace}(A))$.\n\\end{definition}\n\n\\begin{lemma}[mulVec as Linear Combination]\n \\label{lem:mulVec_as_linear_combination}\n \\lean{mulVec_as_linear_combination}\n For any matrix $A$ and vector $x$, the matrix-vector product $A \\cdot x$ equals\n $\\sum_{j} x_j \\cdot A^T j$, i.e.\\ scalar multiples of the transpose rows.\n\\end{lemma}\n\\begin{proof}\n Rewrite the matrix vector multiplication as a sum and observe that\n $\\mathrm{MulOpposite.op}(x_j) \\cdot A^T j = x_j \\cdot A^T j$\n because $K$ is a commutative field.\n\\end{proof}\n\n\\begin{lemma}[Solvability as Column Space Membership]\n \\label{lem:solvability_as_column_space_membership}\n \\lean{solvability_as_column_space_membership}\n \\uses{def:ColumnSpace, lem:mulVec_as_linear_combination}\n The system $Ax = b$ has a solution if and only if $b \\in \\mathrm{ColumnSpace}(A)$.\n\\end{lemma}\n\\begin{proof}\n Apply the fact that an element lies in the span iff it can be written as sum over that span.\n which gives $b \\in \\mathrm{span}_K(\\mathrm{range}(A^T))$ iff there exist coefficients\n $c_j$ with $\\sum_j c_j \\cdot A^T j = b$. Both directions then follow from\n Lemma~\\ref{lem:mulVec_as_linear_combination} identifying $A \\cdot x$ with $\\sum_j x_j \\cdot A^T j$.\n\\end{proof}\n\n\\begin{lemma}[Augmented Range Subset]\n \\label{lem:augmented_range_subset}\n \\lean{augmented_range_subset}\n \\uses{def:AugmentedMatrix, def:SystemOfLinearEquations}\n The range of the transpose columns of the augmented matrix is contained in\n the range of the transpose columns of $A$ union $\\{b\\}$.\n\\end{lemma}\n\\begin{proof}\n Every column of $[A \\mid b]^T$ is either a column of $A^T$ (for non-last indices) or equals $b$.\n Apply \\texttt{Fin.lastCases} to split on these two cases.\n\\end{proof}\n\n\\begin{lemma}[Augmented Range Superset]\n \\label{lem:augmented_range_superset}\n \\lean{augmented_range_superset}\n \\uses{def:AugmentedMatrix, def:SystemOfLinearEquations}\n The range of transpose columns of $A$ union $\\{b\\}$ is contained in\n the range of transpose columns of the augmented matrix.\n\\end{lemma}\n\\begin{proof}\n Each column of $A$ appears in $[A \\mid b]^T$ at a cast index, and $b$ appears at the last index.\n\\end{proof}\n\n\\begin{lemma}[Augmented Column Space Equality]\n \\label{lem:augmented_column_space_eq}\n \\lean{augmented_column_space_eq}\n \\uses{def:ColumnSpace, def:AugmentedMatrix, def:SystemOfLinearEquations, lem:augmented_range_subset, lem:augmented_range_superset}\n The column space of the augmented matrix equals\n $\\mathrm{span}_K\\bigl(\\mathrm{range}(A^T) \\cup \\{b\\}\\bigr)$.\n\\end{lemma}\n\\begin{proof}\n By \\texttt{Submodule.span\\_mono} applied to Lemma~\\ref{lem:augmented_range_subset} and\n Lemma~\\ref{lem:augmented_range_superset}, the two spans are each contained in the other,\n so they are equal by antisymmetry.\n\\end{proof}\n\n\\begin{lemma}[Column Space Monotone under Augmentation]\n \\label{lem:column_space_le_augmented}\n \\lean{column_space_le_augmented}\n \\uses{def:ColumnSpace, def:AugmentedMatrix, def:SystemOfLinearEquations}\n The column space of $A$ is a subspace of the column space of the augmented matrix:\n $\\mathrm{ColumnSpace}(A) \\le \\mathrm{ColumnSpace}([A \\mid b])$.\n\\end{lemma}\n\\begin{proof}\n Apply \\texttt{Submodule.span\\_mono}: every generator $A^T j$ of $\\mathrm{ColumnSpace}(A)$\n appears as $([A \\mid b])^T(\\mathrm{castSucc}(j))$,\n so the generator set is included.\n\\end{proof}\n\n\\begin{lemma}[b Lies in Augmented Column Space]\n \\label{lem:b_mem_augmented_column_space}\n \\lean{b_mem_augmented_column_space}\n \\uses{def:ColumnSpace, def:AugmentedMatrix, def:SystemOfLinearEquations}\n The vector $b$ belongs to the column space of the augmented matrix.\n\\end{lemma}\n\\begin{proof}\n We have $b = ([A \\mid b])^T(\\mathrm{last}\\,n)$,\n so $b$ lies in the range of the transpose columns of $[A \\mid b]$ and hence in\n $\\mathrm{ColumnSpace}([A \\mid b])$ by \\texttt{Submodule.subset\\_span}.\n\\end{proof}\n\n\\begin{lemma}[Column Space of Augmented Matrix when b in ColumnSpace A]\n \\label{lem:column_space_augmented_of_mem}\n \\lean{column_space_augmented_of_mem}\n \\uses{def:ColumnSpace, def:AugmentedMatrix, def:SystemOfLinearEquations, lem:augmented_column_space_eq}\n If $b \\in \\mathrm{ColumnSpace}(A)$, then $\\mathrm{ColumnSpace}([A \\mid b]) = \\mathrm{ColumnSpace}(A)$.\n\\end{lemma}\n\\begin{proof}\n By Lemma~\\ref{lem:augmented_column_space_eq},\n $\\mathrm{ColumnSpace}([A \\mid b]) = \\mathrm{span}_K(\\mathrm{range}(A^T) \\cup \\{b\\})$.\n Since $b \\in \\mathrm{ColumnSpace}(A) = \\mathrm{span}_K(\\mathrm{range}(A^T))$,\n The fact that adding an element of the span does not increase the span gives\n $\\mathrm{span}_K(\\mathrm{range}(A^T) \\cup \\{b\\}) = \\mathrm{span}_K(\\mathrm{range}(A^T)) = \\mathrm{ColumnSpace}(A)$.\n\\end{proof}\n\n\\begin{lemma}[Rank Equality from Column Space Membership (Forward)]\n \\label{lem:rank_eq_of_mem_column_space}\n \\lean{rank_eq_of_mem_column_space}\n \\uses{def:MatrixRank, lem:column_space_augmented_of_mem}\n If $b \\in \\mathrm{ColumnSpace}(A)$, then $\\mathrm{rank}(A) = \\mathrm{rank}([A \\mid b])$.\n\\end{lemma}\n\\begin{proof}\n Apply Lemma~\\ref{lem:column_space_augmented_of_mem}:\n since $\\mathrm{ColumnSpace}([A \\mid b]) = \\mathrm{ColumnSpace}(A)$, their finranks are equal.\n\\end{proof}\n\n\\begin{lemma}[Column Space Equality from Rank Equality]\n \\label{lem:column_space_eq_of_rank_eq}\n \\lean{column_space_eq_of_rank_eq}\n \\uses{def:MatrixRank, lem:column_space_le_augmented}\n If $\\mathrm{rank}(A) = \\mathrm{rank}([A \\mid b])$, then $\\mathrm{ColumnSpace}(A) = \\mathrm{ColumnSpace}([A \\mid b])$.\n\\end{lemma}\n\\begin{proof}\n By Lemma~\\ref{lem:column_space_le_augmented} and the equal finranks these are equal.\n\\end{proof}\n\n\\begin{lemma}[Column Space Membership from Rank Equality (Backward)]\n \\label{lem:mem_column_space_of_rank_eq}\n \\lean{mem_column_space_of_rank_eq}\n \\uses{lem:column_space_eq_of_rank_eq, lem:b_mem_augmented_column_space}\n If $\\mathrm{rank}(A) = \\mathrm{rank}([A \\mid b])$, then $b \\in \\mathrm{ColumnSpace}(A)$.\n\\end{lemma}\n\\begin{proof}\n By Lemma~\\ref{lem:column_space_eq_of_rank_eq}, $\\mathrm{ColumnSpace}(A) = \\mathrm{ColumnSpace}([A \\mid b])$.\n By Lemma~\\ref{lem:b_mem_augmented_column_space}, $b \\in \\mathrm{ColumnSpace}([A \\mid b])$,\n so $b \\in \\mathrm{ColumnSpace}(A)$ after rewriting.\n\\end{proof}\n\n\\begin{lemma}[Rank Equality Condition]\n \\label{lem:rank_equality_condition}\n \\lean{rank_equality_condition}\n \\uses{lem:rank_eq_of_mem_column_space, lem:mem_column_space_of_rank_eq}\n $b \\in \\mathrm{ColumnSpace}(A)$ if and only if $\\mathrm{rank}(A) = \\mathrm{rank}([A \\mid b])$.\n\\end{lemma}\n\\begin{proof}\n This follows from Lemma~\\ref{lem:rank_eq_of_mem_column_space} (forward direction) and\n Lemma~\\ref{lem:mem_column_space_of_rank_eq} (backward direction).\n\\end{proof}\n\n\\begin{theorem}[Rouché--Capelli]\n \\label{thm:rouche_capelli}\n \\lean{rouche_capelli}\n \\uses{lem:solvability_as_column_space_membership, lem:rank_equality_condition}\n A system of linear equations $Ax = b$ is consistent (has at least one solution) if and only if\n $\\mathrm{rank}(A) = \\mathrm{rank}([A \\mid b])$.\n\\end{theorem}\n\\begin{proof}\n Chain the two equivalences:\n \\begin{align*}\n (\\exists x,\\, Ax = b)\n &\\iff b \\in \\mathrm{ColumnSpace}(A)\n && \\text{(Lemma~\\ref{lem:solvability_as_column_space_membership})} \\\\\n &\\iff \\mathrm{rank}(A) = \\mathrm{rank}([A \\mid b])\n && \\text{(Lemma~\\ref{lem:rank_equality_condition})}\n \\end{align*}\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Matrix\n\nopen Submodule\n\n\ntheorem rouche_capelli {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n (∃ x : Fin n → K, sys.A.mulVec x = sys.b) ↔\n MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := sorry"} -{"project_name": "SchauderFixedPointTheorem", "name": "SchauderFixedPointTheorem", "type": "theorem", "title": "Schauder fixed-point theorem", "informal_statement": "If $C$ is a nonempty convex compact subset of a locally\nconvex Hausdorff topological vector space $E$ over $\\mathbb{R}$, and $f : E \\to E$ is continuous with\n$f(C) \\subseteq C$, then $f$ has a fixed point in $C$. -/", "informal_proof": "\\chapter{Schauder fixed-point theorem}\n\nThis section contains a proof of Schauder's fixed-point theorem.\nSee \\url{https://en.wikipedia.org/wiki/Schauder_fixed-point_theorem} for more details.\n\n\\begin{theorem}\n \\label{thm:SchauderFixedPointTheorem}\n \\lean{SchauderFixedPointTheorem}\n If $C$ is a nonempty convex compact subset of a locally\nconvex Hausdorff topological vector space $E$ over $\\mathbb{R}$, and $f : E \\to E$ is continuous with\n$f(C) \\subseteq C$, then $f$ has a fixed point in $C$. -/\n\\end{theorem}\n\\begin{proof}\n For any $\\epsilon > 0$, notice that the family of open sets\n $\\{B_{\\epsilon}(x) : x \\in C\\}$\n is an open covering of $C$. Because $C$ is compact, there exists $n \\in \\mathbb{N}$ and $x_1, \\dots, x_n \\in C$ such that $K$ is covered by $B_{\\epsilon}(x_i)$, $i = 1, \\dots, n$.\n For each $i$, define $g_i(x)$ to be\n $\\epsilon - ||x - x_i||$ if $||x - x_i|| \\leq \\epsilon$, else $0$.\n Then each $g_i$ is continuous, $g_i(x) \\geq 0$, and $\\sum_{i=1}^n g_i(x)> 0$ for every $x \\in C$.\n We define a function\n $g(x) = \\frac{\\sum_{i=1}^n g_i(x) x_i}{\\sum_{i=1}^n g_i(x)}$.\n $g$ is then a continuous function from $C$ to the convex hull $C_0$ of $x_1, \\dots, x_n$.\n Also we can see that for any $x \\in C$, $||g(x)-x|| \\leq \\epsilon$.\n Define $B := g \\circ f$. $\\tilde{B} := B | C_0$ is a continuous function $C_0 \\to C_0$.\n Since $C_0$ is a compact convex subset of a finite dimensional vector space,\n we can apply the Brouwer fixed point theorem to get $z \\in C_0$ such that $\\tilde{B} = z$.\n Therefore, $g(f(z))=z$ and so\n $||f(z)-z|| = ||f(z) - g(f(x))|| \\leq \\epsilon$.\n\n Summarizing, for each $\\epsilon > 0$ there exists $z \\in C$ such that $||f(z) - z|| \\leq \\epsilon$.\n\n By compactness, there exists a strictly increasing sequence $m_k \\in \\mathbb{N}$, $k = 1, 2, \\dots$, and a sequence $z_k \\in C$ such that\n $||f(z_k)-z_k|| \\leq 1/m_k$ and $f(z_k) \\to x_0$ for some $x_0 \\in C$.\n Then $z_k \\to x_0$.\n As $f$ is continuous, $f(z_k) \\to f(x_0)$. Therefore, $f(x_0)=x_0$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Set Filter Topology\n\nopen Set in\n\n\ntheorem SchauderFixedPointTheorem\n {E : Type*}\n [AddCommGroup E] [Module ℝ E]\n [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]\n [T2Space E] [LocallyConvexSpace ℝ E]\n {C : Set E} (hne : C.Nonempty) (hconv : Convex ℝ C) (hcpt : IsCompact C)\n {f : E → E} (hf : Continuous f) (hfc : MapsTo f C C) :\n ∃ x ∈ C, f x = x := by sorry"} -{"project_name": "SchurRamsey", "name": "schur", "type": "theorem", "title": "Schur's theorem", "informal_statement": "For any positive integer \\(r\\), there exists a positive integer \\(n_r\\) such that for every \\(r\\)-coloring of the set \\(\\{1, 2, \\ldots, n_r\\}\\), there exist three integers \\(x, y, z\\) of the same color such that \\(x + y = z\\).", "informal_proof": "\\chapter{Schur's theorem}\n\nThis section contains a (stub of a) proof of Schur's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Schur's_theorem} for more details.\n\n\n\\begin{theorem}[Ramsey's theorem for monochromatic triangles]\n \\label{thm:ramsey}\n \\lean{ramsey}\n For any positive integer \\(r\\), there exists a positive integer \\(n_r\\) such that for every \\(r\\)-coloring of the edges of the complete graph \\(K_{n_r}\\), there exists a monochromatic triangle.\n\\end{theorem}\n\n\\begin{proof}\n We proceed by induction on \\(r\\).\n For \\(r = 1\\), we have \\(n_r = 3\\) since a single color will always yield a monochromatic triangle in \\(K_3\\).\n Given $n_r$ such that for every \\(r\\)-coloring of the edges of \\(K_{n_r}\\), there exists a monochromatic triangle, consider \\(n_{r+1} = TODO \\). Let $c$ be an \\((r+1)\\)-coloring of the edges of \\(K_{n_{r+1}}\\).\n Consider an arbitrary vertex $x$ of this graph, and let \\(A_i\\) be the set of vertices connected to this vertex by edges of color \\(i\\) for \\(i = 1, 2, \\ldots, r+1\\).\n There exists an index \\(i\\) such that \\(|A_i| \\geq n_r\\).\n Because otherwise, we would have \\(|A_1| + |A_2| + \\cdots + |A_{r+1}| \\leq (r+1) n_r\\), which contradicts the fact that the total number of vertices is \\((r+1) n_r + 1\\).\n Either\n \\begin{itemize}\n \\item Of the edges between the vertices in \\(A_i\\), at least of them is colored \\(i\\), in which case we have a monochromatic triangle formed by the vertex $x$ and the endpoints of that edge, or\n \\item All the edges between the vertices in \\(A_i\\) are colored with the $n$ colors different from \\(i\\), in which case we have a monochromatic triangle in the subgraph induced by \\(A_i\\) by the induction hypothesis.\n \\end{itemize}\n\\end{proof}\n\n\\begin{theorem}[Schur's theorem]\n \\label{thm:schur}\n \\lean{schur}\n \\uses{thm:ramsey}\n For any positive integer \\(r\\), there exists a positive integer \\(n_r\\) such that for every \\(r\\)-coloring of the set \\(\\{1, 2, \\ldots, n_r\\}\\), there exist three integers \\(x, y, z\\) of the same color such that \\(x + y = z\\).\n\\end{theorem}\n\n\\begin{proof}\n Consider $n_r$ as in the previous theorem. We define $c$ to be an \\(r\\)-coloring of the edge set of the complete graph on \\(\\{1, 2, \\ldots, n_r\\}\\), where the color of the edge \\(\\{x, y\\}\\) is the color of the integer \\(|x - y|\\).\n By the previous theorem, there exist three vertices \\(a < b < c\\) such that the edges \\(\\{a, b\\}\\), \\(\\{b, c\\}\\), and \\(\\{a, c\\}\\) are of the same color.\n This means that the integers \\(x = b - a\\), \\(y = c - b\\), and \\(z = c - a\\) are of the same color, and we have \\((b - a) + (c - b) = c - a\\).\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Setoid Set\n\n\ntheorem schur (n : ℕ) : ∃ S : ℕ, ∀ r : (Icc 1 S) → Fin n,\n ∃ u : Fin n,\n ∃ x y z : Icc 1 S,\n r x = u ∧ r y = u ∧ r z = u ∧ (x : ℕ) + y = z := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sinkhorn_existence", "type": "theorem", "title": "Sinkhorn's theorem", "informal_statement": "Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries. Then there are\n $d_1, d_2 \\in \\mathbb{R}^N$ with all positive entries such that $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ is\n doubly stochastic.", "informal_proof": "\\chapter{Sinkhorn's theorem}\n\nThis section contains a proof of Sinkhorn's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Sinkhorn's_theorem} for more details.\n\n\\begin{theorem}\n \\label{thm:sinkhorn_uniqueness}\n \\lean{sinkhorn_uniqueness}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries. Suppose there are\n $d_1, d_2, d'_1, d'_2 \\in \\mathbb{R}^N$ all have positive entries such that\n $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ and $\\mathrm{diag}(d'_1) * A * \\mathrm{diag}(d'_2)$ are both doubly stochastic.\n Then there is a constant $c > 0$ such that $d'_1 = c * d_1$ and $d'_2 = d_2 / c$.\n\\end{theorem}\n\\begin{proof}\n Let $P = \\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$. Let $b_1 = d_1'/d_1$ and $b_2 = d_2'/d_2$ where division is coordinate-wise. Then both $P$ and $\\mathrm{diag}(b_1) * A * \\mathrm{diag}(b_2)$ are doubly stochastic.\n For each $i$, $1/b_{1i}$ is a convex combination of the entries of $b_2$. So\n \\begin{displaymath}\n \\min(b_2) \\leq 1/b_{1i} \\leq \\max(b_2).\n \\end{displaymath}\n Similarly, for any $j$,\n \\begin{displaymath}\n \\min(b_1) \\leq 1/b_{2j} \\leq \\max(b_1).\n \\end{displaymath}\n Let $\\min(b_1) = b_{1i_0}$ and $\\max(b_2) = b_{2j_0}$. Then we must have $b_{1i_0}b_{2j_0}=1$.\n Again since $1/b_{1i_0}$ is a convex combination of the entries of $b_2$, every $b_{2j}$ must be equal to $b_{2j_0} = 1/b_{1i_0}$. Similarly, every $b_{1i}$ must be equal to $b_{1i_0}$.\n Let $c = b_{11}$. Then $c$ satisfies the conclusion of the lemma.\n\\end{proof}\n\n\\begin{definition}\n \\label{def:RCseq}\n \\lean{RCseq}\n Given an $N \\times N$ matrix $A$ with all positive entries, we define the row-column normalization sequence,\n \\begin{displaymath}\n \\mathrm{RCseq}(A):\\mathbb{N} \\to \\mathbb{R}^N \\times \\mathbb{R}^N,\n \\end{displaymath}\n by recursion.\n \\begin{enumerate}\n \\item $\\mathrm{RCseq}(A)(0) = (1_N, \\mathrm{colSum}(A)^{-1})$, where $1_N = (1, \\dots, 1)$\n denotes the vector with all-one entries, $\\mathrm{colSum}(A)$ denotes the vector consisting\n of all the column sums of $A$, $x^{-1}$ denotes $(x_1^{-1}, \\dots, x_N^{-1})$ for\n $x = (x_1, \\dots, x_N) \\in \\mathbb{R}^N$.\n \\item Suppose that $\\mathrm{RCseq}(A)(n) = (d, e)$ has been defined. Let\n $A' = \\mathrm{diag}(d) * A * \\mathrm{diag}(e)$. Let $d' = \\mathrm{rowSum}(A')^{-1}$ where\n $\\mathrm{rowSum}(A')$ denotes the vector consisting of all the row sums of $A'$. Let\n $e' = \\mathrm{colSum}(\\mathrm{diag}(d') * A')^{-1}$.\n Then $\\mathrm{RCseq}(A)(n+1) = (d' * d, e * e')$, where $*$ denotes pointwise multiplication.\n \\end{enumerate}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:RCseqLeft}\n \\lean{RCseqLeft}\n \\uses{def:RCseq}\n For $n \\in \\mathbb{N}$, $\\mathrm{RCseqLeft}(A)(n)$ denotes the left component of\n $\\mathrm{RCseq}(A)(n)$, i.e.,\n \\begin{displaymath}\n \\mathrm{RCseq}(A)(n) = (\\mathrm{RCseqLeft}(A)(n), \\mathrm{RCseqRight}(A)(n)).\n \\end{displaymath}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:RCseqRight}\n \\lean{RCseqRight}\n \\uses{def:RCseq}\n For $n \\in \\mathbb{N}$, $\\mathrm{RCseqRight}(A)(n)$ denotes the right component of\n $\\mathrm{RCseq}(A)(n)$, i.e.,\n \\begin{displaymath}\n \\mathrm{RCseq}(A)(n) = (\\mathrm{RCseqLeft}(A)(n), \\mathrm{RCseqRight}(A)(n)).\n \\end{displaymath}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:colOneSeq}\n \\lean{colOneSeq}\n \\uses{def:RCseqLeft}\n \\uses{def:RCseqRight}\n For $n \\in \\mathbb{N}$, define\n \\begin{displaymath}\n \\mathrm{colOneSeq}(A)(n) = \\mathrm{diag}(\\mathrm{RCseqLeft(A)(n)}) * A * \\mathrm{diag}(\\mathrm{RCseqRight(A)(n)}).\n \\end{displaymath}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:rowOneSeq}\n \\lean{rowOneSeq}\n \\uses{def:RCseqLeft}\n \\uses{def:RCseqRight}\n For $n \\in \\mathbb{N}$, define\n \\begin{displaymath}\n \\mathrm{rowOneSeq}(A)(n) = \\mathrm{diag}(\\mathrm{RCseqLeft(A)(n+1)}) * A * \\mathrm{diag}(\\mathrm{RCseqRight(A)(n)}).\n \\end{displaymath}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:rowSums}\n \\lean{rowSums}\n \\uses{def:colOneSeq}\n For $n \\in \\mathbb{N}$, define\n \\begin{displaymath}\n \\mathrm{rowSums}(A)(n) = \\mathrm{rowSum}(\\mathrm{colOneSeq}(A)(n)),\n \\end{displaymath}\n the vector of row sums of $\\mathrm{colOneSeq}(A)(n)$.\n\\end{definition}\n\n\\begin{definition}\n \\label{def:colSums}\n \\lean{colSums}\n \\uses{def:rowOneSeq}\n For $n \\in \\mathbb{N}$, define\n \\begin{displaymath}\n \\mathrm{colSums}(A)(n) = \\mathrm{colSum}(\\mathrm{rowOneSeq}(A)(n)),\n \\end{displaymath}\n the vector of column sums of $\\mathrm{rowOneSeq}(A)(n)$.\n\\end{definition}\n\n\\begin{lemma}\n \\label{lem:colSum_one}\n \\lean{colSum_one}\n \\uses{def:colOneSeq}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then for any $n$, $\\mathrm{colSum}(\\mathrm{colOneSeq}(A)(n)) = 1_N$.\n\\end{lemma}\n\\begin{proof}\n Simply unravel the definitions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rowSum_one}\n \\lean{rowSum_one}\n \\uses{def:rowOneSeq}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then for any $n$, $\\mathrm{rowSum}(\\mathrm{rowOneSeq}(A)(n)) = 1_N$.\n\\end{lemma}\n\\begin{proof}\n Simply unravel the definitions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:colOne_to_rowOne}\n \\lean{colOne_to_rowOne}\n \\uses{def:colOneSeq}\n \\uses{def:rowOneSeq}\n \\uses{def:rowSums}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then $\\mathrm{rowOneSeq}(A)(n) = \\mathrm{diag}(\\mathrm{rowSums}(A)(n)^{-1}) * \\mathrm{colOneSeq}(A)(n)$.\n\\end{lemma}\n\\begin{proof}\n Simply unravel the definitions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rowOne_to_colOne}\n \\lean{rowOne_to_colOne}\n \\uses{def:colOneSeq}\n \\uses{def:rowOneSeq}\n \\uses{def:colSums}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then $\\mathrm{colOneSeq}(A)(n+1) = \\mathrm{diag}(\\mathrm{colSums}(A)(n)^{-1}) * \\mathrm{rowOneSeq}(A)(n)$.\n\\end{lemma}\n\\begin{proof}\n Simply unravel the definitions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rowSums_colSums_bound}\n \\lean{rowSums_colSums_bound}\n \\uses{def:rowSums}\n \\uses{def:colSums}\n \\uses{lem:colSum_one}\n \\uses{lem:rowSum_one}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Let $\\min(\\cdot)$ and $\\max(\\cdot)$ denote the minimum and maximum entry of a vector in $\\mathbb{R}^N$, respectively. Then\n \\begin{displaymath}\n \\min(\\mathrm{rowSums}(A)(n)) \\leq 1 \\leq \\max(\\mathrm{rowSums}(A)(n))\n \\end{displaymath}\n and\n \\begin{displaymath}\n \\min(\\mathrm{colSums}(A)(n)) \\leq 1 \\leq \\max(\\mathrm{colSums}(A)(n)).\n \\end{displaymath}\n\\end{lemma}\n\\begin{proof}\n The first one follows from\n \\begin{displaymath}\n \\sum_{i=1}^N \\mathrm{rowSums}(A)(n)_i = \\sum_{i=1}^N \\mathrm{colSums}(A)(n)_i = \\sum_{i=1}^N 1 = N\n \\end{displaymath}\n where the second equality follows from~\\ref{lem:colSum_one}.\n Similarly for the second, using~\\ref{lem:rowSum_one}.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rowSums_colSums_min_max_monotone_antitone}\n \\lean{rowSums_colSums_min_max_monotone_antitone}\n \\uses{def:rowSums}\n \\uses{def:colSums}\n \\uses{lem:colSum_one}\n \\uses{lem:rowSum_one}\n \\uses{lem:colOne_to_rowOne}\n \\uses{lem:rowOne_to_colOne}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then the functions $n \\mapsto \\min(\\mathrm{rowSums}(A)(n))$ and $n \\mapsto \\min(\\mathrm{colSums}(A)(n))$ are increasing. The functions $n \\mapsto \\max(\\mathrm{rowSums}(A)(n))$ and $n \\mapsto \\max(\\mathrm{colSums}(A)(n))$ are decreasing.\n\\end{lemma}\n\\begin{proof}\n By Lemmas~\\ref{lem:colSum_one} and~\\ref{lem:colOne_to_rowOne}, every entry of\n $\\mathrm{colSums}(A)(n)$ is a convex combination of the entries of $rowSums(A)(n)^{-1}$.\n By Lemmas~\\ref{lem:rowSum_one} and~\\ref{lem:rowOne_to_colOne}, every entry of\n $\\mathrm{rowSums}(A)(n+1)$ is a convex combination of the entries of $colSums(A)(n)^{-1}$.\n Therefore, every entry of $\\mathrm{rowSums}(A)(n+1)$ must be in between\n $\\min(\\mathrm{rowSums}(A)(n))$ and $\\max(\\mathrm{rowSums}(A)(n))$.\n\n By Lemmas~\\ref{lem:rowSum_one} and~\\ref{lem:rowOne_to_colOne}, every entry of\n $\\mathrm{rowSums}(A)(n+1)$ is a convex combination of the entries of $colSums(A)(n)^{-1}$.\n By Lemmas~\\ref{lem:colSum_one} and~\\ref{lem:colOne_to_rowOne}, every entry of\n $\\mathrm{colSums}(A)(n+1)$ is a convex combination of the entries of $rowSums(A)(n+1)^{-1}$.\n Therefore, every entry of $\\mathrm{colSums}(A)(n+1)$ must be in between\n $\\min(\\mathrm{colSums}(A)(n))$ and $\\max(\\mathrm{colSums}(A)(n))$.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:entry_lower_bound}\n \\lean{entry_lower_bound}\n \\uses{def:colOneSeq}\n \\uses{def:RCseqLeft}\n \\uses{def:RCseqRight}\n \\uses{def:rowSums}\n \\uses{lem:colSum_one}\n \\uses{lem:rowSums_colSums_min_max_monotone_antitone}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then there is a fixed $\\mu > 0$ such that for every $n$, every entry of $\\mathrm{colOneSeq}(A)(n)$\n is $\\geq \\mu$.\n\\end{lemma}\n\\begin{proof}\n Let $A = (a_ij)$ and let $a$ be its minimal entry. Let $x_n = RCseqLeft(A)(n)$ and let\n $y_n = RCseqRight(A)(n)$.\n Let $\\lambda_n = \\mathrm{rowSums}(A)(n)$. Let $\\lambda = \\min(\\lambda_1)$. By\n Lemma~\\ref{lem:rowSums_colSums_min_max_monotone_antitone}, $\\lambda \\leq \\lambda_{n,i}$.\n By Lemma~\\ref{lem:colSum_one}, $\\sum_i x_{ni}a_{ij}y_{nj} = 1$. So\n \\begin{displaymath}\n y_nj = 1 / \\sum_i a_{ij}x_{ni} \\leq 1 / a_{ij}x_{ni} \\leq 1 / a x_{ni}\n \\end{displaymath}\n for all $i, j$. Thus, in particular $y_{nj} \\leq 1 / a \\max (x_n)$.\n Since\n \\begin{displaymath}\n \\sum_j x_{ni} a_{ij} y_{nj} = \\lambda_{n,i} \\geq \\lambda,\n \\end{displaymath}\n it follows that\n \\begin{displaymath}\n x_{n,i} \\geq \\lambda / \\sum_j a_{ij} y_{nj} \\geq a \\lambda \\max(x_n) / N.\n \\end{displaymath}\n Also $y_{n,j} = 1 / \\sum_i a_{ij}x_{ni} \\geq 1 / N \\max(x_n)$ and we see that\n \\begin{displaymath}\n \\mathrm{colOneSeq}(A)(n)_ij = x_{ni} a_{ij} y_{nj} \\geq a \\lambda / N^2.\n \\end{displaymath}\n We set $\\mu = a \\lambda / N^2$ and every entry of $\\mathrm{colOneSeq}(A)(n)$ is therefore\n $\\geq \\mu$.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:colSums_tendsTo_one}\n \\lean{colSums_tendsTo_one}\n \\uses{def:colSums}\n \\uses{def:rowSums}\n \\uses{def:colOneSeq}\n \\uses{lem:rowSums_colSums_bound}\n \\uses{lem:rowSums_colSums_min_max_monotone_antitone}\n \\uses{lem:entry_lower_bound}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then $\\lim_{n \\to \\infty} \\mathrm{colSums}(A)(n) = 1_N$.\n\\end{lemma}\n\\begin{proof}\n Let $\\lambda_n = \\mathrm{colSums}(A)(n)$ and $\\delta_n = \\mathrm{rowSums}(A)(n)$.\n By Lemmas~\\ref{lem:rowSums_colSums_bound} and~\\ref{lem:rowSums_colSums_min_max_monotone_antitone},\n $\\max(\\lambda_n) \\to 1 + c$ where $c \\geq 0$. Set $\\max(\\lambda_n) = 1 + c_n$.\n For any $j$, set $\\mu_j = \\sum_{i : \\lambda_{ni} \\leq 1} colOneSeq(A)(n)_{ij}$ and set\n $\\mu_j' = \\sum_{i : \\lambda_{ni} > 1} colOneSeq(A)(n)_{ij}$. Then\n \\begin{displaymath}\n \\delta_{nj} \\geq \\mu_j + \\frac{1}{1 + c_n} \\mu_j' = \\frac{1 + c_n \\mu_j}{1 + c_n} \\geq\n \\frac{1 + c_n a_n}{1 + c_n}\n \\end{displaymath}\n where $a_n$ denotes the minimum entry of $\\mathrm{colSums}(A)(n)$. Then if\n $\\max(\\lambda_{n+1})=\\lambda_{n+1, \\lambda_0}$,\n \\begin{displaymath}\n 1 + c \\leq \\lambda_{n+1, i_0} = \\sum_j \\mathrm{rowSums}(A)(n)_{i_0j}/\\lambda_{ni_0}\\delta_{nj}\n \\leq (1 + c_n) / (1 + c_n a_n).\n \\end{displaymath}\n If $c > 0$, then\n \\begin{displaymath}\n (1 + c_n)/(1 + c_n a_n) \\leq (1 + c_n) / (1 + c \\mu)\n \\end{displaymath}\n where $\\mu$ is obtained from Lemma~\\ref{lem:entry_lower_bound}.\n So $1 + c \\leq (1 + c_n) / (1 + c \\mu)$ and by taking limit $n \\to \\infty$, we get a contradiction.\n Thus $c=0$ and $\\max(\\lambda_n) \\to 1$. Since $\\sum_i \\lambda_{n,i} = N$, $\\lambda_n \\to 1_N$.\n\\end{proof}\n\n\n\\begin{lemma}\n \\label{lem:rowSums_tendsTo_one}\n \\lean{rowSums_tendsTo_one}\n \\uses{def:rowSums}\n \\uses{lem:rowSum_one}\n \\uses{lem:rowOne_to_colOne}\n \\uses{lem:colSums_tendsTo_one}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then $\\lim_{n \\to \\infty} \\mathrm{rowSums}(A)(n) = 1_N$.\n\\end{lemma}\n\\begin{proof}\n By Lemmas~\\ref{lem:rowSum_one} and~\\ref{lem:rowOne_to_colOne}, every entry of\n $\\mathrm{rowSums}(A)(n+1)$ is a convex combination of the entries of $colSums(A)(n)^{-1}$.\n The lemma thus follows from Lemma~\\ref{lem:colSums_tendsTo_one},\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rescale}\n \\lean{rescale}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Suppose that $x_n, y_n \\in \\mathbb{R}^N$ for $n \\in \\mathbb{N}$ are vectors with all positive\n entries.\n Suppose that for any $i, j$, $x_{n, i} y_{n, j}$ converges to a positive limit.\n Then there exists $x'_n, y'_n \\in \\mathbb{R}^N$ such that for any $i, j$,\n $x'_{n,i}y'_{n,j} = x_{n,i}y_{n,j}$ for any $n$ and both\n $x'_{n,i}, y'_{n,j}$ converge to positive limits.\n\\end{lemma}\n\\begin{proof}\n Let $x'_{n,i} = x_{n,i} / x_{n,1}$ and $y'_{n,j} = y_{n,j} x_{n,1}$.\n Then $x'_{n,i}y'_{n,j} = x_{n,i}y_{n,j}$.\n $y'_{n,j}$ converges to a positive limit by assumption.\n Since $x'_{n,i} = x_{n,i}y_{n,1} / x_{n,1}y_{n,1}$ and both $x_{n,i}y_{n,1}$ and $x_{n,1}y_{n,1}$\n converge to a positive limit by assumption, $x'_{n,i}$ also converge to a positive limit.\n\\end{proof}\n\n\\begin{theorem}\n \\label{thm:sinkhorn_existence}\n \\lean{sinkhorn_existence}\n \\uses{def:colOneSeq}\n \\uses{def:RCseqLeft}\n \\uses{def:RCseqRight}\n \\uses{def:rowSums}\n \\uses{lem:colSum_one}\n \\uses{lem:rescale}\n \\uses{lem:entry_lower_bound}\n \\uses{lem:rowSums_tendsTo_one}\n \\uses{thm:sinkhorn_uniqueness}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries. Then there are\n $d_1, d_2 \\in \\mathbb{R}^N$ with all positive entries such that $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ is\n doubly stochastic.\n\\end{theorem}\n\\begin{proof}\n Let $\\mu>0$ be obtained from Lemma~\\ref{lem:entry_lower_bound}. Then for every $n$, every entry of $\\mathrm{colOneSeq}(A)(n)$ is $\\geq \\mu$. Also by Lemma~\\ref{lem:colSum_one}, every entry of $\\mathrm{colOneSeq}(A)(n)$ is $\\leq 1$.\n Let $x_n = RCseqLeft(A)(n)$ and $y_n = RCseqRight(A)(n)$. Then for each $i,j$, $x_{n,i}y_{n,j}$\n is bounded and has a positive lower bound. By compactness, there is a subsequence\n $(x_{n_k}, y_{n_k})_k$ such that each $x_{n_k,i}y_{n_k,j}$ converges to a positive limit.\n By Lemma~\\ref{lem:rescale}, there is $(x'_{k}, y'_{k})_k$ such that\n $x'_{ki}y'_{kj} = x_{n_k,i}y_{n_k,j}$ and $d_1, d_2 \\in \\mathbb{R}^N$ such that $d_1, d_2$\n have positive entries and $(x'_k, y'_k) \\to (d_1, d_2)$.\n Let $A = (a_ij)$.\n The sum of the $i$th row of $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ is\n \\begin{displaymath}\n \\sum_i d_{1i} a_{ij} d_{2j} = \\lim_{k \\to \\infty} \\sum_i x'_{ki} a_{ij} y'_{kj}\n = \\lim_{k \\to \\infty} \\sum_i x_{n_k,i} a_{ij} y_{n_k,j}\n = \\lim_{k \\to \\infty} \\mathrm{rowSums}(A)(n_k)_i = 1\n \\end{displaymath}\n where the last equality follows from Lemma~\\ref{lem:colSums_tendsTo_one}.\n Similarly, every column sum of $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ is 1 using\n Lemma~\\ref{lem:rowSums_tendsTo_one}.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Matrix Finset Filter Topology\n\n\ntheorem sinkhorn_existence {n : ℕ} (hn : 0 < n)\n (A : Matrix (Fin n) (Fin n) ℝ)\n (hA : ∀ i j, 0 < A i j) :\n ∃ d₁ d₂ : Fin n → ℝ,\n (∀ i, 0 < d₁ i) ∧\n (∀ i, 0 < d₂ i) ∧\n diagonal d₁ * A * diagonal d₂ ∈ doublyStochastic ℝ (Fin n) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sinkhorn_uniqueness", "type": "theorem", "title": "Sinkhorn's theorem", "informal_statement": "Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries. Suppose there are\n $d_1, d_2, d'_1, d'_2 \\in \\mathbb{R}^N$ all have positive entries such that\n $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ and $\\mathrm{diag}(d'_1) * A * \\mathrm{diag}(d'_2)$ are both doubly stochastic.\n Then there is a constant $c > 0$ such that $d'_1 = c * d_1$ and $d'_2 = d_2 / c$.", "informal_proof": "\\chapter{Sinkhorn's theorem}\n\nThis section contains a proof of Sinkhorn's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Sinkhorn's_theorem} for more details.\n\n\\begin{theorem}\n \\label{thm:sinkhorn_uniqueness}\n \\lean{sinkhorn_uniqueness}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries. Suppose there are\n $d_1, d_2, d'_1, d'_2 \\in \\mathbb{R}^N$ all have positive entries such that\n $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ and $\\mathrm{diag}(d'_1) * A * \\mathrm{diag}(d'_2)$ are both doubly stochastic.\n Then there is a constant $c > 0$ such that $d'_1 = c * d_1$ and $d'_2 = d_2 / c$.\n\\end{theorem}\n\\begin{proof}\n Let $P = \\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$. Let $b_1 = d_1'/d_1$ and $b_2 = d_2'/d_2$ where division is coordinate-wise. Then both $P$ and $\\mathrm{diag}(b_1) * A * \\mathrm{diag}(b_2)$ are doubly stochastic.\n For each $i$, $1/b_{1i}$ is a convex combination of the entries of $b_2$. So\n \\begin{displaymath}\n \\min(b_2) \\leq 1/b_{1i} \\leq \\max(b_2).\n \\end{displaymath}\n Similarly, for any $j$,\n \\begin{displaymath}\n \\min(b_1) \\leq 1/b_{2j} \\leq \\max(b_1).\n \\end{displaymath}\n Let $\\min(b_1) = b_{1i_0}$ and $\\max(b_2) = b_{2j_0}$. Then we must have $b_{1i_0}b_{2j_0}=1$.\n Again since $1/b_{1i_0}$ is a convex combination of the entries of $b_2$, every $b_{2j}$ must be equal to $b_{2j_0} = 1/b_{1i_0}$. Similarly, every $b_{1i}$ must be equal to $b_{1i_0}$.\n Let $c = b_{11}$. Then $c$ satisfies the conclusion of the lemma.\n\\end{proof}\n\n\\begin{definition}\n \\label{def:RCseq}\n \\lean{RCseq}\n Given an $N \\times N$ matrix $A$ with all positive entries, we define the row-column normalization sequence,\n \\begin{displaymath}\n \\mathrm{RCseq}(A):\\mathbb{N} \\to \\mathbb{R}^N \\times \\mathbb{R}^N,\n \\end{displaymath}\n by recursion.\n \\begin{enumerate}\n \\item $\\mathrm{RCseq}(A)(0) = (1_N, \\mathrm{colSum}(A)^{-1})$, where $1_N = (1, \\dots, 1)$\n denotes the vector with all-one entries, $\\mathrm{colSum}(A)$ denotes the vector consisting\n of all the column sums of $A$, $x^{-1}$ denotes $(x_1^{-1}, \\dots, x_N^{-1})$ for\n $x = (x_1, \\dots, x_N) \\in \\mathbb{R}^N$.\n \\item Suppose that $\\mathrm{RCseq}(A)(n) = (d, e)$ has been defined. Let\n $A' = \\mathrm{diag}(d) * A * \\mathrm{diag}(e)$. Let $d' = \\mathrm{rowSum}(A')^{-1}$ where\n $\\mathrm{rowSum}(A')$ denotes the vector consisting of all the row sums of $A'$. Let\n $e' = \\mathrm{colSum}(\\mathrm{diag}(d') * A')^{-1}$.\n Then $\\mathrm{RCseq}(A)(n+1) = (d' * d, e * e')$, where $*$ denotes pointwise multiplication.\n \\end{enumerate}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:RCseqLeft}\n \\lean{RCseqLeft}\n \\uses{def:RCseq}\n For $n \\in \\mathbb{N}$, $\\mathrm{RCseqLeft}(A)(n)$ denotes the left component of\n $\\mathrm{RCseq}(A)(n)$, i.e.,\n \\begin{displaymath}\n \\mathrm{RCseq}(A)(n) = (\\mathrm{RCseqLeft}(A)(n), \\mathrm{RCseqRight}(A)(n)).\n \\end{displaymath}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:RCseqRight}\n \\lean{RCseqRight}\n \\uses{def:RCseq}\n For $n \\in \\mathbb{N}$, $\\mathrm{RCseqRight}(A)(n)$ denotes the right component of\n $\\mathrm{RCseq}(A)(n)$, i.e.,\n \\begin{displaymath}\n \\mathrm{RCseq}(A)(n) = (\\mathrm{RCseqLeft}(A)(n), \\mathrm{RCseqRight}(A)(n)).\n \\end{displaymath}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:colOneSeq}\n \\lean{colOneSeq}\n \\uses{def:RCseqLeft}\n \\uses{def:RCseqRight}\n For $n \\in \\mathbb{N}$, define\n \\begin{displaymath}\n \\mathrm{colOneSeq}(A)(n) = \\mathrm{diag}(\\mathrm{RCseqLeft(A)(n)}) * A * \\mathrm{diag}(\\mathrm{RCseqRight(A)(n)}).\n \\end{displaymath}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:rowOneSeq}\n \\lean{rowOneSeq}\n \\uses{def:RCseqLeft}\n \\uses{def:RCseqRight}\n For $n \\in \\mathbb{N}$, define\n \\begin{displaymath}\n \\mathrm{rowOneSeq}(A)(n) = \\mathrm{diag}(\\mathrm{RCseqLeft(A)(n+1)}) * A * \\mathrm{diag}(\\mathrm{RCseqRight(A)(n)}).\n \\end{displaymath}\n\\end{definition}\n\n\\begin{definition}\n \\label{def:rowSums}\n \\lean{rowSums}\n \\uses{def:colOneSeq}\n For $n \\in \\mathbb{N}$, define\n \\begin{displaymath}\n \\mathrm{rowSums}(A)(n) = \\mathrm{rowSum}(\\mathrm{colOneSeq}(A)(n)),\n \\end{displaymath}\n the vector of row sums of $\\mathrm{colOneSeq}(A)(n)$.\n\\end{definition}\n\n\\begin{definition}\n \\label{def:colSums}\n \\lean{colSums}\n \\uses{def:rowOneSeq}\n For $n \\in \\mathbb{N}$, define\n \\begin{displaymath}\n \\mathrm{colSums}(A)(n) = \\mathrm{colSum}(\\mathrm{rowOneSeq}(A)(n)),\n \\end{displaymath}\n the vector of column sums of $\\mathrm{rowOneSeq}(A)(n)$.\n\\end{definition}\n\n\\begin{lemma}\n \\label{lem:colSum_one}\n \\lean{colSum_one}\n \\uses{def:colOneSeq}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then for any $n$, $\\mathrm{colSum}(\\mathrm{colOneSeq}(A)(n)) = 1_N$.\n\\end{lemma}\n\\begin{proof}\n Simply unravel the definitions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rowSum_one}\n \\lean{rowSum_one}\n \\uses{def:rowOneSeq}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then for any $n$, $\\mathrm{rowSum}(\\mathrm{rowOneSeq}(A)(n)) = 1_N$.\n\\end{lemma}\n\\begin{proof}\n Simply unravel the definitions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:colOne_to_rowOne}\n \\lean{colOne_to_rowOne}\n \\uses{def:colOneSeq}\n \\uses{def:rowOneSeq}\n \\uses{def:rowSums}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then $\\mathrm{rowOneSeq}(A)(n) = \\mathrm{diag}(\\mathrm{rowSums}(A)(n)^{-1}) * \\mathrm{colOneSeq}(A)(n)$.\n\\end{lemma}\n\\begin{proof}\n Simply unravel the definitions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rowOne_to_colOne}\n \\lean{rowOne_to_colOne}\n \\uses{def:colOneSeq}\n \\uses{def:rowOneSeq}\n \\uses{def:colSums}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then $\\mathrm{colOneSeq}(A)(n+1) = \\mathrm{diag}(\\mathrm{colSums}(A)(n)^{-1}) * \\mathrm{rowOneSeq}(A)(n)$.\n\\end{lemma}\n\\begin{proof}\n Simply unravel the definitions.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rowSums_colSums_bound}\n \\lean{rowSums_colSums_bound}\n \\uses{def:rowSums}\n \\uses{def:colSums}\n \\uses{lem:colSum_one}\n \\uses{lem:rowSum_one}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Let $\\min(\\cdot)$ and $\\max(\\cdot)$ denote the minimum and maximum entry of a vector in $\\mathbb{R}^N$, respectively. Then\n \\begin{displaymath}\n \\min(\\mathrm{rowSums}(A)(n)) \\leq 1 \\leq \\max(\\mathrm{rowSums}(A)(n))\n \\end{displaymath}\n and\n \\begin{displaymath}\n \\min(\\mathrm{colSums}(A)(n)) \\leq 1 \\leq \\max(\\mathrm{colSums}(A)(n)).\n \\end{displaymath}\n\\end{lemma}\n\\begin{proof}\n The first one follows from\n \\begin{displaymath}\n \\sum_{i=1}^N \\mathrm{rowSums}(A)(n)_i = \\sum_{i=1}^N \\mathrm{colSums}(A)(n)_i = \\sum_{i=1}^N 1 = N\n \\end{displaymath}\n where the second equality follows from~\\ref{lem:colSum_one}.\n Similarly for the second, using~\\ref{lem:rowSum_one}.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rowSums_colSums_min_max_monotone_antitone}\n \\lean{rowSums_colSums_min_max_monotone_antitone}\n \\uses{def:rowSums}\n \\uses{def:colSums}\n \\uses{lem:colSum_one}\n \\uses{lem:rowSum_one}\n \\uses{lem:colOne_to_rowOne}\n \\uses{lem:rowOne_to_colOne}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then the functions $n \\mapsto \\min(\\mathrm{rowSums}(A)(n))$ and $n \\mapsto \\min(\\mathrm{colSums}(A)(n))$ are increasing. The functions $n \\mapsto \\max(\\mathrm{rowSums}(A)(n))$ and $n \\mapsto \\max(\\mathrm{colSums}(A)(n))$ are decreasing.\n\\end{lemma}\n\\begin{proof}\n By Lemmas~\\ref{lem:colSum_one} and~\\ref{lem:colOne_to_rowOne}, every entry of\n $\\mathrm{colSums}(A)(n)$ is a convex combination of the entries of $rowSums(A)(n)^{-1}$.\n By Lemmas~\\ref{lem:rowSum_one} and~\\ref{lem:rowOne_to_colOne}, every entry of\n $\\mathrm{rowSums}(A)(n+1)$ is a convex combination of the entries of $colSums(A)(n)^{-1}$.\n Therefore, every entry of $\\mathrm{rowSums}(A)(n+1)$ must be in between\n $\\min(\\mathrm{rowSums}(A)(n))$ and $\\max(\\mathrm{rowSums}(A)(n))$.\n\n By Lemmas~\\ref{lem:rowSum_one} and~\\ref{lem:rowOne_to_colOne}, every entry of\n $\\mathrm{rowSums}(A)(n+1)$ is a convex combination of the entries of $colSums(A)(n)^{-1}$.\n By Lemmas~\\ref{lem:colSum_one} and~\\ref{lem:colOne_to_rowOne}, every entry of\n $\\mathrm{colSums}(A)(n+1)$ is a convex combination of the entries of $rowSums(A)(n+1)^{-1}$.\n Therefore, every entry of $\\mathrm{colSums}(A)(n+1)$ must be in between\n $\\min(\\mathrm{colSums}(A)(n))$ and $\\max(\\mathrm{colSums}(A)(n))$.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:entry_lower_bound}\n \\lean{entry_lower_bound}\n \\uses{def:colOneSeq}\n \\uses{def:RCseqLeft}\n \\uses{def:RCseqRight}\n \\uses{def:rowSums}\n \\uses{lem:colSum_one}\n \\uses{lem:rowSums_colSums_min_max_monotone_antitone}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then there is a fixed $\\mu > 0$ such that for every $n$, every entry of $\\mathrm{colOneSeq}(A)(n)$\n is $\\geq \\mu$.\n\\end{lemma}\n\\begin{proof}\n Let $A = (a_ij)$ and let $a$ be its minimal entry. Let $x_n = RCseqLeft(A)(n)$ and let\n $y_n = RCseqRight(A)(n)$.\n Let $\\lambda_n = \\mathrm{rowSums}(A)(n)$. Let $\\lambda = \\min(\\lambda_1)$. By\n Lemma~\\ref{lem:rowSums_colSums_min_max_monotone_antitone}, $\\lambda \\leq \\lambda_{n,i}$.\n By Lemma~\\ref{lem:colSum_one}, $\\sum_i x_{ni}a_{ij}y_{nj} = 1$. So\n \\begin{displaymath}\n y_nj = 1 / \\sum_i a_{ij}x_{ni} \\leq 1 / a_{ij}x_{ni} \\leq 1 / a x_{ni}\n \\end{displaymath}\n for all $i, j$. Thus, in particular $y_{nj} \\leq 1 / a \\max (x_n)$.\n Since\n \\begin{displaymath}\n \\sum_j x_{ni} a_{ij} y_{nj} = \\lambda_{n,i} \\geq \\lambda,\n \\end{displaymath}\n it follows that\n \\begin{displaymath}\n x_{n,i} \\geq \\lambda / \\sum_j a_{ij} y_{nj} \\geq a \\lambda \\max(x_n) / N.\n \\end{displaymath}\n Also $y_{n,j} = 1 / \\sum_i a_{ij}x_{ni} \\geq 1 / N \\max(x_n)$ and we see that\n \\begin{displaymath}\n \\mathrm{colOneSeq}(A)(n)_ij = x_{ni} a_{ij} y_{nj} \\geq a \\lambda / N^2.\n \\end{displaymath}\n We set $\\mu = a \\lambda / N^2$ and every entry of $\\mathrm{colOneSeq}(A)(n)$ is therefore\n $\\geq \\mu$.\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:colSums_tendsTo_one}\n \\lean{colSums_tendsTo_one}\n \\uses{def:colSums}\n \\uses{def:rowSums}\n \\uses{def:colOneSeq}\n \\uses{lem:rowSums_colSums_bound}\n \\uses{lem:rowSums_colSums_min_max_monotone_antitone}\n \\uses{lem:entry_lower_bound}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then $\\lim_{n \\to \\infty} \\mathrm{colSums}(A)(n) = 1_N$.\n\\end{lemma}\n\\begin{proof}\n Let $\\lambda_n = \\mathrm{colSums}(A)(n)$ and $\\delta_n = \\mathrm{rowSums}(A)(n)$.\n By Lemmas~\\ref{lem:rowSums_colSums_bound} and~\\ref{lem:rowSums_colSums_min_max_monotone_antitone},\n $\\max(\\lambda_n) \\to 1 + c$ where $c \\geq 0$. Set $\\max(\\lambda_n) = 1 + c_n$.\n For any $j$, set $\\mu_j = \\sum_{i : \\lambda_{ni} \\leq 1} colOneSeq(A)(n)_{ij}$ and set\n $\\mu_j' = \\sum_{i : \\lambda_{ni} > 1} colOneSeq(A)(n)_{ij}$. Then\n \\begin{displaymath}\n \\delta_{nj} \\geq \\mu_j + \\frac{1}{1 + c_n} \\mu_j' = \\frac{1 + c_n \\mu_j}{1 + c_n} \\geq\n \\frac{1 + c_n a_n}{1 + c_n}\n \\end{displaymath}\n where $a_n$ denotes the minimum entry of $\\mathrm{colSums}(A)(n)$. Then if\n $\\max(\\lambda_{n+1})=\\lambda_{n+1, \\lambda_0}$,\n \\begin{displaymath}\n 1 + c \\leq \\lambda_{n+1, i_0} = \\sum_j \\mathrm{rowSums}(A)(n)_{i_0j}/\\lambda_{ni_0}\\delta_{nj}\n \\leq (1 + c_n) / (1 + c_n a_n).\n \\end{displaymath}\n If $c > 0$, then\n \\begin{displaymath}\n (1 + c_n)/(1 + c_n a_n) \\leq (1 + c_n) / (1 + c \\mu)\n \\end{displaymath}\n where $\\mu$ is obtained from Lemma~\\ref{lem:entry_lower_bound}.\n So $1 + c \\leq (1 + c_n) / (1 + c \\mu)$ and by taking limit $n \\to \\infty$, we get a contradiction.\n Thus $c=0$ and $\\max(\\lambda_n) \\to 1$. Since $\\sum_i \\lambda_{n,i} = N$, $\\lambda_n \\to 1_N$.\n\\end{proof}\n\n\n\\begin{lemma}\n \\label{lem:rowSums_tendsTo_one}\n \\lean{rowSums_tendsTo_one}\n \\uses{def:rowSums}\n \\uses{lem:rowSum_one}\n \\uses{lem:rowOne_to_colOne}\n \\uses{lem:colSums_tendsTo_one}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Then $\\lim_{n \\to \\infty} \\mathrm{rowSums}(A)(n) = 1_N$.\n\\end{lemma}\n\\begin{proof}\n By Lemmas~\\ref{lem:rowSum_one} and~\\ref{lem:rowOne_to_colOne}, every entry of\n $\\mathrm{rowSums}(A)(n+1)$ is a convex combination of the entries of $colSums(A)(n)^{-1}$.\n The lemma thus follows from Lemma~\\ref{lem:colSums_tendsTo_one},\n\\end{proof}\n\n\\begin{lemma}\n \\label{lem:rescale}\n \\lean{rescale}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries.\n Suppose that $x_n, y_n \\in \\mathbb{R}^N$ for $n \\in \\mathbb{N}$ are vectors with all positive\n entries.\n Suppose that for any $i, j$, $x_{n, i} y_{n, j}$ converges to a positive limit.\n Then there exists $x'_n, y'_n \\in \\mathbb{R}^N$ such that for any $i, j$,\n $x'_{n,i}y'_{n,j} = x_{n,i}y_{n,j}$ for any $n$ and both\n $x'_{n,i}, y'_{n,j}$ converge to positive limits.\n\\end{lemma}\n\\begin{proof}\n Let $x'_{n,i} = x_{n,i} / x_{n,1}$ and $y'_{n,j} = y_{n,j} x_{n,1}$.\n Then $x'_{n,i}y'_{n,j} = x_{n,i}y_{n,j}$.\n $y'_{n,j}$ converges to a positive limit by assumption.\n Since $x'_{n,i} = x_{n,i}y_{n,1} / x_{n,1}y_{n,1}$ and both $x_{n,i}y_{n,1}$ and $x_{n,1}y_{n,1}$\n converge to a positive limit by assumption, $x'_{n,i}$ also converge to a positive limit.\n\\end{proof}\n\n\\begin{theorem}\n \\label{thm:sinkhorn_existence}\n \\lean{sinkhorn_existence}\n \\uses{def:colOneSeq}\n \\uses{def:RCseqLeft}\n \\uses{def:RCseqRight}\n \\uses{def:rowSums}\n \\uses{lem:colSum_one}\n \\uses{lem:rescale}\n \\uses{lem:entry_lower_bound}\n \\uses{lem:rowSums_tendsTo_one}\n \\uses{thm:sinkhorn_uniqueness}\n Suppose that $A$ is an $N \\times N$ matrix $A$ with all positive entries. Then there are\n $d_1, d_2 \\in \\mathbb{R}^N$ with all positive entries such that $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ is\n doubly stochastic.\n\\end{theorem}\n\\begin{proof}\n Let $\\mu>0$ be obtained from Lemma~\\ref{lem:entry_lower_bound}. Then for every $n$, every entry of $\\mathrm{colOneSeq}(A)(n)$ is $\\geq \\mu$. Also by Lemma~\\ref{lem:colSum_one}, every entry of $\\mathrm{colOneSeq}(A)(n)$ is $\\leq 1$.\n Let $x_n = RCseqLeft(A)(n)$ and $y_n = RCseqRight(A)(n)$. Then for each $i,j$, $x_{n,i}y_{n,j}$\n is bounded and has a positive lower bound. By compactness, there is a subsequence\n $(x_{n_k}, y_{n_k})_k$ such that each $x_{n_k,i}y_{n_k,j}$ converges to a positive limit.\n By Lemma~\\ref{lem:rescale}, there is $(x'_{k}, y'_{k})_k$ such that\n $x'_{ki}y'_{kj} = x_{n_k,i}y_{n_k,j}$ and $d_1, d_2 \\in \\mathbb{R}^N$ such that $d_1, d_2$\n have positive entries and $(x'_k, y'_k) \\to (d_1, d_2)$.\n Let $A = (a_ij)$.\n The sum of the $i$th row of $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ is\n \\begin{displaymath}\n \\sum_i d_{1i} a_{ij} d_{2j} = \\lim_{k \\to \\infty} \\sum_i x'_{ki} a_{ij} y'_{kj}\n = \\lim_{k \\to \\infty} \\sum_i x_{n_k,i} a_{ij} y_{n_k,j}\n = \\lim_{k \\to \\infty} \\mathrm{rowSums}(A)(n_k)_i = 1\n \\end{displaymath}\n where the last equality follows from Lemma~\\ref{lem:colSums_tendsTo_one}.\n Similarly, every column sum of $\\mathrm{diag}(d_1) * A * \\mathrm{diag}(d_2)$ is 1 using\n Lemma~\\ref{lem:rowSums_tendsTo_one}.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Matrix Finset Filter Topology\n\n\ntheorem sinkhorn_uniqueness {n : ℕ} (hn : 0 < n)\n (A : Matrix (Fin n) (Fin n) ℝ)\n (hA : ∀ i j, 0 < A i j)\n (d₁ d₂ d₁' d₂' : Fin n → ℝ)\n (hd₁ : ∀ i, 0 < d₁ i)\n (hd₂ : ∀ i, 0 < d₂ i)\n (hd₁' : ∀ i, 0 < d₁' i)\n (hd₂' : ∀ i, 0 < d₂' i)\n (hDS : diagonal d₁ * A * diagonal d₂ ∈ doublyStochastic ℝ (Fin n))\n (hDS' : diagonal d₁' * A * diagonal d₂' ∈ doublyStochastic ℝ (Fin n)) :\n ∃ c : ℝ, 0 < c ∧\n (∀ i, d₁' i = c * d₁ i) ∧\n (∀ i, d₂' i = d₂ i / c) := by sorry"} -{"project_name": "StarOfDavid", "name": "starofdavid", "type": "theorem", "title": "Star of David", "informal_statement": "For all $n, k \\in \\mathbb{N}$,\n \\[\n \\gcd(\\gcd(\\binom{n-1}{k-1}, \\binom{n}{k+1}), \\binom{n+1}{k})\n = \\gcd(\\gcd(\\binom{n-1}{k}, \\binom{n}{k-1}), \\binom{n+1}{k+1}).\n \\]", "informal_proof": "\n\\chapter{Star of David theorem}\n\nThis section contains a proof of the Star of David theorem for binomial coefficients.\nSee \\url{https://en.wikipedia.org/wiki/Star_of_David_theorem} for more details.\n\nFor all $n, k \\in \\mathbb{N}$,\n\\[\n \\gcd\\bigl(\\gcd\\bigl(\\binom{n-1}{k-1},\\, \\binom{n}{k+1}\\bigr),\\, \\binom{n+1}{k}\\bigr)\n \\;=\\;\n \\gcd\\bigl(\\gcd\\bigl(\\binom{n-1}{k},\\, \\binom{n}{k-1}\\bigr),\\, \\binom{n+1}{k+1}\\bigr).\n\\]\n\n\\section{Edge Cases}\n\n\\begin{lemma}[Edge case $n=0$]\n \\label{lem:starofdavid_n_zero}\n \\lean{starofdavid_n_zero}\n For all $k$, the identity holds when $n = 0$.\n\\end{lemma}\n\n\\begin{proof}\n This follows by case-splitting on $k = 0, 1, \\ge 2$ and using direct computation or the fact that $\\binom{0}{m} = 0$ for $m \\ge 1$.\n\\end{proof}\n\n\\begin{lemma}[Edge case $k=0$]\n \\label{lem:starofdavid_k_zero}\n \\lean{starofdavid_k_zero}\n For all $n$, the identity holds when $k = 0$, since $\\binom{n}{0} = 1$ and $\\binom{n}{1} = n$.\n\\end{lemma}\n\n\\begin{proof}\n This follows by case splitting on $n=0$: When $n=0$ this follows by direct computation; when $n \\ge 1$ this follows from standard binomial identities.\n\\end{proof}\n\n\\section{Main Case Setup}\n\nWrite $n = m+1$, $k = j+1$ so all $\\mathbb{N}$-subtractions are clean. Define:\n\\begin{align*}\n a &= \\binom{m}{j}, &\n b &= \\binom{m+1}{j+2}, &\n c &= \\binom{m+2}{j+1}, \\\\\n d &= \\binom{m}{j+1}, &\n e &= \\binom{m+1}{j}, &\n f &= \\binom{m+2}{j+2}, \\\\\n M &= \\binom{m+1}{j+1} = a + d.\n\\end{align*}\nThe LHS is $g = \\gcd(a, b, c)$ and the RHS is $h = \\gcd(d, e, f)$.\n\n\\section{Product Identity}\n\n\\begin{lemma}[Product identity]\n \\label{lem:product_identity}\n \\lean{product_identity}\n $a \\cdot b \\cdot c = d \\cdot e \\cdot f$.\n\\end{lemma}\n\n\\begin{proof}\n Multiply both sides by $(j+1)(j+2)$ and use the absorption identity to rewrite, then cancel. The out-of-range case ($j+1 > m$) follows since both sides are zero.\n\\end{proof}\n\n\\section{Key Identities}\n\nThe proof uses equational reasoning over the following standard identities:\n\n\\begin{itemize}\n \\item \\textbf{Absorption:} $(n+1) \\cdot \\binom{n}{k} = \\binom{n+1}{k+1} \\cdot (k+1)$\n \\item \\textbf{Pascal:} $\\binom{n+1}{k+1} = \\binom{n}{k} + \\binom{n}{k+1}$\n \\item \\textbf{Absorption relation:} $(m - j) \\cdot \\binom{m}{j} = (j+1) \\cdot \\binom{m}{j+1}$\n\\end{itemize}\n\n\\section{Divisibility: \\texorpdfstring{$g \\mid d$}{g | d}}\n\n\\begin{lemma}[$g$ divides $d+e$]\n \\label{lem:gcd_abc_dvd_d_plus_e}\n \\lean{gcd_abc_dvd_d_plus_e}\n $g \\mid (d + e)$.\n\\end{lemma}\n\n\\begin{proof}\n Rewrite $c = a + d + e$ via Pascal's rule. Then note $g \\mid c$, $g \\mid a$.\n\\end{proof}\n\n\\begin{lemma}[$g$ divides $d$ --- key lemma]\n \\label{lem:gcd_abc_dvd_d}\n \\lean{gcd_abc_dvd_d}\n \\uses{lem:product_identity, lem:gcd_abc_dvd_d_plus_e}\n $\\gcd(a, b, c) \\mid d$.\n\\end{lemma}\n\n\\begin{proof}\n Reduce to showing $p^k \\mid d$ for each prime power $p^k$ dividing $g$. From the absorption identities: $p^k \\mid (j+1)d$, $p^k \\mid (m+1)d$, and $p^k \\mid (m+2)e$. Since $p$ cannot divide both $m+1$ and $m+2$, at least one of these coefficients is coprime to $p$, allowing cancellation.\n\\end{proof}\n\n\\section{Symmetric Divisibility: \\texorpdfstring{$h \\mid a$}{h | a}}\n\n\\begin{lemma}[$h$ divides $a$]\n \\label{lem:gcd_def_dvd_a}\n \\lean{gcd_def_dvd_a}\n \\uses{lem:product_identity}\n $\\gcd(d, e, f) \\mid a$, by the symmetric prime-power argument.\n\\end{lemma}\n\n\\begin{proof}\n Same structure as Lemma~\\ref{lem:gcd_abc_dvd_d}, using $h \\mid (m-j)a$, $h \\mid (m+1)a$, and $h \\mid (m+2)a$ derived from the absorption identities.\n\\end{proof}\n\n\\section{Assembly}\n\n\\begin{lemma}[$g \\mid h$]\n \\label{lem:gcd_abc_dvd_gcd_def}\n \\lean{gcd_abc_dvd_gcd_def}\n \\uses{lem:gcd_abc_dvd_d}\n $g \\mid \\gcd(d,e,f) = h$.\n\\end{lemma}\n\n\\begin{proof}\n From $g \\mid d$, derive $g \\mid e$ (via $g \\mid d+e$) and $g \\mid f$ (via $f = a + d + b$).\n\\end{proof}\n\n\\begin{lemma}[$h \\mid g$]\n \\label{lem:gcd_def_dvd_gcd_abc}\n \\lean{gcd_def_dvd_gcd_abc}\n \\uses{lem:gcd_def_dvd_a}\n $h \\mid \\gcd(a,b,c) = g$.\n\\end{lemma}\n\n\\begin{proof}\n From $h \\mid a$, derive $h \\mid b$ (via $h \\mid a+b$) and $h \\mid c$ (via $c = e + a + d$).\n\\end{proof}\n\n\\section{Main Theorem}\n\n\\begin{theorem}[Star of David]\n \\label{thm:starofdavid}\n \\lean{starofdavid}\n \\uses{lem:starofdavid_n_zero, lem:starofdavid_k_zero, lem:gcd_abc_dvd_gcd_def, lem:gcd_def_dvd_gcd_abc}\n For all $n, k \\in \\mathbb{N}$,\n \\[\n \\gcd(\\gcd(\\binom{n-1}{k-1}, \\binom{n}{k+1}), \\binom{n+1}{k})\n = \\gcd(\\gcd(\\binom{n-1}{k}, \\binom{n}{k-1}), \\binom{n+1}{k+1}).\n \\]\n\\end{theorem}\n\n\\begin{proof}\n Edge cases $n=0$ and $k=0$ by Lemmas~\\ref{lem:starofdavid_n_zero} and~\\ref{lem:starofdavid_k_zero}. For $n = m+1$, $k = j+1$: mutual divisibility $g \\mid h$ and $h \\mid g$ (Lemmas~\\ref{lem:gcd_abc_dvd_gcd_def} and~\\ref{lem:gcd_def_dvd_gcd_abc}) gives $g = h$ by antisymmetry of divisibility.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem starofdavid (n k : ℕ) :\n (((n - 1).choose (k - 1)).gcd (n.choose (k + 1))).gcd ((n + 1).choose k)\n = (((n - 1).choose k).gcd (n.choose (k - 1))).gcd ((n + 1).choose (k + 1)) := by sorry"} -{"project_name": "SzemerediTheorem", "name": "szemeredi", "type": "theorem", "title": "Szemerédi's Theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Szemerédi's Theorem}\n\nThis section contains a (stub of a) proof of Szemerédi's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Szemer%C3%A9di%27s_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Szemerédi's Theorem]\n \\label{thm:szemeredi-theorem}\n \\lean{szemeredi}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Nat Filter Set\n\n\ntheorem szemeredi {A : Set ℕ} (h : 0 < upperDensity A) (n : ℕ) :\n ∃ a b : ℕ, b > 0 ∧ {a + k * b | k < n} ⊆ A := sorry"} -{"project_name": "SzemerediTrotterTheorem", "name": "szemeredi_trotter", "type": "theorem", "title": "Szemerédi–Trotter theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Szemerédi–Trotter theorem}\n\nThis section contains a (stub of a) proof of the Szemerédi–Trotter theorem.\nSee \\url{https://en.wikipedia.org/wiki/Szemerédi–Trotter_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Szemerédi–Trotter theorem]\n \\label{thm:szemeredi-trotter-theorem}\n \\lean{szemeredi_trotter}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen scoped EuclideanGeometry\n\nopen Classical in\n\n\ntheorem szemeredi_trotter :\n ∃ C : ℝ, 0 < C ∧ ∀ (P : Finset (EuclideanSpace ℝ (Fin 2)))\n (L : Finset Line2),\n (incidenceCount P L : ℝ) ≤\n C * ((P.card : ℝ) ^ ((2 : ℝ) / 3) *\n (L.card : ℝ) ^ ((2 : ℝ) / 3) +\n (P.card : ℝ) + (L.card : ℝ)) := by sorry"} -{"project_name": "TotientGrowthRate", "name": "totient_lower_bound", "type": "theorem", "title": "Lower bound on totient growth", "informal_statement": "TODO", "informal_proof": "\\chapter{Lower bound on totient growth rate \\texorpdfstring{$e^{-\\gamma} n / \\log \\log n$}{e\\^(-gamma) n / log log n}}\n\nThis section contains a (stub of a) proof of the lower bound on the totient growth rate $e^{-\\gamma} n / \\log \\log n$.\nSee \\url{https://en.wikipedia.org/wiki/Euler%27s_totient_function#Growth_rate} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Lower bound on totient growth]\n \\label{thm:totient-growth-rate}\n \\lean{totient_lower_bound}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen ENNReal NNReal\n\nopen Filter Set Topology Nat Real\n\n\ntheorem totient_lower_bound {n : ℕ} (hn : 2 < n) :\n ↑n / (rexp eulerMascheroniConstant * Real.log (Real.log ↑n) + 3 / Real.log (Real.log ↑n))\n < (↑(φ n) : ℝ) := by sorry"} -{"project_name": "TverbergTheorem", "name": "tverberg", "type": "theorem", "title": "Tverberg's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Tverberg's theorem}\n\nThis section contains a (stub of a) proof of Tverberg's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Tverberg%27s_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Tverberg's theorem]\n \\label{thm:tverberg-theorem}\n \\lean{tverberg}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem tverberg (d r : ℕ) (d_pos : 0 < d) (r_pos : 0 < r)\n (S : Finset (EuclideanSpace ℝ (Fin d))) (hS : S.card = (d + 1) * (r - 1) + 1) :\n ∃ (x : EuclideanSpace ℝ (Fin d)) (partition : Finpartition S),\n partition.parts.card = r ∧\n ∀ part ∈ partition.parts, x ∈ convexHull ℝ part := by sorry"} -{"project_name": "TwoFactorTheorem", "name": "two_factor_theorem", "type": "theorem", "title": "2-factor theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{2-factor theorem}\n\nThis section contains a (stub of a) proof of the 2-factor theorem.\nSee \\url{https://en.wikipedia.org/wiki/2-factor_theorem} for more details.\n\nTODO: Expand this stubbed file by adding an informal proof.\n\n% TODO: add blueprint\n\n\\begin{theorem}[2-factor theorem]\n \\label{thm:two-factor-theorem}\n \\lean{two_factor_theorem}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem two_factor_theorem {V : Type} (G : SimpleGraph V) {k : ℕ}\n (h : G.IsRegularOfDegree' (2 * k)) :\n ∃ (factors : Fin k → SimpleGraph V),\n (∀ i, factors i ≤ G) ∧\n (∀ i, (factors i).IsRegularOfDegree' 2) ∧\n (∀ i j, i ≠ j → Disjoint (factors i).edgeSet (factors j).edgeSet) ∧\n (⋃ i, (factors i).edgeSet) = G.edgeSet := sorry"} -{"project_name": "TwoNinety", "name": "two_ninety_theorem", "type": "theorem", "title": "The 290 Theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{The 290 Theorem}\n\nThis section contains a (stub of a) proof of the 290 Theorem (Bhargava-Hanke, 2011 preprint), which states that an integer-valued integral quadratic form that represents a specific list of 29 numbers represents all positive integers.\n\nSee \\url{https://en.wikipedia.org/wiki/15_and_290_theorems} for more details.\n\nTODO: Expand this stubbed file by adding formal definitions and an informal proof.\n\n% TODO: add blueprint\n\n\\begin{theorem}[The 290 Theorem]\n \\label{thm:two-ninety}\n \\lean{two_ninety_theorem}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem two_ninety_theorem {n : ℕ} (M : Matrix (Fin n) (Fin n) ℤ)\n (hpos : M.PosDef)\n (hrep : ∀ m ∈ critical_290_numbers, M.represents m) :\n M.Universal := by sorry"} -{"project_name": "ValuationRingInterSubfield", "name": "ValuationRing.inter_subfield", "type": "theorem", "title": "Valuation Ring $\\cap$ Subfield (Stacks 052L)", "informal_statement": "\\leanok\nLet $K \\subseteq L$ be a field extension and $B$ a subring of $L$ that is a valuation ring. Then $A = K \\cap B$ is a valuation ring.", "informal_proof": "\\chapter{Valuation Ring Intersected with Subfield (Stacks 052L)}\n\nThis section contains a proof of the fact about valuation rings intersected with a subfield.\nSee \\url{https://stacks.math.columbia.edu/tag/052L} for more details.\n\n\\begin{lemma}[Subfield membership from multiplication]\n\\label{lem:subfield_mem_of_mul_eq}\n\\lean{Subfield.mem_of_mul_eq}\n\\leanok\nIf $a, b \\in K$ for a subfield $K \\subseteq L$ with $a \\neq 0$ and $a \\cdot x = b$, then $x \\in K$.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\nWe have $x = a^{-1} b$, and subfields are closed under inversion and multiplication.\n\\end{proof}\n\n\\begin{lemma}[Divisibility lifts to the intersection]\n\\label{lem:dvd_inf_of_dvd_in_subring}\n\\lean{dvd_inf_of_dvd_in_subring}\n\\leanok\nLet $B$ be a subring of a field $L$ and $K$ a subfield. If $a, b \\in K \\cap B$ and $a \\mid b$ in $B$, then $a \\mid b$ in $K \\cap B$.\n\\end{lemma}\n\n\\begin{proof}\n\\leanok\n\\uses{lem:subfield_mem_of_mul_eq}\nLet $c \\in B$ satisfy $b = ac$. If $a = 0$ then $b = 0$ and divisibility is trivial. If $a \\neq 0$, then $c = a^{-1}b \\in K$ by Lemma~\\ref{lem:subfield_mem_of_mul_eq}, so $c \\in K \\cap B$ and witnesses divisibility in the intersection.\n\\end{proof}\n\n\\begin{theorem}[Valuation Ring $\\cap$ Subfield (Stacks 052L)]\n\\label{thm:valuation_ring_inter_subfield}\n\\lean{ValuationRing.inter_subfield}\n\\leanok\nLet $K \\subseteq L$ be a field extension and $B$ a subring of $L$ that is a valuation ring. Then $A = K \\cap B$ is a valuation ring.\n\\end{theorem}\n\n\\begin{proof}\n\\leanok\n\\uses{lem:dvd_inf_of_dvd_in_subring}\nBy \\texttt{ValuationRing.iff\\_dvd\\_total}, it suffices to show dvd-totality in $K \\cap B$. Given $a, b \\in K \\cap B$, dvd-totality in $B$ gives $a \\mid b$ or $b \\mid a$ in $B$. In either case, Lemma~\\ref{lem:dvd_inf_of_dvd_in_subring} lifts the divisibility to $K \\cap B$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nopen Subring Subfield\n\n\ntheorem ValuationRing.inter_subfield\n (B : Subring L) [ValuationRing B] (K : Subfield L) :\n ValuationRing ↥(K.toSubring ⊓ B) := by sorry"} -{"project_name": "Vantieghem", "name": "vantieghem", "type": "theorem", "title": "Vantieghem's Theorem", "informal_statement": "For $n \\geq 3$, $n$ is prime if and only if\n $\\prod_{k=1}^{n-1}(2^k - 1) \\equiv n \\pmod{2^n - 1}$.", "informal_proof": "\\chapter{Vantieghem's Theorem}\n\nThis section contains a proof of Vantieghem's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Vantieghem%27s_theorem} for more details.\n\n\\begin{lemma}[Square less than power for large values]\n \\label{lem:vantieghem_sq_lt_pow}\n \\lean{Vantieghem.sq_lt_pow_of_ge_five}\n For all $d \\geq 5$, $d^2 < 2^d$.\n\\end{lemma}\n\\begin{proof}\n By induction on $d$. The base case $d = 5$ is $25 < 32$. For the inductive step, if\n $n^2 < 2^n$ and $n \\geq 5$, then $(n+1)^2 = n^2 + 2n + 1 \\leq 2n^2 < 2 \\cdot 2^n = 2^{n+1}$,\n using $2n + 1 \\leq n^2$ which holds for $n \\geq 5$.\n\\end{proof}\n\n\\begin{lemma}[Product at least $n$]\n \\label{lem:vantieghem_prod_ge_n}\n \\lean{Vantieghem.prod_ge_n}\n For $n \\geq 3$, $n \\leq \\prod_{k=1}^{n-1}(2^k - 1)$.\n\\end{lemma}\n\\begin{proof}\n By induction on $n$. For $n = 3$ the product is $1 \\cdot 3 = 3$, which equals $n$. For the\n inductive step from $m$ to $m+1$ (with $m \\geq 3$), the new factor $2^m - 1 \\geq 2$ (since\n $m \\geq 3$ gives $2^m \\geq 4$), and the existing product is at least $m$, so the new product\n is at least $2m \\geq m + 1$.\n\\end{proof}\n\n\\begin{lemma}[GCD of Mersenne-like numbers with prime exponent]\n \\label{lem:vantieghem_gcd_mersenne_prime}\n \\lean{Vantieghem.gcd_mersenne_prime}\n If $n$ is prime and $1 \\leq r < n$, then $\\gcd(2^r - 1,\\, 2^n - 1) = 1$.\n\\end{lemma}\n\\begin{proof}\n By the identity $\\gcd(2^r - 1, 2^n - 1) = 2^{\\gcd(r,n)} - 1$. Since $n$ is prime and\n $1 \\leq r < n$, we have $\\gcd(r, n) = 1$, so $\\gcd(2^r - 1, 2^n - 1) = 2^1 - 1 = 1$.\n\\end{proof}\n\n\\begin{lemma}[$2^n = 1$ in $\\mathbb{Z}/(2^n-1)\\mathbb{Z}$]\n \\label{lem:vantieghem_two_pow_eq_one_zmod}\n \\lean{Vantieghem.two_pow_eq_one_zmod}\n For $n \\geq 1$, $(2 : \\mathrm{ZMod}\\,(2^n - 1))^n = 1$.\n\\end{lemma}\n\\begin{proof}\n This follows from the fact that $2^n - 1 \\mid 2^n - 1$, translating to\n $2^n \\equiv 1 \\pmod{2^n - 1}$ in $\\mathrm{ZMod}$.\n\\end{proof}\n\n\\begin{lemma}[Powers of two are roots of $X^n - 1$]\n \\label{lem:vantieghem_root_of_xn_sub_one}\n \\lean{Vantieghem.root_of_xn_sub_one}\n \\uses{lem:vantieghem_two_pow_eq_one_zmod}\n For $n \\geq 1$ and $k < n$, $((2 : \\mathrm{ZMod}\\,(2^n-1))^k)^n = 1$.\n\\end{lemma}\n\\begin{proof}\n Rewrite $((2^k)^n) = (2^n)^k = 1^k = 1$ using the fact that $2^n = 1$ in $\\mathrm{ZMod}\\,(2^n-1)$.\n\\end{proof}\n\n\\begin{lemma}[Powers of two are pairwise distinct in $\\mathrm{ZMod}$]\n \\label{lem:vantieghem_powers_of_two_distinct_zmod}\n \\lean{Vantieghem.powers_of_two_distinct_zmod}\n \\uses{lem:vantieghem_gcd_mersenne_prime}\n If $n$ is prime and $a, b < n$ with $2^a \\equiv 2^b \\pmod{2^n - 1}$, then $a = b$.\n\\end{lemma}\n\\begin{proof}\n Assume without loss of generality $a < b$ and set $r = b - a$, so $1 \\leq r < n$.\n From $2^a \\equiv 2^b$, cancelling $2^a$ (coprime to $2^n - 1$ since $2^n - 1$ is odd)\n gives $1 \\equiv 2^r$, so $2^n - 1 \\mid 2^r - 1$. But $\\gcd(2^r - 1, 2^n - 1) = 1$ by the\n Mersenne GCD lemma, forcing $2^n - 1 = 1$, contradicting $n \\geq 2$.\n\\end{proof}\n\n\\begin{lemma}[Key integer congruence for the forward direction]\n \\label{lem:vantieghem_key_int_congruence}\n \\lean{Vantieghem.key_int_congruence}\n \\uses{lem:vantieghem_powers_of_two_distinct_zmod, lem:vantieghem_root_of_xn_sub_one, lem:vantieghem_two_pow_eq_one_zmod}\n For $n \\geq 3$ prime, $(2^n - 1) \\mid \\prod_{k=1}^{n-1}(1 - 2^k) - n$ in $\\mathbb{Z}$.\n\\end{lemma}\n\\begin{proof}\n Work in $R = \\mathrm{ZMod}(2^n - 1)$. The elements $1, 2, \\ldots, 2^{n-1}$ are pairwise\n distinct roots of $X^n - 1$ in $R[X]$. Let $f = X^n - 1$ and $g = \\prod_{k=0}^{n-1}(X - 2^k)$;\n both are monic of degree $n$ and vanish on the same $n$ points, so $f = g$.\n Differentiating and evaluating at $X = 1$: $f'(1) = n$, while for $g'(1)$ only the $j = 0$\n term survives (all other terms contain the factor $1 - 2^0 = 0$), giving\n $g'(1) = \\prod_{k=1}^{n-1}(1 - 2^k)$. The resulting equality in $R$ lifts to the\n stated $\\mathbb{Z}$-divisibility.\n\\end{proof}\n\n\\begin{lemma}[Sign correction in $\\mathbb{Z}$]\n \\label{lem:vantieghem_sign_correction_int}\n \\lean{Vantieghem.sign_correction_int}\n For $n \\geq 2$, $\\prod_{k=1}^{n-1}(2^k - 1) = (-1)^{n-1} \\prod_{k=1}^{n-1}(1 - 2^k)$\n in $\\mathbb{Z}$.\n\\end{lemma}\n\\begin{proof}\n Each factor satisfies $2^k - 1 = (-1)(1 - 2^k)$. Multiplying over $k = 1, \\ldots, n-1$\n introduces a sign of $(-1)^{n-1}$.\n\\end{proof}\n\n\\begin{lemma}[$(-1)^{n-1} = 1$ for odd prime $n$]\n \\label{lem:vantieghem_neg_one_pow_even_sub_one}\n \\lean{Vantieghem.neg_one_pow_even_sub_one}\n If $n$ is prime and $n \\geq 3$, then $(-1 : \\mathbb{Z})^{n-1} = 1$.\n\\end{lemma}\n\\begin{proof}\n Since $n \\geq 3$ is an odd prime, $n - 1$ is even, so $(-1)^{n-1} = 1$.\n\\end{proof}\n\n\\begin{lemma}[Forward integer divisibility]\n \\label{lem:vantieghem_forward_int_dvd}\n \\lean{Vantieghem.forward_int_dvd}\n \\uses{lem:vantieghem_sign_correction_int, lem:vantieghem_neg_one_pow_even_sub_one, lem:vantieghem_key_int_congruence}\n For $n \\geq 3$ prime, $(2^n - 1) \\mid \\prod_{k=1}^{n-1}(2^k - 1) - n$ in $\\mathbb{Z}$.\n\\end{lemma}\n\\begin{proof}\n Combine the sign correction with the key congruence. Since $(-1)^{n-1} = 1$ for odd prime $n$,\n the product $\\prod(2^k - 1)$ equals $\\prod(1 - 2^k)$, and the $\\mathbb{Z}$-divisibility follows.\n\\end{proof}\n\n\\begin{lemma}[Forward direction]\n \\label{lem:vantieghem_forward_direction}\n \\lean{Vantieghem.forward_direction}\n \\uses{lem:vantieghem_prod_ge_n, lem:vantieghem_forward_int_dvd}\n For $n \\geq 3$ prime, $\\prod_{k=1}^{n-1}(2^k - 1) \\equiv n \\pmod{2^n - 1}$.\n\\end{lemma}\n\\begin{proof}\n The forward integer divisibility gives $(2^n-1) \\mid \\prod(2^k-1) - n$ in $\\mathbb{Z}$.\n Since $\\prod_{k=1}^{n-1}(2^k-1) \\geq n$ (the product lower bound), both sides are natural\n numbers and the divisibility lifts to the natural number congruence.\n\\end{proof}\n\n\\begin{lemma}[$(2^d - 1)$ divides the product]\n \\label{lem:vantieghem_factor_dvd_prod}\n \\lean{Vantieghem.factor_dvd_prod}\n If $1 \\leq d < n$, then $(2^d - 1) \\mid \\prod_{k=1}^{n-1}(2^k - 1)$.\n\\end{lemma}\n\\begin{proof}\n Since $1 \\le d < n$, the factor $2^d - 1$ appears in the product,\n so it divides the product.\n\\end{proof}\n\n\\begin{lemma}[Congruence forces $(2^d - 1) \\mid n$]\n \\label{lem:vantieghem_divisor_divides_n}\n \\lean{Vantieghem.divisor_divides_n}\n \\uses{lem:vantieghem_factor_dvd_prod}\n If $n \\geq 3$, the congruence holds, $d \\mid n$, and $2 \\leq d \\leq n - 1$,\n then $(2^d - 1) \\mid n$.\n\\end{lemma}\n\\begin{proof}\n Since $d \\mid n$: $(2^d-1) \\mid (2^n-1)$. Since $1 \\leq d \\leq n-1$: $(2^d-1) \\mid \\prod$.\n The congruence gives $(2^n-1) \\mid \\prod - n$, hence $(2^d-1) \\mid \\prod - n$.\n Combined with $(2^d-1) \\mid \\prod$, we conclude $(2^d-1) \\mid n$.\n\\end{proof}\n\n\\begin{lemma}[Small composite witness]\n \\label{lem:vantieghem_not_dvd_of_small_composite}\n \\lean{Vantieghem.not_dvd_of_small_composite}\n For composite $n$ with $3 \\leq n \\leq 31$, there exists $d$ with $d \\mid n$,\n $2 \\leq d \\leq n-1$, and $(2^d - 1) \\nmid n$.\n\\end{lemma}\n\\begin{proof}\n Verified by casework over all composite values of $n$ in $[3, 31]$.\n\\end{proof}\n\n\\begin{lemma}[Small composites fail the congruence]\n \\label{lem:vantieghem_backward_small}\n \\lean{Vantieghem.backward_small}\n \\uses{lem:vantieghem_not_dvd_of_small_composite, lem:vantieghem_divisor_divides_n}\n For composite $n$ with $3 \\leq n \\leq 31$, the congruence\n $\\prod_{k=1}^{n-1}(2^k - 1) \\equiv n \\pmod{2^n - 1}$ cannot hold.\n\\end{lemma}\n\\begin{proof}\n The witness lemma gives $d$ with $d \\mid n$, $2 \\leq d \\leq n-1$, and $(2^d-1) \\nmid n$.\n If the congruence held, the divisor lemma would force $(2^d-1) \\mid n$, a contradiction.\n\\end{proof}\n\n\\begin{lemma}[$\\mathrm{minFac}(n) \\leq n / \\mathrm{minFac}(n)$ for composite $n$]\n \\label{lem:vantieghem_minFac_le_sqrt}\n \\lean{Vantieghem.minFac_le_sqrt}\n For composite $n \\geq 2$, $\\mathrm{minFac}(n) \\leq n / \\mathrm{minFac}(n)$.\n\\end{lemma}\n\\begin{proof}\n For composite $n$, $\\mathrm{minFac}(n)^2 \\leq n$, so $\\mathrm{minFac}(n) \\leq n / \\mathrm{minFac}(n)$.\n\\end{proof}\n\n\\begin{lemma}[$n / \\mathrm{minFac}(n) \\geq 6$ for large composite $n$]\n \\label{lem:vantieghem_div_minFac_ge_six}\n \\lean{Vantieghem.div_minFac_ge_six}\n \\uses{lem:vantieghem_minFac_le_sqrt}\n For composite $n \\geq 32$, $n / \\mathrm{minFac}(n) \\geq 6$.\n\\end{lemma}\n\\begin{proof}\n Let $d = n / \\mathrm{minFac}(n)$. Since $\\mathrm{minFac}(n) \\leq d$ and $n \\leq d^2$,\n combined with $n \\geq 32$, we get $d^2 \\geq 32$, which forces $d \\geq 6$.\n\\end{proof}\n\n\\begin{lemma}[$n / \\mathrm{minFac}(n)$ divides $n$]\n \\label{lem:vantieghem_div_minFac_dvd}\n \\lean{Vantieghem.div_minFac_dvd}\n For $n \\geq 2$, $(n / \\mathrm{minFac}(n)) \\mid n$.\n\\end{lemma}\n\\begin{proof}\n Since $\\mathrm{minFac}(n) \\mid n$, the quotient $n / \\mathrm{minFac}(n)$ also divides $n$.\n\\end{proof}\n\n\\begin{lemma}[$n / \\mathrm{minFac}(n) \\leq n - 1$]\n \\label{lem:vantieghem_div_minFac_le_pred}\n \\lean{Vantieghem.div_minFac_le_pred}\n For $n \\geq 2$, $n / \\mathrm{minFac}(n) \\leq n - 1$.\n\\end{lemma}\n\\begin{proof}\n Since $\\mathrm{minFac}(n) \\geq 2$, we have $n / \\mathrm{minFac}(n) \\leq n / 2 \\leq n - 1$.\n\\end{proof}\n\n\\begin{lemma}[$n \\leq (n / \\mathrm{minFac}(n))^2$ for composite $n$]\n \\label{lem:vantieghem_n_le_sq_div_minFac}\n \\lean{Vantieghem.n_le_sq_div_minFac}\n \\uses{lem:vantieghem_minFac_le_sqrt}\n For composite $n \\geq 2$, $n \\leq (n / \\mathrm{minFac}(n))^2$.\n\\end{lemma}\n\\begin{proof}\n Let $d = n / \\mathrm{minFac}(n)$. Since $\\mathrm{minFac}(n) \\leq d$ and\n $\\mathrm{minFac}(n) \\cdot d = n$, we get $n = \\mathrm{minFac}(n) \\cdot d \\leq d \\cdot d = d^2$.\n\\end{proof}\n\n\\begin{lemma}[Large composite has a suitable divisor]\n \\label{lem:vantieghem_backward_large_aux}\n \\lean{Vantieghem.backward_large_aux}\n \\uses{lem:vantieghem_div_minFac_ge_six, lem:vantieghem_div_minFac_dvd, lem:vantieghem_div_minFac_le_pred, lem:vantieghem_n_le_sq_div_minFac, lem:vantieghem_sq_lt_pow}\n For composite $n \\geq 32$, there exists $d$ with $d \\mid n$, $2 \\leq d \\leq n-1$,\n and $n < 2^d - 1$.\n\\end{lemma}\n\\begin{proof}\n Take $d = n / \\mathrm{minFac}(n)$. Then $d \\geq 6$, $d \\mid n$, $d \\leq n-1$, and\n $n \\leq d^2 < 2^d$ by the square-less-than-power lemma for $d \\geq 5$. A sharper bound\n $d^2 + 2 \\leq 2^d$ (from applying the same lemma at $d-1$) yields $n < 2^d - 1$.\n\\end{proof}\n\n\\begin{lemma}[Large composites fail the congruence]\n \\label{lem:vantieghem_backward_large}\n \\lean{Vantieghem.backward_large}\n \\uses{lem:vantieghem_backward_large_aux, lem:vantieghem_divisor_divides_n}\n For composite $n \\geq 32$ with $n \\geq 3$, the congruence\n $\\prod_{k=1}^{n-1}(2^k-1) \\equiv n \\pmod{2^n-1}$ cannot hold.\n\\end{lemma}\n\\begin{proof}\n The auxiliary lemma gives $d$ with $d \\mid n$, $2 \\leq d \\leq n-1$, and $n < 2^d - 1$.\n If the congruence held, the divisor lemma would give $(2^d-1) \\mid n$. But\n $0 < n < 2^d - 1$ makes this impossible.\n\\end{proof}\n\n\\begin{lemma}[Backward direction]\n \\label{lem:vantieghem_backward_direction}\n \\lean{Vantieghem.backward_direction}\n \\uses{lem:vantieghem_backward_small, lem:vantieghem_backward_large}\n For $n \\geq 3$, if $\\prod_{k=1}^{n-1}(2^k-1) \\equiv n \\pmod{2^n-1}$, then $n$ is prime.\n\\end{lemma}\n\\begin{proof}\n Suppose $n$ is composite. If $3 \\leq n \\leq 31$ the small case lemma gives a contradiction.\n If $n \\geq 32$ the large case lemma gives a contradiction. Hence $n$ must be prime.\n\\end{proof}\n\n\\begin{theorem}[Vantieghem's Theorem]\n \\label{thm:vantieghem}\n \\lean{vantieghem}\n \\uses{lem:vantieghem_forward_direction, lem:vantieghem_backward_direction}\n For $n \\geq 3$, $n$ is prime if and only if\n $\\prod_{k=1}^{n-1}(2^k - 1) \\equiv n \\pmod{2^n - 1}$.\n\\end{theorem}\n\\begin{proof}\n The forward implication is the forward direction lemma, and the backward implication\n is the backward direction lemma.\n\\end{proof}\n", "code": "import Mathlib\n\n\nset_option maxHeartbeats 1600000 in\n\n\nopen Nat Finset BigOperators\n\n\ntheorem vantieghem {n : ℕ} (hn : 3 ≤ n) :\n n.Prime ↔ (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := sorry"} -{"project_name": "VonStaudtClausen", "name": "von_staudt_clausen", "type": "theorem", "title": "Von Staudt-Clausen Theorem", "informal_statement": "For any positive integer $n$, the Bernoulli number $B_{2n}$ can be expressed as\n $B_{2n} = I_n - \\sum_{(p-1)|2n} \\frac{1}{p}$\n where $I_n$ is an integer and the sum is over all prime numbers $p$ such that $p-1$ divides $2n$. This is equivalent to saying that $B_{2n} + \\sum_{(p-1)|2n} \\frac{1}{p}$ is an integer.", "informal_proof": "\\chapter{Von Staudt-Clausen Theorem}\n\nThis section contains a proof of the Von Staudt-Clausen Theorem.\nSee \\url{https://en.wikipedia.org/wiki/Von_Staudt%E2%80%93Clausen_theorem} for more details.\n\n\\begin{lemma}[Explicit Formula for Bernoulli Numbers]\n \\label{lem:Bernoulli_Number_Explicit_Formula}\n \\lean{bernoulli_two_mul_eq_sum}\n An explicit formula for the (even indexed) Bernoulli numbers is given for positive even $n$ by:\n $B_{2n} = \\sum_{j=0}^{2n} \\frac{1}{j+1} \\sum_{m=0}^{j} (-1)^m \\binom{j}{m} m^{2n}$.\n\\end{lemma}\n\n\\begin{proof}\n This follows from applying the Mercator series to the forward difference operator.\n % TODO this proof could be made more detailed\n\\end{proof}\n\nNote that more explanation of the above theorem can be found at \\url{https://en.wikipedia.org/wiki/Bernoulli_polynomials#Another_explicit_formula}.\n\n\\begin{lemma}[Explicit Formula for Stirling Numbers of the Second Kind]\n \\label{lem:Stirling_Number_Second_kind_Explicit_Formula}\n \\lean{stirlingSecond_kind_explicit_formula}\n An explicit formula for the Stirling numbers of the second kind is given by:\n $S(n, k) = \\frac{1}{k!} \\sum_{j=0}^{k} (-1)^{k-j} \\binom{k}{j} j^n$.\n\\end{lemma}\n\n\\begin{proof}\n This follows by using inclusion-exclusion to show that the number of surjections from n to k is\n given by $\\sum_{j=0}^{k} (-1)^{k-j} \\binom{k}{j} j^n$,\n and then dividing by $k!$ for indistinguishability of the subsets.\n\\end{proof}\n\nNote that this means we can substitute the formula for Stirling numbers of the second kind into the explicit formula for Bernoulli numbers to get another formula for Bernoulli numbers in terms of Stirling numbers.\n\n\\begin{lemma}[Sum of Binomial Coefficients Modulo p]\n \\label{lem:Sum_of_Binomial_Coefficients_Modulo_p}\n \\lean{sum_neg_one_pow_mul_choose_mul_pow_two_mul}\n Let $p$ be a prime number. Then, for $n \\geq 1$, we have the following congruences:\n \\begin{enumerate}\n \\item If $p-1$ divides $2n$, then $\\sum_{m=0}^{p-1} (-1)^m \\binom{p-1}{m} m^{2n} \\equiv -1 \\pmod{p}$.\n \\item If $p-1$ does not divide $2n$, then $\\sum_{m=0}^{p-1} (-1)^m \\binom{p-1}{m} m^{2n} \\equiv 0 \\pmod{p}$.\n \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n By Fermat's Little Theorem, $m^{p-1} \\equiv 1 \\pmod{p}$ for $m = 1, 2, \\dots, p-1$.\n\n Case 1: If $p-1$ divides $2n$, then $m^{2n} \\equiv 1 \\pmod{p}$ for $m=1, \\dots, p-1$.\n Therefore,\n $\\sum_{m=1}^{p-1} (-1)^m \\binom{p-1}{m} m^{2n} \\equiv \\sum_{m=1}^{p-1} (-1)^m \\binom{p-1}{m} \\pmod{p}$.\n From the binomial expansion of $(1-1)^{p-1} = \\sum_{m=0}^{p-1} (-1)^m \\binom{p-1}{m}$, we have\n $0 = 1 + \\sum_{m=1}^{p-1} (-1)^m \\binom{p-1}{m}$, so $\\sum_{m=1}^{p-1} (-1)^m \\binom{p-1}{m} = -1$.\n Thus, $\\sum_{m=0}^{p-1} (-1)^m \\binom{p-1}{m} m^{2n} \\equiv -1 \\pmod{p}$.\n\n Case 2: If $p-1$ does not divide $2n$, let $2n = q(p-1) + r$ where $0 < r < p-1$.\n Then $m^{2n} \\equiv (m^{p-1})^q m^r \\equiv m^r \\pmod{p}$ for $m=1, \\dots, p-1$.\n We need to evaluate $\\sum_{m=0}^{p-1} (-1)^m \\binom{p-1}{m} m^r \\pmod{p}$.\n Using the identity $\\binom{p-1}{m} \\equiv (-1)^m \\pmod{p}$, the sum becomes\n $\\sum_{m=0}^{p-1} m^r \\pmod{p}$.\n For $0 < r < p-1$, the sum of powers $\\sum_{m=0}^{p-1} m^r$ is congruent to $0 \\pmod{p}$.\n Therefore, $\\sum_{m=0}^{p-1} (-1)^m \\binom{p-1}{m} m^{2n} \\equiv 0 \\pmod{p}$.\n\\end{proof}\n\n\\begin{lemma}[Integer Property of Composite Denominators]\n \\label{lem:Integer_Property_of_Composite_Denominators}\n \\lean{composite_dvd_factorial}\n If $j+1$ is a composite number greater than 4, then $\\frac{j!}{j+1}$ is an integer.\n\\end{lemma}\n\n\\begin{proof}\n If $j+1$ is composite and $j+1 > 4$, then either $j+1 = ab$ for integers $a, b$ with $1 < a < b \\le j$, in which case $a$ and $b$ are distinct factors in $j!$, so $(j+1) | j!$. Or $j+1 = p^2$ for some prime $p$. If $p>2$, then $p$ and $2p$ are factors in $(p^2-1)!$, so $p^2 | (p^2-1)!$. If $p=2$, $j+1=4$, which is excluded. For all these cases, $\\frac{j!}{j+1}$ is an integer.\n\\end{proof}\n\n\n\\begin{theorem}[Von Staudt-Clausen Theorem]\n \\label{thm:Von_Staudt-Clausen}\n \\lean{von_staudt_clausen}\n For any positive integer $n$, the Bernoulli number $B_{2n}$ can be expressed as\n $B_{2n} = I_n - \\sum_{(p-1)|2n} \\frac{1}{p}$\n where $I_n$ is an integer and the sum is over all prime numbers $p$ such that $p-1$ divides $2n$. This is equivalent to saying that $B_{2n} + \\sum_{(p-1)|2n} \\frac{1}{p}$ is an integer.\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:Bernoulli_Number_Explicit_Formula}\n \\uses{lem:Sum_of_Binomial_Coefficients_Modulo_p}\n \\uses{lem:Integer_Property_of_Composite_Denominators}\n \\uses{lem:Stirling_Number_Second_kind_Explicit_Formula}\n\n We start with the explicit formula for Bernoulli numbers given in~\\ref{lem:Bernoulli_Number_Explicit_Formula}:\n $B_{2n} = \\sum_{j=0}^{2n} \\frac{1}{j+1} \\sum_{m=0}^{j} (-1)^m \\binom{j}{m} m^{2n}$.\n\n We analyze the term $\\frac{1}{j+1} \\sum_{m=0}^{j} (-1)^m \\binom{j}{m} m^{2n}$ for each $j$.\n Let $A_j = \\sum_{m=0}^{j} (-1)^m \\binom{j}{m} m^{2n}$.\n\n For the case $j=3$, so $j+1=4$, we examine the corresponding numerator:\n $\\sum_{m=0}^{3} (-1)^m \\binom{3}{m} m^{2n} = -1 + 3 \\cdot 1^{2n} - 3 \\cdot 2^{2n} + 1 \\cdot 3^{2n} = 3(3^{2n-1} - 2^{2n} + 1)$.\n For $n \\ge 1$, this is always divisible by 4. Specifically, for $n=1$, we get $3(3-4+1)=0$. For $n>1$, $3^{2n-1}$ is an odd power of 3, so it is 3 mod 4. $2^{2n}$ is divisible by 4. So the expression is $3(3-0+1) = 12 \\equiv 0 \\pmod{4}$.\n Thus, the term for $j=3$ contributes an integer.\n\n If $j+1$ is a prime number $p$, then $j=p-1$. From lemma \\ref{lem:Sum_of_Binomial_Coefficients_Modulo_p}, we have two cases:\n \\begin{itemize}\n \\item If $p-1$ divides $2n$, then $A_{p-1} \\equiv -1 \\pmod{p}$. This implies $A_{p-1} = kp - 1$ for some integer $k$. The term for $j=p-1$ is $\\frac{kp-1}{p} = k - \\frac{1}{p}$.\n \\item If $p-1$ does not divide $2n$, then $A_{p-1} \\equiv 0 \\pmod{p}$. This implies $A_{p-1} = kp$, so the term is $\\frac{kp}{p} = k$, an integer.\n \\end{itemize}\n\n If $j+1$ is a composite number $> 4$, from lemma \\ref{lem:Integer_Property_of_Composite_Denominators}, the term $\\frac{j!}{j+1}$ is an integer. Furthermore, from \\ref{lem:Stirling_Number_Second_kind_Explicit_Formula} shows that the other component of this term is also an integer. Thus, the entire term for composite $j+1 > 4$ is an integer.\n\n Combining these results, we can write the formula for $B_{2n}$ as a sum of terms. The terms where $j+1$ is composite contribute an integer value. The terms where $j+1$ is a prime $p$ such that $p-1$ does not divide $2n$ also contribute an integer value. The only fractional parts come from the terms where $j+1$ is a prime $p$ such that $p-1$ divides $2n$. Each of these terms contributes $-\\frac{1}{p}$ to the fractional part.\n\n Therefore, $B_{2n}$ can be written as an integer $I_n$ (the sum of all integer parts) minus the sum of the fractional parts $\\frac{1}{p}$ for all primes $p$ where $p-1$ divides $2n$.\n\n $B_{2n} = I_n - \\sum_{(p-1)|2n} \\frac{1}{p}$.\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem von_staudt_clausen (n : ℕ) (hn : 1 ≤ n) :\n IsLocalization.IsInteger ℤ (bernoulli (2 * n) + ∑ j ∈ (Finset.range (2 * n + 1)).filter\n (fun j => (j + 1).Prime) , if j ∣ (2 * n) then (1 : ℚ) / (j+1) else 0) := by sorry"} -{"project_name": "WaringProblem", "name": "waring", "type": "theorem", "title": "Waring's Problem", "informal_statement": "TODO", "informal_proof": "\\chapter{Waring's Problem}\n\nThis section contains a (stub of a) proof of Waring's problem.\nSee \\url{https://en.wikipedia.org/wiki/Waring%27s_problem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Waring's Problem]\n \\label{thm:waring-problem}\n \\lean{waring}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem waring (n : ℕ) : ∃ t : ℕ,\n ∀ k, ∃ s : Finset ℕ, s.card ≤ t ∧ k = ∑ i ∈ s, i ^ n := by sorry"} -{"project_name": "Wolstenholme", "name": "wolstenholme", "type": "theorem", "title": "Wolstenholme's theorem", "informal_statement": "For every prime $p \\ge 5$,\n \\[\n \\binom{2p-1}{p-1} \\equiv 1 \\pmod{p^3}.\n \\]", "informal_proof": "\\chapter{Wolstenholme's Theorem}\n\nThis section contains a proof of Wolstenholme's theorem: for every prime $p \\ge 5$, the central binomial coefficient\n$\\binom{2p-1}{p-1} \\equiv 1 \\pmod{p^3}$.\nSee \\url{https://en.wikipedia.org/wiki/Wolstenholme\\%27s_theorem} for more details.\n\n%---------------------------------------------------------------------------\n\\section{Factorial and binomial identities}\n%---------------------------------------------------------------------------\n\n\\begin{lemma}[Choose times factorial equals product]\n \\label{lem:wolst_choose_mul_factorial_eq_prod}\n \\lean{Wolstenholme.choose_mul_factorial_eq_prod}\n \\uses{}\n For any natural number $p \\ge 1$,\n \\[\n \\binom{2p-1}{p-1} \\cdot (p-1)! = \\prod_{k=1}^{p-1}(p+k).\n \\]\n\\end{lemma}\n\\begin{proof}\n The descending factorial $(2p-1)^{\\underline{p-1}}$ equals $(p-1)! \\cdot \\binom{2p-1}{p-1}$ by\n the standard identity, and also equals $\\prod_{k=1}^{p-1}(p+k)$ after a reflection of the\n index range.\n\\end{proof}\n\n\\begin{lemma}[Factorial coprime to prime cube]\n \\label{lem:wolst_factorial_coprime_prime_cube}\n \\lean{Wolstenholme.factorial_coprime_prime_cube}\n \\uses{}\n If $p$ is prime, then $\\gcd\\bigl((p-1)!,\\, p^3\\bigr) = 1$.\n\\end{lemma}\n\\begin{proof}\n Every factor in $(p-1)!$ is strictly less than $p$, so $p$ is coprime to $(p-1)!$, and hence\n $p^3$ is coprime to $(p-1)!$.\n\\end{proof}\n\n\\begin{lemma}[Cancelling the factorial]\n \\label{lem:wolst_cancel_factorial}\n \\lean{Wolstenholme.cancel_factorial}\n \\uses{lem:wolst_choose_mul_factorial_eq_prod, lem:wolst_factorial_coprime_prime_cube}\n If $p$ is prime and $p \\ge 5$, then\n \\[\n \\binom{2p-1}{p-1} \\equiv 1 \\pmod{p^3}\n \\;\\Longleftrightarrow\\;\n \\prod_{k=1}^{p-1}(p+k) \\equiv (p-1)! \\pmod{p^3}.\n \\]\n\\end{lemma}\n\\begin{proof}\n By Lemma~\\ref{lem:wolst_choose_mul_factorial_eq_prod}, $\\binom{2p-1}{p-1}\\cdot(p-1)! =\n \\prod_{k=1}^{p-1}(p+k)$. Since $\\gcd((p-1)!, p^3)=1$\n (Lemma~\\ref{lem:wolst_factorial_coprime_prime_cube}), $(p-1)!$ can be cancelled from both\n sides of the congruence.\n\\end{proof}\n\n%---------------------------------------------------------------------------\n\\section{Working in ZMod}\n%---------------------------------------------------------------------------\n\n\\begin{lemma}[Sum of inverses is zero in ZMod p]\n \\label{lem:wolst_sum_inv_eq_zero_zmod}\n \\lean{Wolstenholme.sum_inv_eq_zero_zmod}\n \\uses{}\n For an odd prime $p$,\n \\[\n \\sum_{k=1}^{p-1} k^{-1} = 0 \\quad \\text{in } \\mathbb{Z}/p\\mathbb{Z}.\n \\]\n\\end{lemma}\n\\begin{proof}\n The map $k \\mapsto p - k$ is an involution on $\\{1,\\ldots,p-1\\}$ satisfying\n $(p-k)^{-1} = -k^{-1}$ in $\\mathbb{Z}/p\\mathbb{Z}$, so the sum equals its own negation.\n Since $p$ is odd, $2$ is invertible, forcing the sum to be zero.\n\\end{proof}\n\n\\begin{lemma}[Sum of squares is zero in ZMod p]\n \\label{lem:wolst_sum_sq_eq_zero_zmod}\n \\lean{Wolstenholme.sum_sq_eq_zero_zmod}\n \\uses{}\n For a prime $p \\ge 5$,\n \\[\n \\sum_{k=1}^{p-1} k^2 = 0 \\quad \\text{in } \\mathbb{Z}/p\\mathbb{Z}.\n \\]\n\\end{lemma}\n\\begin{proof}\n Multiply both sides by $6$; by the closed form $6\\sum_{k=1}^{n}k^2 = n(n+1)(2n+1)$,\n the sum at $n=p-1$ becomes $(p-1)\\cdot p\\cdot(2p-1)$, which contains the factor $p$,\n hence is zero mod $p$. Since $p\\ge 5$ the factor $6$ is invertible mod $p$.\n\\end{proof}\n\n\\begin{lemma}[Sum of inverse squares equals sum of squares in ZMod p]\n \\label{lem:wolst_sum_inv_sq_eq_sum_sq}\n \\lean{Wolstenholme.sum_inv_sq_eq_sum_sq}\n \\uses{lem:wolst_sum_sq_eq_zero_zmod}\n For a prime $p \\ge 5$,\n \\[\n \\sum_{k=1}^{p-1} k^{-2} = \\sum_{k=1}^{p-1} k^2 \\quad \\text{in } \\mathbb{Z}/p\\mathbb{Z}.\n \\]\n\\end{lemma}\n\\begin{proof}\n The map $k \\mapsto k^{-1}$ is a bijection on $\\{1,\\ldots,p-1\\}$ in $\\mathbb{Z}/p\\mathbb{Z}$,\n sending $k^{-2}$ to $(k^{-1})^{-2} = k^2$. A formal reindexing of the sum via this\n bijection gives the equality.\n\\end{proof}\n\n\\begin{lemma}[Sum of inverse squares is zero in ZMod p]\n \\label{lem:wolst_sum_inv_sq_eq_zero_zmod}\n \\lean{Wolstenholme.sum_inv_sq_eq_zero_zmod}\n \\uses{lem:wolst_sum_inv_sq_eq_sum_sq, lem:wolst_sum_sq_eq_zero_zmod}\n For a prime $p \\ge 5$,\n \\[\n \\sum_{k=1}^{p-1} k^{-2} = 0 \\quad \\text{in } \\mathbb{Z}/p\\mathbb{Z}.\n \\]\n\\end{lemma}\n\\begin{proof}\n By Lemma~\\ref{lem:wolst_sum_inv_sq_eq_sum_sq} this equals $\\sum k^2$, which vanishes by\n Lemma~\\ref{lem:wolst_sum_sq_eq_zero_zmod}.\n\\end{proof}\n\n%---------------------------------------------------------------------------\n\\section{Lifting to integer divisibility}\n%---------------------------------------------------------------------------\n\n\\begin{lemma}[Sum of cross-products divisible by p]\n \\label{lem:wolst_sum_inv_zero_mod_p}\n \\lean{Wolstenholme.sum_inv_zero_mod_p}\n \\uses{lem:wolst_sum_inv_eq_zero_zmod}\n For a prime $p \\ge 5$,\n \\[\n p \\;\\Big|\\; \\sum_{k=1}^{p-1} \\prod_{j \\ne k} j \\quad \\text{in } \\mathbb{Z}.\n \\]\n\\end{lemma}\n\\begin{proof}\n Cast to $\\mathbb{Z}/p\\mathbb{Z}$. Each term $\\prod_{j\\ne k} j$ equals $(p-1)!\\cdot k^{-1}$.\n Factoring out the common $(p-1)!$, the sum reduces to $(p-1)!\\cdot\\sum k^{-1}$, which is\n zero by Lemma~\\ref{lem:wolst_sum_inv_eq_zero_zmod}.\n\\end{proof}\n\n\\begin{lemma}[Sum of cross-products divisible by p squared]\n \\label{lem:wolst_sum_inv_zero_mod_p_sq}\n \\lean{Wolstenholme.sum_inv_zero_mod_p_sq}\n \\uses{lem:wolst_sum_inv_zero_mod_p, lem:wolst_sum_inv_sq_eq_zero_zmod}\n For a prime $p \\ge 5$,\n \\[\n p^2 \\;\\Big|\\; \\sum_{k=1}^{p-1} \\prod_{j \\ne k} j \\quad \\text{in } \\mathbb{Z}.\n \\]\n\\end{lemma}\n\\begin{proof}\n Let $S$ denote the sum. Pairing each term with its reflection and using Wilson's theorem\n shows $2S = p \\cdot T$ where $T = \\sum_k \\prod_{j \\ne k, j \\ne p-2-k} j$. Since $p$\n divides $T$ (by reducing to $\\sum k^{-2} = 0$ mod $p$ via\n Lemma~\\ref{lem:wolst_sum_inv_sq_eq_zero_zmod}), we get $p^2 \\mid 2S$. Coprimality of $p$\n with $2$ then gives $p^2 \\mid S$.\n\\end{proof}\n\n\\begin{lemma}[Square of sum identity]\n \\label{lem:wolst_sq_sum_eq}\n \\lean{Wolstenholme.sq_sum_eq}\n \\uses{}\n In any commutative ring, for a sequence $a_0, \\ldots, a_{n-1}$,\n \\[\n \\Bigl(\\sum_{i=0}^{n-1} a_i\\Bigr)^2\n = \\sum_{i=0}^{n-1} a_i^2 + 2\\!\\!\\sum_{0 \\le i < j < n}\\!\\! a_i a_j.\n \\]\n\\end{lemma}\n\\begin{proof}\n Expand the square $(\\sum a_i)^2 = \\sum_i\\sum_j a_i a_j$, split the double sum according to\n whether $i=j$, $ij$, and use commutativity to combine the off-diagonal terms.\n\\end{proof}\n\n\\begin{lemma}[Sum of cross-inverse products is zero in ZMod p]\n \\label{lem:wolst_sum_cross_inv_eq_zero_zmod}\n \\lean{Wolstenholme.sum_cross_inv_eq_zero_zmod}\n \\uses{lem:wolst_sum_inv_eq_zero_zmod, lem:wolst_sum_inv_sq_eq_zero_zmod, lem:wolst_sq_sum_eq}\n For a prime $p \\ge 5$,\n \\[\n \\sum_{1 \\le i < j \\le p-1} i^{-1} j^{-1} = 0 \\quad \\text{in } \\mathbb{Z}/p\\mathbb{Z}.\n \\]\n\\end{lemma}\n\\begin{proof}\n By Lemma~\\ref{lem:wolst_sq_sum_eq} applied to $(a_k) = (k^{-1})$, the square of\n $\\sum k^{-1}$ equals $\\sum k^{-2} + 2\\sum_{i \\sigma(i+1)\\}$ be the set of descents. Let $k = |\\mathrm{Asc}(\\sigma)|$ and $d = |\\mathrm{Des}(\\sigma)|$. Then:\n \\[ k + d = n - 1 \\]\n\\end{lemma}\n\n\\begin{proof}\n The set of indices considered for ascents and descents is $\\{0, 1, \\dots, n-2\\}$, which has cardinality $n-1$. Since $\\sigma$ is a permutation, all elements are distinct, so for any $i$, $\\sigma(i) \\neq \\sigma(i+1)$. Therefore, the relation must be either $\\sigma(i) < \\sigma(i+1)$ (an ascent) or $\\sigma(i) > \\sigma(i+1)$ (a descent). The sets $\\mathrm{Asc}(\\sigma)$ and $\\mathrm{Des}(\\sigma)$ partition the set of indices, so their sizes sum to $n-1$.\n\\end{proof}\n\n\\begin{lemma}[Insertion Bijection]\n \\label{lem:insertion_bijection}\n \\lean{perm_down_bij}\n For $n \\in \\mathbb{N}$, let $\\mathcal{I}: S_n \\times \\{0, \\dots, n\\} \\to S_{n+1}$ be the map where $\\mathcal{I}(\\sigma, j)$ is the permutation obtained by inserting the element $n+1$ into the sequence $\\sigma(0), \\dots, \\sigma(n-1)$ at position $j$ (specifically, before the element at index $j$ if $j < n$, or appended to the end if $j=n$).\n Then $\\mathcal{I}$ is a bijection.\n\\end{lemma}\n\n\\begin{proof}\n Let $\\tau \\in S_{n+1}$. Since $n+1$ is the maximal element in the codomain, its position in $\\tau$ is unique. Let $j$ be the index such that $\\tau(j) = n+1$. Removing the element $n+1$ from $\\tau$ results in a sequence of length $n$ containing the elements $\\{1, \\dots, n\\}$, which corresponds to a unique permutation $\\sigma \\in S_n$. Thus, the inverse map is well-defined, mapping $\\tau$ to $(\\sigma, j)$. Since an inverse exists, $\\mathcal{I}$ is a bijection.\n\\end{proof}\n\n\\begin{lemma}[Insertion Effect on Ascents]\n \\label{lem:insertion_effect}\n \\lean{decomposeEnd}\n \\uses{def:eulerian_number, lem:ascents_descents_sum, lem:insertion_bijection}\n Let $\\sigma \\in S_n$ be a permutation with $k$ ascents. Let $\\sigma' = \\mathcal{I}(\\sigma, j)$ for some $j \\in \\{0, \\dots, n\\}$.\n Then:\n \\begin{enumerate}\n \\item The number of ascents in $\\sigma'$ is $k+1$ if $j=n$ or if $j-1 \\in \\mathrm{Des}(\\sigma)$ (i.e., $n+1$ is inserted at the end or immediately after a descent). There are exactly $n-k$ such positions.\n \\item The number of ascents in $\\sigma'$ is $k$ if $j=0$ or if $j-1 \\in \\mathrm{Asc}(\\sigma)$ (i.e., $n+1$ is inserted at the beginning or immediately after an ascent). There are exactly $k+1$ such positions.\n \\end{enumerate}\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:ascents_descents_sum}\n We analyze the local change in ascents caused by inserting $n+1$ at index $j$.\n Note that $n+1$ is greater than all elements in $\\sigma$.\n \\begin{itemize}\n \\item If $j=0$: The sequence starts $n+1, \\sigma(0)$. This is a descent. Existing ascents shift indices but their count is preserved. Total ascents: $k$.\n \\item If $j=n$: The sequence ends $\\sigma(n-1), n+1$. Since $\\sigma(n-1) < n+1$, this adds a new ascent. Total ascents: $k+1$.\n \\item If $0 < j < n$: We insert between $a = \\sigma(j-1)$ and $b = \\sigma(j)$. The pair $(a, b)$ is replaced by $(a, n+1)$ and $(n+1, b)$. Since $a < n+1$, $(a, n+1)$ is always an ascent. Since $n+1 > b$, $(n+1, b)$ is always a descent.\n \\begin{itemize}\n \\item If $(a, b)$ was an ascent ($a < b$), we removed one ascent and added one ascent ($a < n+1$). The total count remains $k$.\n \\item If $(a, b)$ was a descent ($a > b$), we removed zero ascents and added one ascent ($a < n+1$). The total count becomes $k+1$.\n \\end{itemize}\n \\end{itemize}\n Counting the positions:\n \\begin{itemize}\n \\item Count preserving ascents ($k \\to k$): Position $j=0$ plus positions $j$ where $j-1$ was an ascent. Total $= 1 + k$.\n \\item Count increasing ascents ($k \\to k+1$): Position $j=n$ plus positions $j$ where $j-1$ was a descent. Using Lemma \\ref{lem:ascents_descents_sum}, the number of descents is $(n-1) - k$. Total $= 1 + (n - 1 - k) = n - k$.\n \\end{itemize}\n\\end{proof}\n\n\\begin{lemma}[Recurrence for Eulerian numbers]\n \\label{lem:eulerian_recurrence}\n \\lean{eulerianNumber_rec}\n \\uses{def:eulerian_number, lem:insertion_bijection, lem:insertion_effect}\n For any $n \\in \\mathbb{N}$ and integer $k$, the Eulerian numbers satisfy the recurrence relation:\n \\[ A(n+1, k+1) = (n-k)A(n, k) + (k+2)A(n, k+1) \\]\n\\end{lemma}\n\n\\begin{proof}\n \\uses{lem:insertion_bijection, lem:insertion_effect}\n By Lemma \\ref{lem:insertion_bijection}, we can partition $S_{n+1}$ based on the pre-image $(\\sigma, j)$. A permutation in $S_{n+1}$ has $k+1$ ascents if and only if it was formed by:\n 1. Taking $\\sigma \\in S_n$ with $k$ ascents and inserting $n+1$ in a position that increases the ascent count. By Lemma \\ref{lem:insertion_effect}, there are $n-k$ such positions. Since there are $A(n, k)$ such $\\sigma$, this contributes $(n-k)A(n, k)$.\n 2. Taking $\\sigma \\in S_n$ with $k+1$ ascents and inserting $n+1$ in a position that preserves the ascent count. By Lemma \\ref{lem:insertion_effect} (replacing $k$ with $k+1$), there are $(k+1)+1 = k+2$ such positions. Since there are $A(n, k+1)$ such $\\sigma$, this contributes $(k+2)A(n, k+1)$.\n\n These cases are exhaustive and disjoint. Thus, $A(n+1, k+1)$ is the sum of these contributions.\n\\end{proof}\n\n\\begin{lemma}[Binomial Coefficient Identity]\n \\label{lem:binomial_identity}\n \\lean{choose_succ_right_eq'}\n For any integers $n, k \\ge 0$ and any variable $x$, the following algebraic identity holds:\n \\[ (n-k)\\binom{x+k+1}{n+1} + (k+1)\\binom{x+k}{n+1} = x\\binom{x+k}{n} \\]\n\\end{lemma}\n\n\\begin{proof}\n We expand the binomial coefficients:\n \\[ \\text{LHS} = (n-k) \\frac{x+k+1}{n+1} \\binom{x+k}{n} + (k+1) \\frac{x+k-n}{n+1} \\binom{x+k}{n} \\]\n Factor out $\\frac{1}{n+1} \\binom{x+k}{n}$:\n \\[ = \\frac{1}{n+1} \\binom{x+k}{n} \\left[ (n-k)(x+k+1) + (k+1)(x+k-n) \\right] \\]\n Simplify the bracketed term:\n \\[ (nx + nk + n - kx - k^2 - k) + (kx + k^2 - kn + x + k - n) \\]\n Grouping by $x$ and constants:\n \\[ x(n-k+k+1) + (nk+n-k^2-k + k^2-kn+k-n) = x(n+1) + 0 \\]\n Substituting back:\n \\[ = \\frac{1}{n+1} \\binom{x+k}{n} \\cdot (n+1)x = x \\binom{x+k}{n} \\]\n\\end{proof}\n\n\\begin{theorem}[Worpitzky identity]\n \\label{thm:worpitzky_identity}\n \\lean{worpitzky}\n \\uses{def:eulerian_number, lem:eulerian_recurrence, lem:binomial_identity}\n For all $n \\in \\mathbb{N}$ and any variable $x$, the following identity holds:\n \\[ x^n = \\sum_{k=0}^{n} A(n, k) \\binom{x+k}{n} \\]\n\\end{theorem}\n\n\\begin{proof}\n \\uses{lem:eulerian_recurrence, lem:binomial_identity}\n We proceed by induction on $n$.\n Base case $n=0$: $x^0 = 1$. The sum is $A(0,0)\\binom{x}{0} = 1 \\cdot 1 = 1$. It holds.\n\n Inductive step: Assume the identity holds for $n$. Consider the expression for $n+1$:\n \\[ \\sum_{k=0}^{n+1} A(n+1, k) \\binom{x+k}{n+1} \\]\n Split the term for $k=0$ (where $A(n+1, 0)=1$) and use the recurrence from Lemma \\ref{lem:eulerian_recurrence} for $k \\ge 1$:\n \\[ A(n+1, k) = (n-(k-1))A(n, k-1) + (k+1)A(n, k) \\]\n Substituting into the sum (noting $A(n, n+1)=0$ allow extending the sum):\n \\[ \\binom{x}{n+1} + \\sum_{k=1}^{n+1} \\left[ (n-k+1)A(n, k-1) + (k+1)A(n, k) \\right] \\binom{x+k}{n+1} \\]\n Shift the index in the first part by letting $j = k-1$:\n \\[ \\sum_{j=0}^{n} (n-j)A(n, j) \\binom{x+j+1}{n+1} + \\sum_{k=0}^{n} (k+1)A(n, k) \\binom{x+k}{n+1} \\]\n Note that the $k=0$ term in the second sum corresponds to the initial separated $\\binom{x}{n+1}$ if we consider $A(n,0)=1$ and algebraic simplification. Combining the sums over $0 \\le k \\le n$:\n \\[ \\sum_{k=0}^{n} A(n, k) \\left[ (n-k)\\binom{x+k+1}{n+1} + (k+1)\\binom{x+k}{n+1} \\right] \\]\n Using Lemma \\ref{lem:binomial_identity}, the term in brackets is $x \\binom{x+k}{n}$:\n \\[ \\sum_{k=0}^{n} A(n, k) \\cdot x \\binom{x+k}{n} = x \\sum_{k=0}^{n} A(n, k) \\binom{x+k}{n} \\]\n By the induction hypothesis, $\\sum_{k=0}^{n} A(n, k) \\binom{x+k}{n} = x^n$.\n Thus, the expression equals $x \\cdot x^n = x^{n+1}$.\n\\end{proof}\n", "code": "import Mathlib\n\n\nset_option maxHeartbeats 300000 in\n\n\nopen Nat Function Set Equiv Fin\n\n\ntheorem worpitzky (n : ℕ) (x : R) :\n ∑ k ∈ Finset.range (n + 1), (↑(EulerianNumber n k) : R) * Ring.choose (x + k) n = x ^ n := by sorry"} -{"project_name": "ZsigmondyTheorem", "name": "zsigmondy_theorem", "type": "theorem", "title": "Zsigmondy's theorem", "informal_statement": "TODO", "informal_proof": "\\chapter{Zsigmondy's theorem}\n\nThis section contains a (stub of a) proof of Zsigmondy's theorem.\nSee \\url{https://en.wikipedia.org/wiki/Zsigmondy's_theorem} for more details.\n\n% TODO: Expand this stubbed file by adding an informal proof.\n\n\\begin{theorem}[Zsigmondy's theorem]\n \\label{thm:zsigmondy-theorem}\n \\lean{zsigmondy_theorem}\n TODO\n\\end{theorem}\n\\begin{proof}\n TODO\n\\end{proof}\n", "code": "import Mathlib\n\n\ntheorem zsigmondy_theorem\n (a b n : Nat)\n (hab_coprime : Nat.Coprime a b)\n (ha_gt_b : b < a)\n (hb_pos : 0 < b)\n (hn : 2 ≤ n)\n (hexc1 : ¬(n = 2 ∧ (a + b).isPowerOfTwo))\n (hexc2 : ¬(a = 2 ∧ b = 1 ∧ n = 6)) :\n ∃ p, IsPrimitivePrimeDivisor a b n p := by sorry"} diff --git a/scripts/create_sorries/statements_hard.jsonl b/scripts/create_sorries/statements_hard.jsonl deleted file mode 100644 index f7bb97c..0000000 --- a/scripts/create_sorries/statements_hard.jsonl +++ /dev/null @@ -1,114 +0,0 @@ -{"project_name": "AndersonTheorem", "name": "anderson", "type": "theorem", "code": "import Mathlib\n\n\nopen NNReal Set MeasureTheory Measure Filter Classical\n\nopen scoped Pointwise ENNReal\n\n\ntheorem anderson {n : ℕ} (hn : 0 < n) {c : ℝ} {y : RSpace n} {E : Set (RSpace n)} {f : (RSpace n) → ℝ}\n (E_symm : E = -E) (E_convex : Convex ℝ E)\n (f_nonneg : ∀ x, 0 ≤ f x) (f_symm : ∀ x, f (-x) = f x)\n (f_int : Integrable f volume) (f_unimodal : ∀ t, 0 ≤ t → Convex ℝ (f ⁻¹' (Ici t)))\n (hc : 0 ≤ c ∧ c ≤ 1) :\n ∫ x in E, f (x + y) ≤ ∫ x in E, f (x + c • y) := by sorry"} -{"project_name": "Apery", "name": "apery", "type": "theorem", "code": "import Mathlib\n\n\ntheorem apery : Irrational (riemannZeta 3).re := by sorry"} -{"project_name": "AztecDiamond", "name": "aztecDiamond_tiling", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem aztecDiamond_tiling (n : ℕ) :\n Nat.card (DominoTiling (AztecDiamond n)) = 2 ^ ((n + 1).choose 2) := by sorry"} -{"project_name": "BanachMazur", "name": "banach_mazur", "type": "theorem", "code": "import Mathlib\n\n\nopen TopologicalSpace\n\n\ntheorem banach_mazur (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E]\n [SeparableSpace E] :\n Nonempty (E →ₗᵢ[ℝ] C(unitInterval, ℝ)) := by sorry"} -{"project_name": "BauerFike", "name": "bauer_fike", "type": "theorem", "code": "import Mathlib\n\n\nopen Matrix BigOperators\n\n\ntheorem bauer_fike\n (A : Matrix (Fin n) (Fin n) ℂ) (V Λ δA : Matrix (Fin n) (Fin n) ℂ)\n (hV : IsUnit (V.det)) (hΛ : Λ.IsDiag) (hA : A = V * Λ * V⁻¹)\n (norm : Matrix (Fin n) (Fin n) ℂ → ℝ)\n (hnorm : IsSubordinateMatrixNorm norm)\n (μ : ℂ) (hμ : Module.End.HasEigenvalue (toLin' (A + δA)) μ) :\n ∃ i : Fin n, ‖Λ i i - μ‖ ≤ conditionNumber norm V * norm δA := by sorry"} -{"project_name": "BeckmanQuarlesTheorem", "name": "beckmann_quarles", "type": "theorem", "code": "import Mathlib\n\n\ntheorem beckmann_quarles {d : ℕ} {f : EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)}\n (h : ∀ x y : EuclideanSpace ℝ (Fin d), dist x y = 1 → dist (f x) (f y) = 1) :\n Isometry f := by sorry"} -{"project_name": "BergeTheorem", "name": "SimpleGraph.Subgraph.IsMatching.berge", "type": "theorem", "code": "import Mathlib\n\n\nopen SimpleGraph SimpleGraph.Subgraph\n\nopen scoped symmDiff\n\n\ntheorem SimpleGraph.Subgraph.IsMatching.berge\n [Fintype V] [DecidableEq V] {M : G.Subgraph} (hM : M.IsMatching) :\n (∀ M' : G.Subgraph, M'.IsMatching → M'.edgeSet.ncard ≤ M.edgeSet.ncard) ↔\n ∀ {u v : V} (p : G.Walk u v), ¬M.IsAugmentingPath p := by sorry"} -{"project_name": "BondyTheorem", "name": "bondy", "type": "theorem", "code": "import Mathlib\n\n\nopen Set Finset\n\n\ntheorem bondy {n : ℕ} (hn : 0 < n) {A : Fin n → Finset (Fin n)}\n (h_disj : ∀ i j : Fin n, i ≠ j → A i ≠ A j) :\n ∃ S : Finset (Fin n),\n S.card + 1 = n ∧\n ∀ i j : Fin n, i ≠ j → (S) ∩ A i ≠ (S) ∩ A j := by sorry"} -{"project_name": "BorsukUlamTheorem", "name": "borsuk_ulam", "type": "theorem", "code": "import Mathlib\n\n\nopen Metric\n\n\ntheorem borsuk_ulam (n : ℕ) {g : UnitNDimensionalSphere n → Fin n → ℝ}\n (hg : ∀ x : UnitNDimensionalSphere n, g (-x) = g x) (cont : Continuous g):\n ∃ x : UnitNDimensionalSphere n, g x = 0 := by sorry"} -{"project_name": "BrascampLieb", "name": "upperBound", "type": "theorem", "code": "import Mathlib\n\n\nopen EuclideanSpace in\n\n\ntheorem upperBound {J E : Type*} [Fintype J] [NormedAddCommGroup E] [InnerProductSpace ℝ E]\n [FiniteDimensional ℝ E] {F : J → Type*} [(j : J) → NormedAddCommGroup (F j)]\n [(j : J) → InnerProductSpace ℝ (F j)] [(j : J) → FiniteDimensional ℝ (F j)]\n (hE : Module.finrank ℝ E ≠ 0)\n (D : locRegDatum E F) (α : J → NNReal) (β : NNReal) (hα : ∀ i, 0 < α i)\n (hP : D.IsMetricPercep α β)\n (hS : ∀ j : J, (D.map j).EssentialRank rfl (α j) = Module.finrank ℝ (F j)) :\n let M_max := (D.loc + ∑ j, (D.weight j) • (D.map j).adjoint ∘ₗ (D.reg j) ∘ₗ (D.map j))\n loc_reg_constant_g D ≤\n (Module.finrank ℝ E : NNReal)^(D.Acuity / 2 : ℝ) *\n (∏ j, (D.weight j)^(- (D.weight j : ℝ) * Module.finrank ℝ (F j) / 2)) *\n (∏ j, (α j)^(- (D.weight j : ℝ) * Module.finrank ℝ (F j))) *\n ‖M_max.toContinuousLinearMap‖₊^((D.Acuity.toReal - Module.finrank ℝ E + β) / 2) *\n ‖(D.loc.equivOfDetNeZero D.pos_loc.2).symm.toContinuousLinearMap‖₊^(β.toReal / 2) := by sorry"} -{"project_name": "BrooksTheorem", "name": "brooks_theorem", "type": "theorem", "code": "import Mathlib\n\n\nopen Finset\n\n\ntheorem brooks_theorem {V : Type} (G : SimpleGraph V) [Fintype V] [DecidableRel G.Adj]\n (h_connected : G.Connected) :\n (G.chromaticNumber ≤ G.maxDegree) ∨\n (∃ n : ℕ, Nonempty (G ≃g SimpleGraph.completeGraph (Fin n))) ∨\n (∃ n : ℕ, Nonempty (G ≃g SimpleGraph.cycleGraph (2 * n + 3))) := by sorry"} -{"project_name": "BrunTheorem", "name": "brun", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat\n\nopen Classical in\n\n\ntheorem brun : Summable (fun n ↦ if n ∈ TwinPrimes then 1 / (n : ℝ) else 0) := by sorry"} -{"project_name": "BrunTitchmarshTheorem", "name": "brunTitchmarsh", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem brunTitchmarsh {x q a : ℕ} (ha : a < q) (hq : q < x) :\n {m ∈ Finset.range (x + 1) | m.Prime ∧ a = m%q}.card\n < 2 * x / (φ q * Real.log (x / (q : ℝ))) := by sorry"} -{"project_name": "BrunnMinkowski", "name": "EuclideanSpace.volume_pow_add_le", "type": "theorem", "code": "import Mathlib\n\n\nopen Set MeasureTheory Pointwise ENNReal\n\n\ntheorem EuclideanSpace.volume_pow_add_le {n : ℕ} (hn : n ≥ 1) {A B : Set (EuclideanSpace ℝ (Fin n))}\n (hA1 : A.Nonempty) (hA2 : IsCompact A) (hA3 : MeasurableSet A)\n (hB1 : B.Nonempty) (hB2 : IsCompact B) (hB3 : MeasurableSet B) :\n (volume A) ^ (1 / n : ℝ) + (volume B) ^ (1 / n : ℝ) ≤ volume (A + B) ^ (1 / n : ℝ) := by sorry"} -{"project_name": "BrunnMinkowski", "name": "EuclideanSpace.volume_pow_mul_le", "type": "theorem", "code": "import Mathlib\n\n\nopen Set MeasureTheory Pointwise ENNReal\n\naxiom EuclideanSpace.volume_pow_add_le {n : ℕ} (hn : n ≥ 1) {A B : Set (EuclideanSpace ℝ (Fin n))}\n (hA1 : A.Nonempty) (hA2 : IsCompact A) (hA3 : MeasurableSet A)\n (hB1 : B.Nonempty) (hB2 : IsCompact B) (hB3 : MeasurableSet B) :\n (volume A) ^ (1 / n : ℝ) + (volume B) ^ (1 / n : ℝ) ≤ volume (A + B) ^ (1 / n : ℝ)\n\n\ntheorem EuclideanSpace.volume_pow_mul_le {n : ℕ} {a : ℝ} (hn : n ≥ 1) (ha : 0 ≤ a ∧ a ≤ 1)\n {A B : Set (EuclideanSpace ℝ (Fin n))}\n (hA : A.Nonempty ∧ IsCompact A ∧ MeasurableSet A)\n (hB : B.Nonempty ∧ IsCompact B ∧ MeasurableSet B) :\n (volume A) ^ a * (volume B) ^ (1 - a) ≤ volume (a • A + (1 - a) • B) := by sorry"} -{"project_name": "CameronErdos", "name": "cameron_erdos", "type": "theorem", "code": "import Mathlib\n\n\nopen Set Filter Asymptotics\n\n\ntheorem cameron_erdos :\n (fun (n : ℕ) ↦ (↑{s : Set ℕ | s ⊆ Finset.range n ∧ IsSumFree s}.ncard : ℝ))\n =O[atTop] (fun (n : ℕ) ↦ (2 : ℝ) ^ ((↑n : ℝ) / 2)) := by sorry"} -{"project_name": "CaristiFixedPointTheorem", "name": "caristi", "type": "theorem", "code": "import Mathlib\n\n\nopen Metric NNReal\n\n\ntheorem caristi {X : Type*} [MetricSpace X] [CompleteSpace X] {T : X → X} {f : X → ℝ≥0}\n (hf : LowerSemicontinuous f) (h : ∀ x : X, dist x (T x) ≤ f x - f (T x)) :\n ∃ x : X, T x = x := by sorry"} -{"project_name": "CarlsonTheorem", "name": "carlson", "type": "theorem", "code": "import Mathlib\n\n\nopen Real\n\n\ntheorem carlson {f : ℂ → ℂ} (f_diff : Differentiable ℂ f)\n (f_bound : ∃ C t : ℝ, ∀ x : ℂ, ‖f x‖ ≤ C * rexp (t * ‖x‖))\n (f_bound' : ∃ C c : ℝ, c < π ∧ ∀ x : ℝ, ‖f (.I * x)‖ ≤ C * rexp (c * |x|))\n (f_nat : ∀ n : ℕ, f n = 0): f = 0 := by sorry"} -{"project_name": "Carmichael", "name": "carmichael", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat Int\n\n\ntheorem carmichael {p q : ℤ} {n : ℕ}\n (hn : n ∉ ({1, 2, 6} : Set ℕ))\n (hn12 : n ≠ 12 ∨ (p ≠ 1 ∧ p ≠ -1) ∨ q ≠ -1)\n (hpq : IsCoprime p q)\n (hpq_disc : 0 < p ^ 2 - 4 * q)\n (hpq' : p ≠ 0) (hq : q ≠ 0) :\n (∃ r : ℕ, r.Prime ∧ (↑r : ℤ) ∣ U p q n ∧ ∀ m < n, ¬ (↑r : ℤ) ∣ U p q m ) := by sorry"} -{"project_name": "CartanBrauerHuaTheorem", "name": "cartan_brauer_hua", "type": "theorem", "code": "import Mathlib\n\n\ntheorem cartan_brauer_hua {D : Type*} [DivisionRing D] (K : Subfield D)\n (hK1 : ∀ x : D, x ≠ 0 → ∀ k ∈ K, x * k * x⁻¹ ∈ K) (hK2 : K ≠ ⊤) :\n K ≤ Subfield.center D := by sorry"} -{"project_name": "CasoratiWeierstrass", "name": "casorati_weierstrass", "type": "theorem", "code": "import Mathlib\n\n\nopen Complex Set Metric Filter Topology\n\n\ntheorem casorati_weierstrass (f : ℂ → ℂ) {s : Set ℂ} {c : ℂ}\n (hess : EssentialSingularity f c)\n (hc : s ∈ 𝓝 c) (hd : DifferentiableOn ℂ f (s \\ {c})) :\n Dense (f '' s) := by sorry"} -{"project_name": "ChenTheorem", "name": "chen", "type": "theorem", "code": "import Mathlib\n\n\nopen Filter Nat\n\n\ntheorem chen : ∀ᶠ n in atTop, ∃ a b : ℕ,\n 2 * n = a + b ∧ a.Prime ∧ 1 < b ∧ b.primeFactorsList.length ≤ 2 := by sorry"} -{"project_name": "CondorcetJury", "name": "condorcet_jury_theorem", "type": "theorem", "code": "import Mathlib\n\n\nopen Real PMF BigOperators ENNReal NNReal Finset\n\nopen scoped Classical\n\n\ntheorem condorcet_jury_theorem (p : NNReal) (hp : p ≤ 1) (hp' : 1/2 < p) (hp_lt : p < 1)\n (n m : ℕ) (n_lt_m : n < m) :\n jury_majority_decision_probability p hp n < jury_majority_decision_probability p hp m := by sorry"} -{"project_name": "ContinuousMappingAs", "name": "ae_tendsto_comp_of_ae_tendsto_of_forall_continuousAt", "type": "theorem", "code": "import Mathlib\n\n\nopen MeasureTheory Filter Topology\n\nopen scoped ENNReal\n\n\ntheorem ae_tendsto_comp_of_ae_tendsto_of_forall_continuousAt {ι : Type*} {F : Filter ι}\n {rvs : ι → Ω → X} {rv : Ω → X} (g_cont : ∀ x ∈ X₀, ContinuousAt g x)\n (rv_supp : ∀ᵐ ω ∂P, rv ω ∈ X₀) (rvs_lim_as : ∀ᵐ ω ∂P, Tendsto (rvs · ω) F (𝓝 (rv ω))) :\n ∀ᵐ ω ∂P, Tendsto (fun i ↦ g (rvs i ω)) F (𝓝 (g (rv ω))) := by sorry"} -{"project_name": "ContinuousMappingLaw", "name": "ProbabilityMeasure.tendsto_map_of_forall_continuousAt", "type": "theorem", "code": "import Mathlib\n\n\nopen MeasureTheory ProbabilityTheory Filter Topology ENNReal NNReal\n\nopen scoped ENNReal\n\n\ntheorem ProbabilityMeasure.tendsto_map_of_forall_continuousAt\n (g_cont : ∀ x ∈ X₀, ContinuousAt g x) (g_mble : Measurable g)\n (P_supp : ∀ᵐ x ∂(P.toMeasure), x ∈ X₀) (Ps_lim : Tendsto Ps atTop (𝓝 P)) :\n Tendsto (fun n ↦ (Ps n).map g_mble.aemeasurable) atTop (𝓝 (P.map g_mble.aemeasurable)) := by sorry"} -{"project_name": "CriticalLineTheorem", "name": "critical_line", "type": "theorem", "code": "import Mathlib\n\n\nopen Set\n\n\ntheorem critical_line : {s : ℂ | riemannZeta s = 0 ∧ s.re = 1 / 2}.Infinite := by sorry"} -{"project_name": "DeBruijnErdos", "name": "SimpleGraph.colorable_of_finitely_colorable", "type": "theorem", "code": "import Mathlib\n\n\nopen Set Topology Finset\n\n\ntheorem SimpleGraph.colorable_of_finitely_colorable\n (hS : ∀ F, (ValidFiniteColorings k G F).Nonempty) :\n G.Colorable k := by sorry"} -{"project_name": "DefinabilityNaturalsInRationals", "name": "nat_definable_in_rat", "type": "theorem", "code": "import Mathlib\n\n\nopen FirstOrder FirstOrder.Language FirstOrder.Ring\n\n\ntheorem nat_definable_in_rat :\n (∅ : Set ℚ).Definable₁ Language.ring (Set.range (Nat.cast : ℕ → ℚ)) := by sorry"} -{"project_name": "DifferenceSetContainsInterval", "name": "exists_Ioo_subset_diff_self_of_measure_pos", "type": "theorem", "code": "import Mathlib\n\n\nopen Real Set Pointwise MeasureTheory\n\n\ntheorem exists_Ioo_subset_diff_self_of_measure_pos {A : Set ℝ}\n (A_mble : MeasurableSet A) (A_pos : 0 < volume A) :\n ∃ δ > 0, Ioo (-δ) δ ⊆ A - A := by sorry"} -{"project_name": "DillerDressTheorem", "name": "diller_dress", "type": "theorem", "code": "import Mathlib\n\n\ntheorem diller_dress (K L : Type*) [Field K] [Field L] [Algebra K L] [Module.Finite K L]\n [Pythagorean L] : Pythagorean K := by sorry"} -{"project_name": "Dilworth", "name": "dilworth", "type": "theorem", "code": "import Mathlib\n\n\nopen Finset Nat\n\n\ntheorem dilworth (S : Finset P) :\n IsLeast {k | ∃ (C : Finset (Set P)), IsChainPartition (SetLike.coe C) S ∧\n C.card = k} (width S) := by sorry"} -{"project_name": "ErdosDushnikMillerTheorem", "name": "erdos_dushnik_miller", "type": "theorem", "code": "import Mathlib\n\n\nopen Cardinal in\n\n\ntheorem erdos_dushnik_miller\n {V : Type*} [Infinite V] (G : SimpleGraph V) :\n (∃ s : Set V, G.IsClique s ∧ #s = #V) ∨\n (∃ s : Set V, G.IsIndepSet s ∧ ℵ₀ ≤ #s) := by sorry"} -{"project_name": "ErdosGallaiTheorem", "name": "ErdosGallaiTheorem", "type": "theorem", "code": "import Mathlib\n\n\ntheorem ErdosGallaiTheorem (d : List ℕ) (hd : d.SortedGE) :\n (∃ V, ∃ fV : Fintype V, ∃ G : SimpleGraph V, ∃ dG : DecidableRel G.Adj, degreeList G = d) ↔\n Even d.sum ∧\n ∀ k ∈ Set.Ioc 0 d.length,\n (d.take k).sum ≤ k * (k - 1) + ((d.drop k).map fun x => min x k).sum := by sorry"} -{"project_name": "ErdosKacTheorem", "name": "erdos_kac", "type": "theorem", "code": "import Mathlib\n\n\nopen scoped Classical ArithmeticFunction.omega\n\n\ntheorem erdos_kac (a b : ℝ) (hab : a < b) :\n Filter.Tendsto\n (fun N : ℕ =>\n ((Finset.Icc 1 N |>.filter fun n =>\n a ≤ normalizedOmega n ∧ normalizedOmega n ≤ b).card : ℝ) / (N : ℝ))\n Filter.atTop\n (nhds (stdNormalCDF b - stdNormalCDF a)) := by sorry"} -{"project_name": "FareySequence", "name": "farey_riemann_abs", "type": "theorem", "code": "import Mathlib\n\n\nopen Rat Set Filter\n\n\ntheorem farey_riemann_abs :\n RiemannHypothesis ↔ ∀ r : ℝ,\n 1 / 2 < r → (fun n ↦ ∑' i : Fin (FareyCard n), |FareyDifference n i|)\n =O[atTop] (fun n ↦ (↑n : ℝ) ^ r) := by sorry"} -{"project_name": "FeitThompsonTheorem", "name": "feit_thompson", "type": "theorem", "code": "import Mathlib\n\n\nopen Set Function Nat\n\n\ntheorem feit_thompson {G : Type u} [Fintype G] [Group G] (h : Odd (Fintype.card G)) :\n IsSolvable G := by sorry"} -{"project_name": "Fifteen", "name": "fifteen_theorem", "type": "theorem", "code": "import Mathlib\n\n\nopen Matrix\n\n\ntheorem fifteen_theorem (M : Matrix (Fin n) (Fin n) ℤ)\n (hsymm : M.IsSymm)\n (hpos : M.PosDef)\n (hrep : ∀ m : ℕ, 0 < m → m ≤ 15 → M.represents m) :\n M.Universal := by sorry"} -{"project_name": "Fitting", "name": "fitting", "type": "theorem", "code": "import Mathlib\n\n\nset_option maxHeartbeats 1600000 in\n\nset_option maxHeartbeats 800000 in\n\n\nopen scoped commutatorElement\n\nopen Subgroup in\n\n\ntheorem fitting {G : Type*} [Group G] (M N : Subgroup G) (hM₁ : M.Normal) (hN₁ : N.Normal)\n (m n : ℕ)\n (hM₂ : Group.IsNilpotent M) (hM₃ : Group.nilpotencyClass M = m)\n (hN₂ : Group.IsNilpotent N) (hN₃ : Group.nilpotencyClass N = n) :\n ∃ _ : Group.IsNilpotent ↥(M ⊔ N), Group.nilpotencyClass ↥(M ⊔ N) ≤ m + n := by sorry"} -{"project_name": "FrankWolfe", "name": "frank_wolfe_convergence_rate", "type": "theorem", "code": "import Mathlib\n\n\nopen Set\n\n\ntheorem frank_wolfe_convergence_rate\n {D : Set (EuclideanSpace ℝ (Fin d))} {f : EuclideanSpace ℝ (Fin d) → ℝ} {L : NNReal}\n {lmo : EuclideanSpace ℝ (Fin d) → EuclideanSpace ℝ (Fin d)}\n {x₀ x_star : EuclideanSpace ℝ (Fin d)}\n (hD_compact : IsCompact D)\n (hD_convex : Convex ℝ D)\n (hf_convex : ConvexOn ℝ D f)\n (hf_diff : Differentiable ℝ f)\n (hf_smooth : LipschitzOnWith L (fderiv ℝ f) D)\n (hx₀_mem : x₀ ∈ D)\n (hx_star_mem : x_star ∈ D)\n (hx_star_min : IsMinOn f D x_star)\n (hlmo_mem : ∀ x ∈ D, lmo x ∈ D)\n (hlmo_min : ∀ x ∈ D, IsMinOn (fun s => fderiv ℝ f x s) D (lmo x))\n : ∃ C : ℝ, 0 < C ∧ ∀ k : ℕ,\n f (frankWolfeSeq lmo x₀ k) - f x_star ≤ C / ((k : ℝ) + 2) := by sorry"} -{"project_name": "FreimanTheorem", "name": "Freiman", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat Finset Set Pointwise\n\n\ntheorem Freiman (K : ℝ) : ∃ dim size : ℕ,\n ∀ A : Finset ℤ, QuotSum A ≤ K →\n ∃ L : GFLP,\n ↑A ⊆ setOfGFLP L\n ∧ L.dim ≤ dim\n ∧ (setOfGFLP L).ncard ≤ size * A.card := by sorry"} -{"project_name": "FriedlanderIwaniecTheorem", "name": "friedlander_iwaniec", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem friedlander_iwaniec : {p : ℕ | p.Prime ∧ ∃ a b, p = a ^ 2 + b ^ 4}.Infinite := by sorry"} -{"project_name": "Froda", "name": "Real.countable_not_continuousAt", "type": "theorem", "code": "import Mathlib\n\n\nopen Set Filter Topology\n\n\ntheorem Real.countable_not_continuousAt (f : ℝ → ℝ) (h_mono : Monotone f) :\n {x | ¬ ContinuousAt f x}.Countable := by sorry"} -{"project_name": "GaussLucas", "name": "Complex.mem_convexHull_roots_of_mem_derivative_roots", "type": "theorem", "code": "import Mathlib\n\n\nopen Polynomial\n\n\ntheorem Complex.mem_convexHull_roots_of_mem_derivative_roots (p : ℂ[X]) (z : ℂ)\n (z_mem_roots_p_derivative : z ∈ p.derivative.roots) :\n z ∈ convexHull ℝ (p.roots.toFinset : Set ℂ) := sorry"} -{"project_name": "GelfondSchneiderTheorem", "name": "gelfond_scheider", "type": "theorem", "code": "import Mathlib\n\n\nopen Set Function\n\n\ntheorem gelfond_scheider (a b : ℝ) (ha_neq : a ≠ 0 ∧ a ≠ 1)\n (ha_alg : IsAlgebraic ℚ a) (hb_alg : IsAlgebraic ℚ b) (hb : Irrational b) :\n Transcendental ℚ b := by sorry"} -{"project_name": "GreenTaoTheorem", "name": "Nat.Prime.greenTao", "type": "theorem", "code": "import Mathlib\n\n\ntheorem Nat.Prime.greenTao (k : ℕ) :\n ∃ a d : ℕ, 0 < d ∧ ∀ i < k, (a + i * d).Prime := by sorry"} -{"project_name": "GrushkoTheorem", "name": "grushko", "type": "theorem", "code": "import Mathlib\n\n\nopen Group Monoid.Coprod\n\n\ntheorem grushko {G H : Type*} [Group G] [Group H] [FG G] [FG H] :\n rank (G ∗ H) = rank G + rank H := by sorry"} -{"project_name": "HardyLittlewoodTauberian", "name": "tauberian", "type": "theorem", "code": "import Mathlib\n\n\nopen Filter Topology Asymptotics Real\n\n\ntheorem tauberian {a : ℕ → ℝ} (ha : 0 ≤ a)\n (h : (fun (y : ℝ) ↦ ∑' k : ℕ, a k * rexp (-k * y)) ~[𝓝[>] 0] (fun (y : ℝ) ↦ 1 / y)) :\n (fun n ↦ ∑ k ∈ Finset.range n, a k) ~[atTop] (fun n ↦ ↑n) := sorry"} -{"project_name": "HasseTheoremOnEllipticCurves", "name": "HasseBound", "type": "theorem", "code": "import Mathlib\n\n\ntheorem HasseBound (F : Type*) [Finite F] [Field F] (E : WeierstrassCurve.Affine F) :\n abs ((Nat.card <| E.Point : ℝ) - (Nat.card F + 1)) ≤ 2 * Real.sqrt (Nat.card F) := sorry"} -{"project_name": "HeightOnePrimesUfd", "name": "Ideal.ufd_iff_height_one_primes_principal", "type": "theorem", "code": "import Mathlib\n\n\nopen Ideal\n\n\ntheorem Ideal.ufd_iff_height_one_primes_principal :\n UniqueFactorizationMonoid R ↔\n ∀ (p : Ideal R) [p.IsPrime], p.primeHeight = 1 → p.IsPrincipal := by sorry"} -{"project_name": "Hinge", "name": "hinge_forward", "type": "theorem", "code": "import Mathlib\n\n\nopen Real EuclideanGeometry\n\n\ntheorem hinge_forward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hangle : C₁ > C₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n c₁ > c₂ := by sorry"} -{"project_name": "Hinge", "name": "hinge_backward", "type": "theorem", "code": "import Mathlib\n\n\nopen Real EuclideanGeometry\n\naxiom hinge_forward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hangle : C₁ > C₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n c₁ > c₂\n\n\ntheorem hinge_backward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hside : c₁ > c₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n C₁ > C₂ := by sorry"} -{"project_name": "Hinge", "name": "hinge_iff_geometric", "type": "theorem", "code": "import Mathlib\n\n\nopen Real EuclideanGeometry\n\naxiom hinge_forward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hangle : C₁ > C₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n c₁ > c₂\n\naxiom hinge_backward {a b c₁ c₂ C₁ C₂ : ℝ}\n (ha : 0 < a) (hb : 0 < b) (hc₁ : 0 < c₁) (hc₂ : 0 < c₂)\n (hC₁_nonneg : 0 ≤ C₁) (hC₁_le_pi : C₁ ≤ π)\n (hC₂_nonneg : 0 ≤ C₂) (hC₂_le_pi : C₂ ≤ π)\n (hside : c₁ > c₂)\n (hlaw₁ : c₁^2 = a^2 + b^2 - 2*a*b*Real.cos C₁)\n (hlaw₂ : c₂^2 = a^2 + b^2 - 2*a*b*Real.cos C₂) :\n C₁ > C₂\n\n\ntheorem hinge_iff_geometric (A B₁ B₂ C₁ C₂ : P)\n (hab₁ : dist A B₁ = dist A B₂)\n (hac₁ : dist A C₁ = dist A C₂)\n (hb₁c₁ : B₁ ≠ C₁) (hb₂c₂ : B₂ ≠ C₂)\n (hab₁_ne : A ≠ B₁) (hac₁_ne : A ≠ C₁) :\n angle B₁ A C₁ > angle B₂ A C₂ ↔ dist B₁ C₁ > dist B₂ C₂ := by sorry"} -{"project_name": "HurwitzApproximation", "name": "hurwitz_approximation", "type": "theorem", "code": "import Mathlib\n\n\nopen Real GenContFract Set\n\n\ntheorem hurwitz_approximation (ξ : ℝ) (hξ : Irrational ξ) :\n { q : ℚ | |ξ - q| < 1 / (sqrt 5 * q.den ^ 2) }.Infinite := by sorry"} -{"project_name": "InverseEigenvalue", "name": "Module.End.inv_eigenvalue_iff", "type": "theorem", "code": "import Mathlib\n\n\ntheorem Module.End.inv_eigenvalue_iff {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M]\n (r : Rˣ) (f : M ≃ₗ[R] M) : Module.End.HasEigenvalue f.toLinearMap r ↔\n Module.End.HasEigenvalue f⁻¹.toLinearMap r⁻¹.1 := by sorry"} -{"project_name": "JacobiFourSquareTheorem", "name": "jacobi", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem jacobi (n : ℕ) : {a : Fin 4 → ℤ | (↑n : ℤ) = ∑ i : Fin 4, a i}.ncard\n = 8 * ∑' m : {m : ℕ | m ∣ n ∧ ¬ 4 ∣ m}, m.val := by sorry"} -{"project_name": "JacobsonMorozovTheorem", "name": "Jacobson_Morozov", "type": "theorem", "code": "import Mathlib\n\n\nset_option maxHeartbeats 800000 in\n\n\nopen Submodule in\n\n\ntheorem Jacobson_Morozov (x : L) [FiniteDimensional ℂ L] [hL : LieAlgebra.IsSemisimple ℂ L]\n (hx0 : x ≠ 0) (hx : IsNilpotent (LieAlgebra.ad ℂ L x)) : ∃ h y : L, IsSl2Triple h x y := by sorry"} -{"project_name": "JonesLemma", "name": "jones", "type": "theorem", "code": "import Mathlib\n\n\nopen TopologicalSpace Cardinal Set\n\n\ntheorem jones {X : Type*} [TopologicalSpace X] [SeparableSpace X] [NormalSpace X] {Y : Set X}\n (hc : IsClosed Y) (hd : IsDiscrete Y) : 2 ^ #Y ≤ 𝔠 := by sorry"} -{"project_name": "JordanSchurTheorem", "name": "jordan_schur", "type": "theorem", "code": "import Mathlib\n\n\nopen Function Set Matrix Group\n\n\ntheorem jordan_schur : ∃ f : ℕ → ℝ, ∀ n : ℕ, ∀ G : Subgroup (GeneralLinearGroup (Fin n) ℂ),\n Finite G → ∃ H : Subgroup G, H.Normal ∧ H.Abelian ∧ H.index ≤ f n := by sorry"} -{"project_name": "Joubert", "name": "exists_generator_of_minpoly_with_some_zero_coeffs", "type": "theorem", "code": "import Mathlib\n\n\nopen Polynomial\n\n\ntheorem exists_generator_of_minpoly_with_some_zero_coeffs (K L : Type*) (p : ℕ)\n [Field K] [Field L] [Algebra K L] [Algebra.IsSeparable K L] [CharP K p] [Fact (2 < p)]\n (h : Field.sepDegree K L = 6) :\n ∃ a : L, L = Algebra.adjoin K {a} ∧\n (∃ c4 c2 c1 c0 : K, minpoly K a = X ^ 6 + C c4 * X ^ 4 + C c2 * X ^ 2 + C c1 * X + C c0) := by sorry"} -{"project_name": "KaplanskyTheoremOnQuadraticForms", "name": "kaplansky_two", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem kaplansky_two {p : ℕ} (hp : p.Prime) (hp' : p ≡ 9 [MOD 16]) :\n ∃! t, (t = 32 ∨ t = 64) ∧ ∃ x y : ℕ, p = x ^ 2 + t * y ^ 2 := by sorry"} -{"project_name": "KoebeQuarterTheorem", "name": "koebe", "type": "theorem", "code": "import Mathlib\n\n\nopen Set Metric\n\n\ntheorem koebe {f : ℂ → ℂ} (f_inj : InjOn f (ball 0 1)) (f_diff : DifferentiableOn ℂ f (ball 0 1)) :\n ball (f 0) (‖deriv f 0‖ / 4) ⊆ f '' (ball 0 1) := by sorry"} -{"project_name": "KolmogorovThreeSeriesNecessary", "name": "kolmogorov_three_series_necessity", "type": "theorem", "code": "import Mathlib\n\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\n\ntheorem kolmogorov_three_series_necessity\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n (X_sum_ae : ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s))\n {b : ℝ} (b_pos : 0 < b) :\n (∑' n, P {ω | b < |X n ω|} ≠ ∞) ∧\n (∃ s,\n Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, ((Set.indicator {ω | |X n ω| ≤ b} (X n)) ω) ∂P)\n atTop (𝓝 s)) ∧\n (∑' n, evariance (Set.indicator {ω | |X n ω| ≤ b} (X n)) P ≠ ∞) := by sorry"} -{"project_name": "KolmogorovThreeSeriesSufficient", "name": "kolmogorov_three_series_sufficiency", "type": "theorem", "code": "import Mathlib\n\n\nopen MeasureTheory ProbabilityTheory Filter Topology\n\nopen scoped ENNReal NNReal\n\n\ntheorem kolmogorov_three_series_sufficiency\n (X : ℕ → Ω → ℝ) (X_mble : ∀ n, Measurable (X n)) (X_indep : iIndepFun X P)\n {b : ℝ} (b_pos : 0 < b) (sum_pr_gt_finite : ∑' n, P {ω | b < |X n ω|} ≠ ∞)\n (sum_ev_indic_finite : ∃ s,\n Tendsto (fun N ↦ ∑ n ∈ Finset.range N, ∫ ω, ((Set.indicator {ω | |X n ω| ≤ b} (X n)) ω) ∂P)\n atTop (𝓝 s))\n (sum_var_indic_finite : ∑' n, evariance (Set.indicator {ω | |X n ω| ≤ b} (X n)) P ≠ ∞) :\n ∀ᵐ ω ∂P, ∃ s, Tendsto (fun N ↦ ∑ n ∈ Finset.range N, X n ω) atTop (𝓝 s) := by sorry"} -{"project_name": "KoukoulopoulosMaynard", "name": "koukoulopoulos_maynard", "type": "theorem", "code": "import Mathlib\n\n\nopen MeasureTheory Set Nat\n\n\ntheorem koukoulopoulos_maynard {f : ℕ → ℝ} (hf : ∀ n, 0 < f n) :\n (∀ᵐ (x : ℝ), {(p, q) : ℕ × ℕ | p.Coprime q ∧ |x - p / (↑q : ℝ)|\n < f q / (↑q : ℝ)}.Finite) ↔ Summable fun n ↦ φ n * f n / (↑n : ℝ) := sorry"} -{"project_name": "Kraft", "name": "kraft", "type": "theorem", "code": "import Mathlib\n\n\ntheorem kraft (ls : List ℕ) (hkraft : kraftSum σ ls ≤ 1) :\n ∃ C : Code σ, PrefixFree C ∧\n C.val.map List.length = (ls : Multiset ℕ) := by sorry"} -{"project_name": "KroneckerWeberTheorem", "name": "KroneckerWeber", "type": "theorem", "code": "import Mathlib\n\n\ntheorem KroneckerWeber (F : Type*) [Field F] [NumberField F] [IsAbelianGalois ℚ F] :\n ∃ n, ∃ (K : Type*) (_ : Field K) (_ : Algebra ℚ K) (_ : Algebra F K) (_ : IsScalarTower ℚ F K),\n IsCyclotomicExtension {n} ℚ K := sorry"} -{"project_name": "KrullSeparationLemma", "name": "krull_separation", "type": "theorem", "code": "import Mathlib\n\n\nopen Ideal\n\n\ntheorem krull_separation {R : Type u} [Ring R] {M : Submonoid R} {I : Ideal R}\n (h : M.carrier ∩ I.carrier = ∅) :\n ∃ P : Ideal R, IsPrime P ∧ M.carrier ∩ P.carrier = ∅ ∧ I ≤ P := sorry"} -{"project_name": "LagrangeTheorem", "name": "lagrange", "type": "theorem", "code": "import Mathlib\n\n\nopen Polynomial Nat\n\n\ntheorem lagrange {p : ℕ} (hp : p.Prime) {f : Polynomial ℤ} (h : ∃ n : ℕ, ¬ (↑p : ℤ) ∣ f.coeff n):\n {n : ℕ | n ≤ p ∧ ↑p ∣ eval (↑n : ℤ) f}.ncard ≤ f.natDegree := sorry"} -{"project_name": "LeCamTheorem", "name": "LeCamTheorem", "type": "theorem", "code": "import Mathlib\n\n\ntheorem LeCamTheorem (ps : List unitInterval) (hps : ∀ p ∈ ps, 0 ≤ p ∧ p ≤ 1) :\n let mean := (ps.map (fun p => p.val)).sum\n let sum := independentSum (ps.map (fun k => PMF.bernoulliNat_of_unitInterval (k) ) )\n ∑ k ∈ Finset.range (ps.length+1),\n |(sum k).toReal - (Real.exp (-mean) * mean ^ k / k.factorial)| ≤ 2 * (ps.map (fun p => p.val ^ 2)).sum := sorry"} -{"project_name": "LeastCommonMultipleLowerBound", "name": "Nat.LCM_lower_bound", "type": "theorem", "code": "import Mathlib\n\n\ntheorem Nat.LCM_lower_bound (n : ℕ) (hn : 7 ≤ n) : 2 ^ n ≤ LCM n := sorry"} -{"project_name": "LevitzkyTheorem", "name": "levitzky_theorem", "type": "theorem", "code": "import Mathlib\n\n\ntheorem levitzky_theorem {R : Type*} [Ring R]\n [IsNoetherianRing (MulOpposite R)]\n (I : Ideal R) (hnil : I.IsNil) :\n IsNilpotent I := by sorry"} -{"project_name": "LinnikTheorem", "name": "linnik", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem linnik : ∃ c L : ℝ, ∀ ⦃a b : ℕ⦄, a.Coprime b → d a b ≤ c * (↑b : ℝ) ^ L := by sorry"} -{"project_name": "LukacsProportionSumIndependenceTheorem", "name": "lukacs_proportion_sum_independence_iff", "type": "theorem", "code": "import Mathlib\n\n\nopen MeasureTheory ProbabilityTheory\n\n\ntheorem lukacs_proportion_sum_independence_iff\n {Omega : Type*} [MeasurableSpace Omega]\n {P : Measure Omega} [IsProbabilityMeasure P]\n {X Y : Omega → ℝ}\n (hXm : Measurable X) (hYm : Measurable Y)\n (hXY : IndepFun X Y P)\n (hXpos : ∀ᵐ ω ∂P, 0 < X ω)\n (hYpos : ∀ᵐ ω ∂P, 0 < Y ω)\n (hXnd : ¬∃ c, ∀ᵐ ω ∂P, X ω = c)\n (hYnd : ¬∃ c, ∀ᵐ ω ∂P, Y ω = c) :\n IndepFun (fun ω => X ω / (X ω + Y ω)) (fun ω => X ω + Y ω) P ↔\n ∃ alpha gamma r : ℝ,\n 0 < alpha ∧ 0 < gamma ∧ 0 < r ∧\n HasLaw X (gammaMeasure alpha r) P ∧\n HasLaw Y (gammaMeasure gamma r) P := by sorry"} -{"project_name": "LusinTheorem", "name": "lusin", "type": "theorem", "code": "import Mathlib\n\n\nopen Set Function MeasureTheory\n\n\ntheorem lusin {a b ε : ℝ} (ab : a < b) {f : ℝ → ℂ} (f_meas : Measurable f) (εp : 0 < ε) :\n ∃ E ⊆ Icc a b, IsCompact E ∧ Continuous (restrict E f) ∧ b - a - ε < (volume E).toReal := by sorry"} -{"project_name": "McMillan", "name": "mcmillan", "type": "theorem", "code": "import Mathlib\n\n\ntheorem mcmillan (C : Code σ) (hC : UniquelyDecodable C) :\n kraftSum C ≤ 1 := by sorry"} -{"project_name": "MergelyanTheorem", "name": "mergelyan", "type": "theorem", "code": "import Mathlib\n\n\ntheorem mergelyan {K : Set ℂ} (K_compact : IsCompact K) (K_conn : IsConnected Kᶜ)\n {f : ℂ → ℂ} (f_cont : ContinuousOn f K) (f_diff : DifferentiableOn ℂ f (interior K)) :\n ∀ ε > 0, ∃ p : Polynomial ℂ, ∀ x ∈ K, ‖f x - p.eval x‖ₑ < ε := by sorry"} -{"project_name": "MertensFirstTheorem", "name": "merten_first", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat Set\n\n\ntheorem merten_first {n : ℕ} (hn : 2 ≤ n) :\n - Real.log n + ∑' k : PrimesLe n, Real.log k / k ≤ 2 := by sorry"} -{"project_name": "MycielskiTheorem", "name": "mycielski", "type": "theorem", "code": "import Mathlib\n\n\ntheorem mycielski (n : ℕ) :\n ∃ (W : Type) (H : SimpleGraph W), H.CliqueFree 3 ∧ (n : ℕ∞) ≤ H.chromaticNumber := by sorry"} -{"project_name": "NagellLutzTheorem", "name": "NagellLutz1", "type": "theorem", "code": "import Mathlib\n\n\ntheorem NagellLutz1 {E : WeierstrassCurve.Affine ℚ}\n (h1 : E.IsIntegral ℤ) (h2 : E.Δ ≠ 0) {x y : ℚ} (h : E.Nonsingular x y)\n (hx : 0 < addOrderOf (WeierstrassCurve.Affine.Point.some x y h)) :\n x ∈ (algebraMap ℤ ℚ).range ∧ y ∈ (algebraMap ℤ ℚ).range := sorry"} -{"project_name": "NagellLutzTheorem", "name": "NagellLutz2", "type": "theorem", "code": "import Mathlib\n\naxiom NagellLutz1 {E : WeierstrassCurve.Affine ℚ}\n (h1 : E.IsIntegral ℤ) (h2 : E.Δ ≠ 0) {x y : ℚ} (h : E.Nonsingular x y)\n (hx : 0 < addOrderOf (WeierstrassCurve.Affine.Point.some x y h)) :\n x ∈ (algebraMap ℤ ℚ).range ∧ y ∈ (algebraMap ℤ ℚ).range\n\n\ntheorem NagellLutz2 {E : WeierstrassCurve.Affine ℚ}\n (h1 : E.IsIntegral ℤ)\n (h2 : E.Δ ≠ 0) {x y : ℚ} (h : E.Nonsingular x y)\n (hx : 0 < addOrderOf (WeierstrassCurve.Affine.Point.some x y h)) :\n (y = 0 ∧ addOrderOf (WeierstrassCurve.Affine.Point.some x y h) = 2) ∨\n (NagellLutz1 h1 h2 h hx).2.choose ^ 2 ∣ (E.Δ_integral_of_isIntegral ℤ).choose := sorry"} -{"project_name": "NonSquareFreeWeird", "name": "weird_squarefree_infinite", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat ArithmeticFunction.sigma\n\n\ntheorem weird_squarefree_infinite : ∀ N, ∃ n > N, Weird n ∧ ¬ Squarefree (n.oddPart) := by sorry"} -{"project_name": "OreTheorem", "name": "ore_maximal_hamiltonian_cycle_free_graph", "type": "lemma", "code": "import Mathlib\n\n\nlemma ore_maximal_hamiltonian_cycle_free_graph {α : Type*} [Fintype α] [DecidableEq α]\n (G : SimpleGraph α) [DecidableRel G.Adj]\n (hn : 3 ≤ Fintype.card α)\n (hG : ¬ G.IsHamiltonian)\n (hMax : ∀ (H : SimpleGraph α) [DecidableRel H.Adj], G < H → H.IsHamiltonian) :\n ∀ v w : α, v ≠ w → ¬ G.Adj v w → G.degree v + G.degree w ≤ Fintype.card α - 1 := by sorry"} -{"project_name": "OreTheorem", "name": "ore_theorem", "type": "theorem", "code": "import Mathlib\n\naxiom ore_maximal_hamiltonian_cycle_free_graph {α : Type*} [Fintype α] [DecidableEq α]\n (G : SimpleGraph α) [DecidableRel G.Adj]\n (hn : 3 ≤ Fintype.card α)\n (hG : ¬ G.IsHamiltonian)\n (hMax : ∀ (H : SimpleGraph α) [DecidableRel H.Adj], G < H → H.IsHamiltonian) :\n ∀ v w : α, v ≠ w → ¬ G.Adj v w → G.degree v + G.degree w ≤ Fintype.card α - 1\n\n\ntheorem ore_theorem {α : Type*} [Fintype α] [DecidableEq α] (G : SimpleGraph α)\n [DecidableRel G.Adj]\n (hn : 3 ≤ Fintype.card α)\n (h : ∀ v w : α, v ≠ w → ¬G.Adj v w → Fintype.card α ≤ G.degree v + G.degree w) :\n G.IsHamiltonian := by sorry"} -{"project_name": "PicardTheorem", "name": "picard", "type": "theorem", "code": "import Mathlib\n\n\nopen Function Set\n\n\ntheorem picard {f : ℂ → ℂ} (f_diff : Differentiable ℂ f) (f_ne_const : ∀ a : ℂ, ∃ b : ℂ, f b ≠ a) :\n ∃ x : ℂ, {x}ᶜ ⊆ range f := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "polygonal_number_theorem_odd", "type": "theorem", "code": "import Mathlib\n\n\ntheorem polygonal_number_theorem_odd (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 28 * m ^ 3) (hm2 : Odd m) :\n ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num m k4 := by sorry"} -{"project_name": "PolygonalNumberTheorem", "name": "polygonal_number_theorem_even'", "type": "lemma", "code": "import Mathlib\n\naxiom polygonal_number_theorem_odd (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 28 * m ^ 3) (hm2 : Odd m) :\n ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num m k4\n\n\nlemma polygonal_number_theorem_even' (m N : ℤ) (hm1 : m ≥ 3) (hN : N ≥ 7 * m ^ 3) (hN' : Odd N)\n (hm2 : Even m) : ∃ (k1 k2 k3 k4 : ℤ), N = pol_num m k1 + pol_num m k2 + pol_num m k3 + pol_num\n m k4 := by sorry"} -{"project_name": "PrekopaLeindler", "name": "prekopa_leindler_dim1", "type": "lemma", "code": "import Mathlib\n\n\nset_option maxHeartbeats 400000 in\n\n\nopen ENNReal MeasureTheory Pointwise Real Set Filter MeasurableSet\n\nopen scoped Topology in\n\n\nlemma prekopa_leindler_dim1\n {t : ℝ} (h0t : 0 < t) (ht1 : t < 1) {f g h : EuclideanSpace ℝ (Fin 1) → ℝ} (hf_nonneg : 0 ≤ f)\n (hf_integrable : Integrable f) (hg_nonneg : 0 ≤ g) (hg_integrable : Integrable g)\n (hh_nonneg : 0 ≤ h) (hh_integrable : Integrable h) (hfgh_pow_le : PL_dim1_cond t f g h) :\n PL_dim1_conclusion t f g h := sorry"} -{"project_name": "ProthTheorem", "name": "proth", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem proth {n : ℕ} (h : IsProth n) : n.Prime ↔ ∃ a : ℕ, a ^ ((n - 1) / 2) ≡ -1 [ZMOD n] := by sorry"} -{"project_name": "PseudoArithmeticPeriod", "name": "smallest_period_div", "type": "theorem", "code": "import Mathlib\n\n\ntheorem smallest_period_div {n : ℕ} (hn : 0 < n) :\n (↑(b (n + 1)) : ℝ) = (2 * n + 1 : ℝ)⁻¹ * ∑ j ∈ Finset.range (a n), (2 ^ j % (2 * n + 1)) := by sorry"} -{"project_name": "RamanujanNagellEquation", "name": "ramanujan_nagell", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat Set\n\n\ntheorem ramanujan_nagell (n : ℕ) (hn : 3 ≤ n):\n (∃ x, 2 ^ n - 7 = x ^ 2) ↔ n ∈ ({3, 4, 5, 7, 15} : Set ℕ) := by sorry"} -{"project_name": "RiemannSeries", "name": "riemann_summation_atbot", "type": "theorem", "code": "import Mathlib\n\n\nopen Filter Function Topology\n\n\ntheorem riemann_summation_atbot {a : ℕ → ℝ}\n (h : convergentSeries a) (h' : ¬ convergentSeries (fun n ↦ |a n|)) :\n ∃ p : ℕ → ℕ, Bijective p ∧ Tendsto (fun n ↦ ∑ k ∈ Finset.range n, a (p k)) atTop atBot := sorry"} -{"project_name": "RisingSunLemma", "name": "risingsun", "type": "theorem", "code": "import Mathlib\n\n\nopen Set TopologicalSpace Real\n\n\ntheorem risingsun {a b : ℝ} (ab : a < b) {g : ℝ → ℝ} (hg : Continuous g) :\n ∃ k : ℕ → ℝ × ℝ, ∀ i j : ℕ, i ≠ j → Ioo (k i).1 (k i).2 ∩ Ioo (k j).1 (k j).2 = ∅\n ∧ E a b g = ⋃ n : ℕ, Ioo (k n).1 (k n).2\n ∧ (∀ n : ℕ, (k n).1 ≠ a → g (k n).1 = g (k n).2)\n ∧ (∀ n : ℕ, (k n).1 = a → a ∈ Shadow a b g → g a < g (k n).2)\n ∧ (∀ n : ℕ, ∀ x : ℝ, x ∈ Ioo (k n).1 (k n).2 → g x < g (k n).2) := by sorry"} -{"project_name": "RobinTheorem", "name": "robin", "type": "theorem", "code": "import Mathlib\n\n\nopen ArithmeticFunction.sigma Real\n\n\ntheorem robin : RiemannHypothesis ↔ ∀ n > 5040,\n σ 1 n < exp (eulerMascheroniConstant) * n * log (log n) := by sorry"} -{"project_name": "RothTheorem", "name": "roth", "type": "theorem", "code": "import Mathlib\n\n\nopen ENNReal Set\n\n\ntheorem roth {x : ℝ} (hx_irr : Irrational x) (hx_alg : IsAlgebraic ℚ x) :\n IrrationalityMeasure x = 2 := sorry"} -{"project_name": "RoucheCapelli", "name": "rouche_capelli", "type": "theorem", "code": "import Mathlib\n\n\nopen Matrix\n\nopen Submodule\n\n\ntheorem rouche_capelli {K : Type*} [Field K] {m n : ℕ}\n (sys : SystemOfLinearEquations K m n) :\n (∃ x : Fin n → K, sys.A.mulVec x = sys.b) ↔\n MatrixRank sys.A = MatrixRank (AugmentedMatrix sys) := sorry"} -{"project_name": "SchauderFixedPointTheorem", "name": "SchauderFixedPointTheorem", "type": "theorem", "code": "import Mathlib\n\n\nopen Set Filter Topology\n\nopen Set in\n\n\ntheorem SchauderFixedPointTheorem\n {E : Type*}\n [AddCommGroup E] [Module ℝ E]\n [TopologicalSpace E] [IsTopologicalAddGroup E] [ContinuousSMul ℝ E]\n [T2Space E] [LocallyConvexSpace ℝ E]\n {C : Set E} (hne : C.Nonempty) (hconv : Convex ℝ C) (hcpt : IsCompact C)\n {f : E → E} (hf : Continuous f) (hfc : MapsTo f C C) :\n ∃ x ∈ C, f x = x := by sorry"} -{"project_name": "SchurRamsey", "name": "schur", "type": "theorem", "code": "import Mathlib\n\n\nopen Setoid Set\n\n\ntheorem schur (n : ℕ) : ∃ S : ℕ, ∀ r : (Icc 1 S) → Fin n,\n ∃ u : Fin n,\n ∃ x y z : Icc 1 S,\n r x = u ∧ r y = u ∧ r z = u ∧ (x : ℕ) + y = z := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sinkhorn_existence", "type": "theorem", "code": "import Mathlib\n\n\nopen Matrix Finset Filter Topology\n\n\ntheorem sinkhorn_existence {n : ℕ} (hn : 0 < n)\n (A : Matrix (Fin n) (Fin n) ℝ)\n (hA : ∀ i j, 0 < A i j) :\n ∃ d₁ d₂ : Fin n → ℝ,\n (∀ i, 0 < d₁ i) ∧\n (∀ i, 0 < d₂ i) ∧\n diagonal d₁ * A * diagonal d₂ ∈ doublyStochastic ℝ (Fin n) := by sorry"} -{"project_name": "SinkhornTheorem", "name": "sinkhorn_uniqueness", "type": "theorem", "code": "import Mathlib\n\n\nopen Matrix Finset Filter Topology\n\naxiom sinkhorn_existence {n : ℕ} (hn : 0 < n)\n (A : Matrix (Fin n) (Fin n) ℝ)\n (hA : ∀ i j, 0 < A i j) :\n ∃ d₁ d₂ : Fin n → ℝ,\n (∀ i, 0 < d₁ i) ∧\n (∀ i, 0 < d₂ i) ∧\n diagonal d₁ * A * diagonal d₂ ∈ doublyStochastic ℝ (Fin n)\n\n\ntheorem sinkhorn_uniqueness {n : ℕ} (hn : 0 < n)\n (A : Matrix (Fin n) (Fin n) ℝ)\n (hA : ∀ i j, 0 < A i j)\n (d₁ d₂ d₁' d₂' : Fin n → ℝ)\n (hd₁ : ∀ i, 0 < d₁ i)\n (hd₂ : ∀ i, 0 < d₂ i)\n (hd₁' : ∀ i, 0 < d₁' i)\n (hd₂' : ∀ i, 0 < d₂' i)\n (hDS : diagonal d₁ * A * diagonal d₂ ∈ doublyStochastic ℝ (Fin n))\n (hDS' : diagonal d₁' * A * diagonal d₂' ∈ doublyStochastic ℝ (Fin n)) :\n ∃ c : ℝ, 0 < c ∧\n (∀ i, d₁' i = c * d₁ i) ∧\n (∀ i, d₂' i = d₂ i / c) := by sorry"} -{"project_name": "StarOfDavid", "name": "starofdavid", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat\n\n\ntheorem starofdavid (n k : ℕ) :\n (((n - 1).choose (k - 1)).gcd (n.choose (k + 1))).gcd ((n + 1).choose k)\n = (((n - 1).choose k).gcd (n.choose (k - 1))).gcd ((n + 1).choose (k + 1)) := by sorry"} -{"project_name": "SzemerediTheorem", "name": "szemeredi", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat Filter Set\n\n\ntheorem szemeredi {A : Set ℕ} (h : 0 < upperDensity A) (n : ℕ) :\n ∃ a b : ℕ, b > 0 ∧ {a + k * b | k < n} ⊆ A := sorry"} -{"project_name": "SzemerediTrotterTheorem", "name": "szemeredi_trotter", "type": "theorem", "code": "import Mathlib\n\n\nopen scoped EuclideanGeometry\n\nopen Classical in\n\n\ntheorem szemeredi_trotter :\n ∃ C : ℝ, 0 < C ∧ ∀ (P : Finset (EuclideanSpace ℝ (Fin 2)))\n (L : Finset Line2),\n (incidenceCount P L : ℝ) ≤\n C * ((P.card : ℝ) ^ ((2 : ℝ) / 3) *\n (L.card : ℝ) ^ ((2 : ℝ) / 3) +\n (P.card : ℝ) + (L.card : ℝ)) := by sorry"} -{"project_name": "TotientGrowthRate", "name": "totient_lower_bound", "type": "theorem", "code": "import Mathlib\n\n\nopen ENNReal NNReal\n\nopen Filter Set Topology Nat Real\n\n\ntheorem totient_lower_bound {n : ℕ} (hn : 2 < n) :\n ↑n / (rexp eulerMascheroniConstant * Real.log (Real.log ↑n) + 3 / Real.log (Real.log ↑n))\n < (↑(φ n) : ℝ) := by sorry"} -{"project_name": "TverbergTheorem", "name": "tverberg", "type": "theorem", "code": "import Mathlib\n\n\ntheorem tverberg (d r : ℕ) (d_pos : 0 < d) (r_pos : 0 < r)\n (S : Finset (EuclideanSpace ℝ (Fin d))) (hS : S.card = (d + 1) * (r - 1) + 1) :\n ∃ (x : EuclideanSpace ℝ (Fin d)) (partition : Finpartition S),\n partition.parts.card = r ∧\n ∀ part ∈ partition.parts, x ∈ convexHull ℝ part := by sorry"} -{"project_name": "TwoFactorTheorem", "name": "two_factor_theorem", "type": "theorem", "code": "import Mathlib\n\n\ntheorem two_factor_theorem {V : Type} (G : SimpleGraph V) {k : ℕ}\n (h : G.IsRegularOfDegree' (2 * k)) :\n ∃ (factors : Fin k → SimpleGraph V),\n (∀ i, factors i ≤ G) ∧\n (∀ i, (factors i).IsRegularOfDegree' 2) ∧\n (∀ i j, i ≠ j → Disjoint (factors i).edgeSet (factors j).edgeSet) ∧\n (⋃ i, (factors i).edgeSet) = G.edgeSet := sorry"} -{"project_name": "TwoNinety", "name": "two_ninety_theorem", "type": "theorem", "code": "import Mathlib\n\n\ntheorem two_ninety_theorem {n : ℕ} (M : Matrix (Fin n) (Fin n) ℤ)\n (hpos : M.PosDef)\n (hrep : ∀ m ∈ critical_290_numbers, M.represents m) :\n M.Universal := by sorry"} -{"project_name": "ValuationRingInterSubfield", "name": "ValuationRing.inter_subfield", "type": "theorem", "code": "import Mathlib\n\n\nopen Subring Subfield\n\n\ntheorem ValuationRing.inter_subfield\n (B : Subring L) [ValuationRing B] (K : Subfield L) :\n ValuationRing ↥(K.toSubring ⊓ B) := by sorry"} -{"project_name": "Vantieghem", "name": "vantieghem", "type": "theorem", "code": "import Mathlib\n\n\nset_option maxHeartbeats 1600000 in\n\n\nopen Nat Finset BigOperators\n\n\ntheorem vantieghem {n : ℕ} (hn : 3 ≤ n) :\n n.Prime ↔ (∏ k ∈ Finset.Ico 1 n, (2 ^ k - 1)) ≡ n [MOD (2 ^ n - 1)] := sorry"} -{"project_name": "VonStaudtClausen", "name": "von_staudt_clausen", "type": "theorem", "code": "import Mathlib\n\n\ntheorem von_staudt_clausen (n : ℕ) (hn : 1 ≤ n) :\n IsLocalization.IsInteger ℤ (bernoulli (2 * n) + ∑ j ∈ (Finset.range (2 * n + 1)).filter\n (fun j => (j + 1).Prime) , if j ∣ (2 * n) then (1 : ℚ) / (j+1) else 0) := by sorry"} -{"project_name": "WaringProblem", "name": "waring", "type": "theorem", "code": "import Mathlib\n\n\ntheorem waring (n : ℕ) : ∃ t : ℕ,\n ∀ k, ∃ s : Finset ℕ, s.card ≤ t ∧ k = ∑ i ∈ s, i ^ n := by sorry"} -{"project_name": "Wolstenholme", "name": "wolstenholme", "type": "theorem", "code": "import Mathlib\n\n\nopen Nat Finset BigOperators\n\n\ntheorem wolstenholme {p : ℕ} (hp : p.Prime) (hp' : 5 ≤ p) :\n (2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3] := by sorry"} -{"project_name": "Worpitzky", "name": "worpitzky3", "type": "theorem", "code": "import Mathlib\n\n\nset_option maxHeartbeats 300000 in\n\n\nopen Nat Function Set Equiv Fin\n\n\ntheorem worpitzky3 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n ∑ k ∈ Finset.range (n + 1),\n EulerianNumber n k * ((n - k) * (Ring.choose (x + k) (n + 1) + Ring.choose (x + k) n)\n + (k + 1) * Ring.choose (x + k) (n + 1)) = x ^ (n + 1) := by sorry"} -{"project_name": "Worpitzky", "name": "worpitzky", "type": "theorem", "code": "import Mathlib\n\n\nset_option maxHeartbeats 300000 in\n\n\nopen Nat Function Set Equiv Fin\n\naxiom worpitzky3 {n : ℕ} {x : R}\n (hn : ∑ k ∈ Finset.range (n + 1), ↑(EulerianNumber n k) * Ring.choose (x + ↑k) n = x ^ n) :\n ∑ k ∈ Finset.range (n + 1),\n EulerianNumber n k * ((n - k) * (Ring.choose (x + k) (n + 1) + Ring.choose (x + k) n)\n + (k + 1) * Ring.choose (x + k) (n + 1)) = x ^ (n + 1)\n\n\ntheorem worpitzky (n : ℕ) (x : R) :\n ∑ k ∈ Finset.range (n + 1), (↑(EulerianNumber n k) : R) * Ring.choose (x + k) n = x ^ n := by sorry"} -{"project_name": "ZsigmondyTheorem", "name": "zsigmondy_theorem", "type": "theorem", "code": "import Mathlib\n\n\ntheorem zsigmondy_theorem\n (a b n : Nat)\n (hab_coprime : Nat.Coprime a b)\n (ha_gt_b : b < a)\n (hb_pos : 0 < b)\n (hn : 2 ≤ n)\n (hexc1 : ¬(n = 2 ∧ (a + b).isPowerOfTwo))\n (hexc2 : ¬(a = 2 ∧ b = 1 ∧ n = 6)) :\n ∃ p, IsPrimitivePrimeDivisor a b n p := by sorry"} diff --git a/scripts/create_sorries/test_parsing.py b/scripts/create_sorries/test_parsing.py deleted file mode 100644 index 1c9c9ac..0000000 --- a/scripts/create_sorries/test_parsing.py +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env python3 -""" -测试脚本:测试 LeanCodeParser 对复杂语法的解析能力 -""" - -from scripts.create_sorries.extract_sublemmas import LeanCodeParser, create_proof_with_sorries - -def test_parsing(): - """测试各种复杂的 Lean 语法解析""" - - test_cases = [ - # 测试1: 包含默认参数的 lemma - { - "name": "默认参数测试", - "code": """lemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) : - 0 < x ^ r := by - simpa +singlePass [← zero_rpow_of_pos hr, rpow_lt_rpow_iff hr] using by positivity""", - "expected_statement": "lemma pos_rpow_of_pos {x : ℝ≥0∞} {r : ℝ} (hx : x ≠ 0) (hr : 0 < r := by grind) :\n 0 < x ^ r", - "expected_proof": "by\n simpa +singlePass [← zero_rpow_of_pos hr, rpow_lt_rpow_iff hr] using by positivity" - }, - - # 测试2: 简单的 theorem - { - "name": "简单 theorem 测试", - "code": """theorem simple_example (a b : ℕ) : a + b = b + a := by - exact add_comm a b""", - "expected_statement": "theorem simple_example (a b : ℕ) : a + b = b + a", - "expected_proof": "by\n exact add_comm a b" - }, - - # 测试3: 证明中包含 have 语句 - { - "name": "证明中包含 have 语句测试", - "code": """lemma complex_proof (p q : Prop) (hp : p) (hq : q) : p ∧ q := by - have h1 : p := hp - have h2 : q := hq - exact ⟨h1, h2⟩""", - "expected_statement": "lemma complex_proof (p q : Prop) (hp : p) (hq : q) : p ∧ q", - "expected_proof": "by\n have h1 : p := hp\n have h2 : q := hq\n exact ⟨h1, h2⟩" - }, - - # 测试4: 多行 statement - { - "name": "多行 statement 测试", - "code": """theorem long_statement (n : ℕ) (h : n > 0) : - n * n > 0 := by - exact Nat.mul_pos h h""", - "expected_statement": "theorem long_statement (n : ℕ) (h : n > 0) :\n n * n > 0", - "expected_proof": "by\n exact Nat.mul_pos h h" - }, - - # 测试5: 包含复杂类型参数的 lemma - { - "name": "复杂类型参数测试", - "code": """lemma complex_types {α : Type*} [DecidableEq α] (s : Set α) (h : s.Nonempty) : - ∃ x, x ∈ s := by - exact h""", - "expected_statement": "lemma complex_types {α : Type*} [DecidableEq α] (s : Set α) (h : s.Nonempty) :\n ∃ x, x ∈ s", - "expected_proof": "by\n exact h" - } - ] - - print("=" * 60) - print("LeanCodeParser 解析测试") - print("=" * 60) - - for i, test_case in enumerate(test_cases, 1): - print(f"\n测试 {i}: {test_case['name']}") - print("-" * 40) - - try: - parser = LeanCodeParser(test_case['code']) - blocks = parser.extract_all_blocks(keys=["theorem", "lemma"]) - - if blocks: - block = blocks[0] - info = block['info'] - - print(f"✓ 成功解析") - print(f"名称: {info['name']}") - print(f"证明风格: {info['proof_style']}") - print(f"包含 sorry: {info['with_sorry']}") - print(f"\nStatement:") - print(f"'{info['statement']}'") - print(f"\nProof:") - print(f"'{info['proof']}'") - - # 检查是否符合预期 - if info['statement'].strip() == test_case['expected_statement'].strip(): - print("✓ Statement 解析正确") - else: - print("✗ Statement 解析错误") - print(f"期望: '{test_case['expected_statement']}'") - - if info['proof'].strip() == test_case['expected_proof'].strip(): - print("✓ Proof 解析正确") - else: - print("✗ Proof 解析错误") - print(f"期望: '{test_case['expected_proof']}'") - - else: - print("✗ 未能解析出任何 block") - - except Exception as e: - print(f"✗ 解析出错: {e}") - - print() - -def test_sorry_replacement(): - """测试 sorry 替换功能""" - - print("=" * 60) - print("Sorry 替换测试") - print("=" * 60) - - test_code = """lemma test_lemma (a b : ℕ) : a + b = b + a := by - exact add_comm a b - -theorem test_theorem (p : Prop) : p → p := by - intro h - exact h""" - - print("原始代码:") - print(test_code) - print("\n" + "-" * 40) - - try: - result = create_proof_with_sorries(test_code, keys=["theorem", "lemma"]) - print("替换后的代码:") - print(result) - print("\n✓ Sorry 替换成功") - except Exception as e: - print(f"✗ Sorry 替换失败: {e}") - -if __name__ == "__main__": - test_parsing() - test_sorry_replacement() diff --git a/scripts/difficulty_estimates.json b/scripts/difficulty_estimates.json new file mode 100644 index 0000000..44d71f7 --- /dev/null +++ b/scripts/difficulty_estimates.json @@ -0,0 +1,716 @@ +[ + { + "project_name": "FeitThompsonTheorem", + "name": "feit_thompson", + "title": "Feit–Thompson theorem", + "estimated_pages": 255, + "explanation": "The full theorem (every odd-order finite group is solvable) requires the entire 255-page Feit-Thompson argument: local analysis classifying maximal subgroups, exceptional/coherent character theory and the Dade isometry, and Thompson's generators-and-relations elimination of the final configuration." + }, + { + "project_name": "FriedlanderIwaniecTheorem", + "name": "friedlander_iwaniec", + "title": "Friedlander--Iwaniec theorem", + "estimated_pages": 90, + "explanation": "Infinitude of primes of the form a^2+b^4 needs Friedlander-Iwaniec's ~100-page parity-sensitive asymptotic sieve for primes, with delicate Type I/II bilinear-form estimates and the 'spin' of Gaussian ideals to handle this density-X^{3/4} sparse sequence." + }, + { + "project_name": "GreenTaoTheorem", + "name": "Nat.Prime.greenTao", + "title": "Green–Tao theorem", + "estimated_pages": 90, + "explanation": "The full Green-Tao result requires Szemeredi's theorem (itself a major graduate theorem), a relative/transference Szemeredi theorem against a pseudorandom measure, and the Goldston-Pintz-Yildirim sieve construction enveloping the primes, all of which the formal statement demands in full generality for arbitrary k." + }, + { + "project_name": "RobinTheorem", + "name": "robin", + "title": "Robin's theorem", + "estimated_pages": 80, + "explanation": "The formalized statement is the full biconditional with the Riemann Hypothesis, so the reverse direction effectively requires proving RH; even granting that, Robin's 1984 forward analysis uses Gronwall's maximal-order asymptotics, Mertens' third theorem, superabundant/colossally-abundant number theory and explicit zero-free-region estimates for zeta." + }, + { + "project_name": "LinnikTheorem", + "name": "linnik", + "title": "Linnik's theorem", + "estimated_pages": 60, + "explanation": "The least prime in an arithmetic progression bound requires the full analytic machinery of Linnik's proof: log-free zero-density estimates for Dirichlet L-functions, the Deuring-Heilbronn phenomenon repelling exceptional Siegel zeros, and zero-free regions, the deepest result in the set." + }, + { + "project_name": "SzemerediTheorem", + "name": "szemeredi", + "title": "Szemerédi's Theorem", + "estimated_pages": 60, + "explanation": "The formal statement is the full Szemeredi theorem (positive upper density forces arbitrarily long arithmetic progressions); every known route is deep research-level - Furstenberg's ergodic-theoretic multiple recurrence, Gowers' Fourier analysis with the inverse theorem for Gowers norms, or Szemeredi's regularity lemma - each requiring extensive machinery far beyond undergraduate." + }, + { + "project_name": "TwoNinety", + "name": "two_ninety_theorem", + "title": "The 290 Theorem", + "estimated_pages": 50, + "explanation": "Bhargava-Hanke's proof escalates lattices up to rank 7 (~20000 cases) and certifies universality of the remaining forms via theta-series identities and analytic bounds on Fourier coefficients of cusp forms, requiring substantial modular-forms machinery plus large verified computations." + }, + { + "project_name": "KoukoulopoulosMaynard", + "name": "koukoulopoulos_maynard", + "title": "Duffin–Schaeffer conjecture / Koukoulopoulos–Maynard theorem", + "estimated_pages": 45, + "explanation": "This is the full Duffin-Schaeffer conjecture (Koukoulopoulos-Maynard, Annals 2020), whose proof builds the novel combinatorial theory of GCD graphs and their 'quality' combined with the anatomy of integers and sieve theory to rule out compressed/large-GCD structures, an entire research-paper's worth of new machinery." + }, + { + "project_name": "ChenTheorem", + "name": "chen", + "title": "Chen's theorem", + "estimated_pages": 30, + "explanation": "The formalized statement is the full Chen's theorem (every sufficiently large even number = prime + (prime or semiprime)), whose proof is a celebrated, long and intricate application of the weighted (Chen's double) sieve combined with the Bombieri-Vinogradov theorem on primes in arithmetic progressions and Jurkat-Richert-type sieve bounds, well beyond undergraduate analytic number theory even in Ross's simplified form." + }, + { + "project_name": "FareySequence", + "name": "farey_riemann_abs", + "title": "Farey Sequence", + "estimated_pages": 30, + "explanation": "Formalizes the full Franel-Landau equivalence (an iff) between RH and the L^1 discrepancy bound on Farey fractions, which requires both directions of the deep analytic-number-theory link (Mellin/Perron-type transforms and the explicit-formula apparatus connecting Farey discrepancy to zeros of zeta), making it as demanding as developing the surrounding zeta-function machinery." + }, + { + "project_name": "MergelyanTheorem", + "name": "mergelyan", + "title": "Mergelyan's theorem", + "estimated_pages": 30, + "explanation": "Uniform polynomial approximation on compacts with connected complement requires the deep constructive machinery of Mergelyan/Vitushkin: Cauchy-transform integral representations, smoothing via partitions of unity, continuity of analytic capacity, and Runge-type pole-pushing, well beyond undergraduate complex analysis." + }, + { + "project_name": "RothTheorem", + "name": "roth", + "title": "Roth's theorem", + "estimated_pages": 30, + "explanation": "Full Thue-Siegel-Roth theorem (irrationality measure exactly 2 for algebraic irrationals), whose proof needs the auxiliary-multivariate-polynomial method, Siegel's lemma from geometry of numbers, and Roth's lemma on the index/Wronskians of polynomials proved by induction on the number of variables." + }, + { + "project_name": "CameronErdos", + "name": "cameron_erdos", + "title": "Cameron–Erdős conjecture", + "estimated_pages": 25, + "explanation": "Proving the number of sum-free subsets of [n] is O(2^{n/2}) requires either Green's discrete Fourier analysis with the hypergraph container method or Sapozhenko's Kleitman-Winston/graph-container approach, a substantial body of modern additive-combinatorics research machinery." + }, + { + "project_name": "KroneckerWeberTheorem", + "name": "KroneckerWeber", + "title": "Kronecker–Weber theorem", + "estimated_pages": 25, + "explanation": "The formalized statement is the full Kronecker-Weber theorem (every abelian extension of Q lies in a cyclotomic field), whose proof requires either global class field theory (Artin reciprocity) or the ramification-group approach reducing to the local Kronecker-Weber theorem plus Minkowski's discriminant bound, all substantial graduate algebraic number theory." + }, + { + "project_name": "Fifteen", + "name": "fifteen_theorem", + "title": "The 15 Theorem", + "estimated_pages": 25, + "explanation": "The integer-symmetric-matrix (even) form of the 15 theorem needs Bhargava's escalator-lattice induction together with the arithmetic theory of ternary/quaternary positive-definite quadratic forms (local representability, genus theory, and case analysis over the escalator tree), substantial graduate quadratic-form machinery." + }, + { + "project_name": "FreimanTheorem", + "name": "Freiman", + "title": "Freiman's Theorem", + "estimated_pages": 20, + "explanation": "The full structure theorem requires the chain of additive-combinatorics machinery: Plunnecke-Ruzsa inequalities, the Ruzsa modeling lemma via Freiman homomorphisms, Bogolyubov's lemma with Fourier analysis on Bohr sets, and Minkowski's geometry-of-numbers to extract a bounded-dimension generalized arithmetic progression." + }, + { + "project_name": "BrunTitchmarshTheorem", + "name": "brunTitchmarsh", + "title": "Brun–Titchmarsh theorem", + "estimated_pages": 18, + "explanation": "The sharp constant-2 bound on primes in an arithmetic progression in a short interval requires the Montgomery-Vaughan large sieve (or Selberg's sieve with the bilinear error analysis), substantial analytic number theory machinery well beyond undergraduate level." + }, + { + "project_name": "GelfondSchneiderTheorem", + "name": "gelfond_scheider", + "title": "Gelfond–Schneider theorem", + "estimated_pages": 18, + "explanation": "Gelfond-Schneider's seventh-Hilbert-problem proof builds an auxiliary function via the Thue-Siegel-Dirichlet box principle (Siegel's lemma over algebraic integers), bounds its derivatives/values using complex-analytic interpolation and the maximum modulus principle, and derives a contradiction from arithmetic size (house) estimates; this transcendence machinery is well beyond undergraduate, though the formalized statement is garbled (it asserts the algebraic b is transcendental)." + }, + { + "project_name": "HasseTheoremOnEllipticCurves", + "name": "HasseBound", + "title": "Hasse's theorem on elliptic curves", + "estimated_pages": 14, + "explanation": "Hasse's bound follows from showing the degree map on End(E) is a positive-definite quadratic form and applying Cauchy-Schwarz to the Frobenius-related pairing, but developing the elliptic-curve group law over finite fields, the Frobenius endomorphism, separability/degree of isogenies, and #E = deg(1-Frob) is substantial graduate arithmetic geometry." + }, + { + "project_name": "ErdosKacTheorem", + "name": "erdos_kac", + "title": "Erdős–Kac theorem", + "estimated_pages": 12, + "explanation": "Establishes the full normal-distribution limit law via the method of moments (Granville-Soundararajan style) or the original Brun-sieve-plus-Lindeberg-CLT argument, requiring graduate analytic number theory (mean values of additive functions, sieve error control) well beyond the undergraduate CLT it superficially resembles." + }, + { + "project_name": "GrushkoTheorem", + "name": "grushko", + "title": "Grushko theorem", + "estimated_pages": 12, + "explanation": "Grushko's theorem on the rank of a free product is proved either via Stallings' equivariant foldings of group actions on covering complexes/trees or via Bass-Serre theory and graphs of groups, both requiring graduate geometric group theory and algebraic topology beyond the undergraduate curriculum." + }, + { + "project_name": "Apery", + "name": "apery", + "title": "Apery", + "estimated_pages": 10, + "explanation": "Full irrationality of zeta(3) is formalized, requiring Apery's delicate construction of two integer-recurrence sequences (Apery numbers), nontrivial control of the lcm-denominators to keep them near-integral, and a Diophantine-approximation irrationality criterion, all of which take substantial graduate-level development to make rigorous." + }, + { + "project_name": "JordanSchurTheorem", + "name": "jordan_schur", + "title": "Jordan–Schur theorem", + "estimated_pages": 9, + "explanation": "Even though the formalized statement only asks for existence of some bounding function f(n) (no explicit bound), establishing it still needs the full Frobenius-Blichfeldt argument using character theory and a quantitative bound on commutators of near-identity unitary matrices, which is substantial graduate group-representation machinery." + }, + { + "project_name": "BrunTheorem", + "name": "brun", + "title": "Brun's theorem", + "estimated_pages": 8, + "explanation": "Requires Brun's combinatorial sieve (his 'pure sieve', a truncated inclusion-exclusion) to bound the twin-prime counting function by O(x/log^2 x), from which summability follows; developing the sieve machinery and the careful error-term estimates is the bulk of the work, beyond standard undergraduate number theory." + }, + { + "project_name": "CriticalLineTheorem", + "name": "critical_line", + "title": "Critical Line Theorem", + "estimated_pages": 8, + "explanation": "The statement is exactly Hardy's 1914 theorem (infinitely many zeta zeros on Re(s)=1/2), proved via Hardy's Z-function and the theta/Jacobi transformation formula together with the approximate functional equation and integral/moment estimates of Z(t), requiring genuine analytic number theory beyond a basic complex analysis course." + }, + { + "project_name": "KaplanskyTheoremOnQuadraticForms", + "name": "kaplansky_two", + "title": "Kaplansky's theorem on quadratic forms", + "estimated_pages": 8, + "explanation": "This 2003 result combines Gauss's quartic-residue criterion (2 is a 4th power mod p iff p = x^2+64y^2) and the Barrucand-Cohn octic criterion (-4 is an 8th power iff p = x^2+32y^2) with genus theory of binary quadratic forms and higher reciprocity, requiring well beyond undergraduate number theory." + }, + { + "project_name": "LukacsProportionSumIndependenceTheorem", + "name": "lukacs_proportion_sum_independence_iff", + "title": "Lukacs's proportion-sum independence theorem", + "estimated_pages": 8, + "explanation": "The hard (only-if) direction is a characterization theorem proved via Laplace transforms/characteristic functions reduced to a Cauchy-type functional equation forcing the gamma law, requiring graduate mathematical-statistics machinery plus the measure-theoretic setup of HasLaw and the gamma measure." + }, + { + "project_name": "WaringProblem", + "name": "waring", + "title": "Waring's Problem", + "estimated_pages": 8, + "explanation": "The formalized statement only asserts existence of a uniform bound t (the Hilbert-Waring theorem), proved by Hilbert via algebraic polynomial identities (the Hilbert identity expressing power-sum integrals as sums of k-th powers) and an induction; clever and several pages beyond undergraduate but far easier than determining g(n) via the circle method." + }, + { + "project_name": "ZsigmondyTheorem", + "name": "zsigmondy_theorem", + "title": "Zsigmondy's theorem", + "estimated_pages": 8, + "explanation": "The proof factors a^n - b^n via homogeneous cyclotomic polynomials Phi_n(a,b), shows any primitive prime divides Phi_n, then uses multiplicative-order arguments plus the Lifting-the-Exponent lemma (Birkhoff-Vandiver) and analytic lower bounds on Phi_n(a,b) to force a contradiction, with delicate separate handling of the n=2 power-of-two and (a,b,n)=(2,1,6) exceptions; the formalized statement is the full general theorem with both exceptions, requiring substantial cyclotomic-polynomial and p-adic-valuation machinery beyond undergraduate number theory." + }, + { + "project_name": "JacobsonMorozovTheorem", + "name": "Jacobson_Morozov", + "title": "Jacobson-Morozov Theorem", + "estimated_pages": 7, + "explanation": "Driven by graduate structure theory of semisimple Lie algebras: an induction on dimension using the Killing form, representation theory of sl2, and a cohomological/centralizer argument to extend a nilpotent ad-nilpotent element to a full sl2-triple." + }, + { + "project_name": "NagellLutzTheorem", + "name": "NagellLutz2", + "title": "Nagell–Lutz theorem", + "estimated_pages": 7, + "explanation": "Full theorem driven by graduate elliptic-curve machinery: p-adic valuations / the formal group filtration on E1(Qp) and reduction mod p to bound torsion, plus the discriminant-divisibility (y^2 | Delta) step, all of which must be developed beyond undergraduate algebra." + }, + { + "project_name": "AztecDiamond", + "name": "aztecDiamond_tiling", + "title": "Aztec-Diamonds", + "estimated_pages": 6, + "explanation": "The full count 2^(n(n+1)/2) for all n is formalized; even the 'simple' proofs require real machinery such as the Lindstrom-Gessel-Viennot lemma with Hankel/Schroder-number determinant evaluations, or the domino-shuffling/field-of-arrows induction, none of which is standard undergraduate material." + }, + { + "project_name": "BrunnMinkowski", + "name": "EuclideanSpace.volume_pow_add_le", + "title": "Brunn-Minkowski Inequality (Additive Form)", + "estimated_pages": 6, + "explanation": "The additive Brunn-Minkowski inequality in general dimension n needs either the Hadwiger-Ohmann induction through boxes/finite unions plus measure-theoretic limiting arguments, or the Prekopa-Leindler functional approach with induction on dimension via Fubini; conceptually graduate-level measure theory and convex geometry." + }, + { + "project_name": "BrunnMinkowski", + "name": "EuclideanSpace.volume_pow_mul_le", + "title": "Brunn-Minkowski Inequality (Multiplicative Form)", + "estimated_pages": 6, + "explanation": "The multiplicative (dimension-free-exponent) form is equivalent to the additive Brunn-Minkowski via weighted AM-GM, so it carries the same Prekopa-Leindler/Hadwiger-Ohmann machinery and induction-on-dimension burden as the additive version." + }, + { + "project_name": "Carmichael", + "name": "carmichael", + "title": "Carmichael's theorem", + "estimated_pages": 6, + "explanation": "Establishing a primitive prime divisor for Lucas sequences U_n (n outside {1,2,6,12}) uses factorization via cyclotomic polynomials Phi_n at the roots, lower bounds on cyclotomic values versus the radical of n, and Yabuta's reduction to Fibonacci/Fermat sequences; technical elementary number theory beyond standard coursework." + }, + { + "project_name": "DillerDressTheorem", + "name": "diller_dress", + "title": "Diller–Dress theorem", + "estimated_pages": 6, + "explanation": "The going-down of the Pythagorean property under finite extensions rests on the algebraic theory of quadratic forms over fields, specifically Scharlau transfer (trace forms) and Witt-ring arguments controlling sums of squares, which is graduate-level quadratic-form theory not in the standard undergraduate algebra curriculum." + }, + { + "project_name": "PicardTheorem", + "name": "picard", + "title": "Picard theorem", + "estimated_pages": 6, + "explanation": "Little Picard theorem: the formalized 'omits two values implies constant' statement still needs either the elliptic modular lambda covering of the twice-punctured plane or the Bloch/Landau-theorem route, machinery well beyond a basic complex-analysis course." + }, + { + "project_name": "PolygonalNumberTheorem", + "name": "polygonal_number_theorem_odd", + "title": "Polygonal Number Theorem (Odd Case)", + "estimated_pages": 6, + "explanation": "Nathanson's proof of the odd case rests on Cauchy's lemma producing a four-square representation with prescribed root-sum, which in turn invokes Gauss's three-square theorem (genus theory / ternary quadratic forms), the main source of difficulty beyond undergraduate number theory." + }, + { + "project_name": "RamanujanNagellEquation", + "name": "ramanujan_nagell", + "title": "Ramanujan–Nagell equation", + "estimated_pages": 6, + "explanation": "Nagell's proof factors 2^n - 7 = x^2 in the ring of integers of Q(sqrt(-7)) using unique factorization and the unit group {+-1}, then a recurrence/2-adic argument forces n in {3,4,5,7,15}; the algebraic-number-theory setup (class number one, factorization in Z[(1+sqrt(-7))/2]) is the graduate-level core." + }, + { + "project_name": "TverbergTheorem", + "name": "tverberg", + "title": "Tverberg's theorem", + "estimated_pages": 6, + "explanation": "The formalized statement is the full affine Tverberg theorem for all d,r; Sarkaria's proof uses a tensor/Kronecker-product lifting reducing it to the colorful Caratheodory theorem (Barany), a compact but conceptually nontrivial argument with the colorful Caratheodory lemma itself needing proof." + }, + { + "project_name": "AndersonTheorem", + "name": "anderson", + "title": "Anderson's theorem", + "estimated_pages": 5, + "explanation": "The general n-dimensional statement is formalized; the standard proof goes through the Brunn-Minkowski inequality applied to convex superlevel sets (the layer-cake decomposition of the unimodal f), which is genuine graduate convex-geometry machinery rather than a one-dimensional rearrangement." + }, + { + "project_name": "BorsukUlamTheorem", + "name": "borsuk_ulam", + "title": "Borsuk–Ulam theorem", + "estimated_pages": 5, + "explanation": "The full S^n version is formalized; the proof needs algebraic-topology machinery (degree theory or Z/2 homology/cohomology of projective spaces with the Hurewicz and universal-coefficient theorems), or alternatively the combinatorial Tucker's lemma, all requiring development well beyond undergraduate topology." + }, + { + "project_name": "JacobiFourSquareTheorem", + "name": "jacobi", + "title": "Jacobi's Four-Square Theorem", + "estimated_pages": 5, + "explanation": "The classical proof represents the number of four-square representations via the fourth power of the Jacobi theta function and identifies it with an Eisenstein series / Lambert series using the Jacobi triple product and theta-function identities, which is doable elementarily but requires several pages of theta-function machinery beyond undergraduate analysis." + }, + { + "project_name": "SchauderFixedPointTheorem", + "name": "SchauderFixedPointTheorem", + "title": "Schauder fixed-point theorem", + "estimated_pages": 5, + "explanation": "Infinite-dimensional fixed-point theorem reducing to Brouwer's fixed-point theorem via finite-dimensional approximation by a partition-of-unity (Schauder projection) onto convex hulls of finite epsilon-nets in the compact convex set of a locally convex TVS." + }, + { + "project_name": "BeckmanQuarlesTheorem", + "name": "beckmann_quarles", + "title": "Beckman–Quarles theorem", + "estimated_pages": 4, + "explanation": "The genuine theorem (d>=2) relies on the structural rigidity of unit-distance graphs, e.g. propagating preserved unit distances through rigid simplex configurations to a dense set of distances; note the formal statement omits the d>=2 hypothesis so it is actually false for d=1 where a unit-shift counterexample exists, but the hard mathematical content is the rigidity argument." + }, + { + "project_name": "CarlsonTheorem", + "name": "carlson", + "title": "Carlson's theorem", + "estimated_pages": 4, + "explanation": "The proof divides f by the sine function (whose zeros are the integers) and applies the Phragmen-Lindelof principle in a half-plane, using the exponential-type bound and the sub-pi growth on the imaginary axis to force the quotient to vanish; intermediate complex analysis a step beyond the undergraduate core." + }, + { + "project_name": "ErdosDushnikMillerTheorem", + "name": "erdos_dushnik_miller", + "title": "Erdős–Dushnik–Miller theorem", + "estimated_pages": 4, + "explanation": "This infinite partition relation (clique of size |V| or a countably infinite independent set) requires transfinite recursion over cardinals and a tree/elementary-submodel style argument in infinitary combinatorics, genuinely set-theoretic machinery beyond undergraduate combinatorics." + }, + { + "project_name": "HardyLittlewoodTauberian", + "name": "tauberian", + "title": "Hardy–Littlewood Tauberian theorem", + "estimated_pages": 4, + "explanation": "Karamata's elegant proof reduces the Tauberian statement to approximating a step function by polynomials (Weierstrass approximation) applied to the positive-coefficient series, using essentially only real analysis but with a genuinely non-obvious approximation argument slightly above routine undergraduate work." + }, + { + "project_name": "KolmogorovThreeSeriesNecessary", + "name": "kolmogorov_three_series_necessity", + "title": "Kolmogorov's Three Series, necessity", + "estimated_pages": 4, + "explanation": "The necessity direction is the harder one, requiring Kolmogorov's inequality/two-series theorem and a symmetrization plus martingale (or CLT-type) variance argument to deduce the truncated variance and mean series converge, all in measure-theoretic probability beyond undergraduate level." + }, + { + "project_name": "TotientGrowthRate", + "name": "totient_lower_bound", + "title": "Lower bound on totient growth", + "estimated_pages": 4, + "explanation": "The explicit bound phi(n) > n/(e^gamma loglog n + 3/loglog n) rests on Mertens' third theorem (product over primes ~ e^{-gamma}/log x) plus Chebyshev-type estimates and careful error control, modestly beyond the standard undergraduate analytic-number-theory toolkit." + }, + { + "project_name": "SinkhornTheorem", + "name": "sinkhorn_existence", + "title": "Sinkhorn's theorem", + "estimated_pages": 4, + "explanation": "Existence of diagonal scalings to doubly stochastic form, proved via a compactness/continuity or convex-optimization (entropy minimization) argument on positive matrices, beyond routine undergraduate material but using only finite-dimensional analysis." + }, + { + "project_name": "TwoFactorTheorem", + "name": "two_factor_theorem", + "title": "2-factor theorem", + "estimated_pages": 3, + "explanation": "Petersen's proof orients the graph via an Eulerian circuit to get an in/out-degree-k digraph, then splits each vertex into a k-regular bipartite graph and decomposes it into k perfect matchings by Konig's theorem - standard advanced-undergraduate graph theory." + }, + { + "project_name": "BanachMazur", + "name": "banach_mazur", + "title": "Banach-Mazur Theorem", + "estimated_pages": 3, + "explanation": "The full separable case is formalized; the proof embeds the space into C[0,1] (via C of the weak-* compact, metrizable dual unit ball plus a Peano space-filling surjection) using Hahn-Banach and weak-* compactness, which is graduate functional analysis beyond the undergraduate core." + }, + { + "project_name": "BrooksTheorem", + "name": "brooks_theorem", + "title": "Brooks' theorem", + "estimated_pages": 3, + "explanation": "Formalizes the full classification; Lovasz's proof is upper-undergraduate combinatorics but genuinely involved, requiring a biconnectivity reduction, a careful greedy ordering via a spanning tree rooted to leave a neighbor uncolored, and special-case handling of the regular biconnected case." + }, + { + "project_name": "CaristiFixedPointTheorem", + "name": "caristi", + "title": "Caristi fixed-point theorem", + "estimated_pages": 3, + "explanation": "The proof builds a partial order x <= y iff dist(x,y) <= f(x)-f(y) and applies Zorn's lemma (using completeness and lower semicontinuity) to extract a minimal element that must be a fixed point; a short argument using graduate-flavored but elementary order/metric reasoning." + }, + { + "project_name": "ErdosGallaiTheorem", + "name": "ErdosGallaiTheorem", + "title": "Erdős–Gallai theorem", + "estimated_pages": 3, + "explanation": "The full characterization of graphical degree sequences (the iff) needs the harder existence direction, established by induction on the degree sum (Choudum) or a subrealization/edge-swapping construction (Tripathi et al.); this is involved but elementary graph theory, the constructive realization being the main work." + }, + { + "project_name": "Fitting", + "name": "fitting", + "title": "Fitting's theorem", + "estimated_pages": 3, + "explanation": "A standard graduate group-theory result proved by commutator calculus and the three-subgroups lemma to bound the nilpotency class of MN by m+n; short once the commutator identities and lower-central-series bookkeeping are set up." + }, + { + "project_name": "HurwitzApproximation", + "name": "hurwitz_approximation", + "title": "Hurwitz's Approximation Theorem", + "estimated_pages": 3, + "explanation": "Hurwitz's approximation theorem is proved through the theory of continued fractions (showing one of three consecutive convergents satisfies the sqrt5 bound) or via Farey/mediant arguments, standard elementary number theory but requiring the somewhat involved convergent-comparison machinery." + }, + { + "project_name": "KolmogorovThreeSeriesSufficient", + "name": "kolmogorov_three_series_sufficiency", + "title": "Kolmogorov's Three Series, sufficiency", + "estimated_pages": 3, + "explanation": "The sufficiency direction follows from Kolmogorov's two-series theorem (via Kolmogorov's maximal inequality) on the centered truncated variables plus Borel-Cantelli to pass back to the original series, requiring graduate-level measure-theoretic probability machinery." + }, + { + "project_name": "LeCamTheorem", + "name": "LeCamTheorem", + "title": "Le Cam's theorem", + "estimated_pages": 3, + "explanation": "The formalized bound (total variation of a sum of independent Bernoullis from Poisson <= 2 sum p_i^2) is proved by a coupling/Serfling argument bounding each Bernoulli-vs-Poisson term, modest graduate probability beyond undergraduate measure-theoretic probability." + }, + { + "project_name": "LevitzkyTheorem", + "name": "levitzky_theorem", + "title": "Levitzky's theorem", + "estimated_pages": 3, + "explanation": "Utumi's argument uses the ascending chain condition (here Noetherian on the opposite ring) to extract a maximal nilpotent ideal and reduce to a semiprime quotient, requiring graduate noncommutative ring theory on nil versus nilpotent ideals." + }, + { + "project_name": "LusinTheorem", + "name": "lusin", + "title": "Lusin's theorem", + "estimated_pages": 3, + "explanation": "Standard real-analysis proof via approximating the measurable function by simple/continuous functions, Egorov's theorem to upgrade to near-uniform convergence, and an inner-regularity/Tietze extension step; modest material slightly beyond a first measure theory course." + }, + { + "project_name": "PrekopaLeindler", + "name": "prekopa_leindler_dim1", + "title": "Main Theorem: Prékopa-Leindler inequality in dimension 1", + "estimated_pages": 3, + "explanation": "The 1D case has a short proof via a measure-transport/level-set (essential-supremum convolution) argument with the layer-cake formula and a Brunn-Minkowski-type 1D length bound; only modestly beyond undergraduate measure theory." + }, + { + "project_name": "MertensFirstTheorem", + "name": "merten_first", + "title": "Mertens' First Theorem", + "estimated_pages": 3, + "explanation": "Elementary analytic number theory: Legendre's formula for v_p(n!), Stirling's estimate for log(n!), and Abel partial summation give the bounded-difference estimate; mostly within reach of undergraduate analysis but requires assembling these prime-power summation arguments." + }, + { + "project_name": "MycielskiTheorem", + "name": "mycielski", + "title": "Mycielski's theorem", + "estimated_pages": 3, + "explanation": "Requires iterating the Mycielskian construction and proving by induction that it stays triangle-free (K3-free) while raising the chromatic number by one via a recoloring/contradiction argument; the formalized statement is just the existence direction, but building the construction and the chromatic-number lower bound in a proof assistant is non-trivial combinatorics." + }, + { + "project_name": "SinkhornTheorem", + "name": "sinkhorn_uniqueness", + "title": "Sinkhorn's theorem", + "estimated_pages": 3, + "explanation": "Uniqueness (up to the scalar c) of the diagonal scalings, established by a strict-convexity/log-convexity argument on the positive scaling factors showing two doubly-stochastic scalings must differ only by the stated reciprocal constant." + }, + { + "project_name": "SzemerediTrotterTheorem", + "name": "szemeredi_trotter", + "title": "Szemerédi–Trotter theorem", + "estimated_pages": 3, + "explanation": "Szekely's proof builds a planar graph from points and line-segments and applies the crossing-number inequality (itself from Euler's formula plus a probabilistic deletion argument), a short and clever advanced-undergraduate combinatorial-geometry argument." + }, + { + "project_name": "Wolstenholme", + "name": "wolstenholme", + "title": "Wolstenholme's theorem", + "estimated_pages": 3, + "explanation": "Wolstenholme's mod-p^3 congruence follows from manipulating C(2p-1,p-1) into 1 + p*(harmonic-type sum) and showing the relevant Wolstenholme harmonic sums vanish mod p^2 via pairing/inversion arguments in the cyclic group, a few pages of elementary-but-careful number theory." + }, + { + "project_name": "BauerFike", + "name": "bauer_fike", + "title": "Bauer–Fike Theorem", + "estimated_pages": 2, + "explanation": "A standard diagonalizable-matrix eigenvalue perturbation bound whose roughly two-thirds-page proof is a similarity transformation plus a subordinate-matrix-norm/condition-number estimate, essentially advanced undergraduate linear algebra with only a thin layer of perturbation-theory machinery." + }, + { + "project_name": "BondyTheorem", + "name": "bondy", + "title": "Bondy's theorem", + "estimated_pages": 2, + "explanation": "A short extremal-combinatorics result (drop one column from an n-by-n 0-1 matrix with distinct rows keeping rows distinct) provable by a linear-algebra dimension/rank argument over GF(2) or a direct counting induction, only modestly beyond the undergraduate core." + }, + { + "project_name": "CartanBrauerHuaTheorem", + "name": "cartan_brauer_hua", + "title": "Cartan–Brauer–Hua theorem", + "estimated_pages": 2, + "explanation": "Despite its fame, the proof is a short consequence of Hua's identity showing the invariant subfield is fixed; only basic division-ring algebra is needed once the identity is in hand, essentially undergraduate-to-early-graduate." + }, + { + "project_name": "ContinuousMappingLaw", + "name": "ProbabilityMeasure.tendsto_map_of_forall_continuousAt", + "title": "Continuous Mapping Theorem (convergence in distribution version)", + "estimated_pages": 2, + "explanation": "The convergence-in-distribution version requires the portmanteau theorem and careful handling of the discontinuity set having limit-measure zero (weak convergence machinery), modestly beyond a first probability course but standard graduate measure-theoretic probability." + }, + { + "project_name": "FrankWolfe", + "name": "frank_wolfe_convergence_rate", + "title": "Convergence rate of Frank-Wolfe algorithm", + "estimated_pages": 2, + "explanation": "The O(1/k) convergence bound follows from the smoothness (descent) lemma giving a per-step decrease via the curvature/duality gap and a simple induction on the optimality gap; essentially advanced-undergraduate convex optimization." + }, + { + "project_name": "DeBruijnErdos", + "name": "SimpleGraph.colorable_of_finitely_colorable", + "title": "De Bruijn-Erd\\H{o}s Theorem (Graph Coloring)", + "estimated_pages": 2, + "explanation": "The De Bruijn-Erdos compactness theorem follows from a short topological compactness argument (Tychonoff on the product of finite color spaces) or equivalently Zorn's lemma / the ultrafilter lemma, a modest use of the axiom of choice slightly beyond standard undergraduate topology." + }, + { + "project_name": "Dilworth", + "name": "dilworth", + "title": "Dilworth's Theorem", + "estimated_pages": 2, + "explanation": "The finite Dilworth theorem has a clean induction proof (Galvin) or a reduction to Konig's bipartite matching/Hall's theorem; it is elementary combinatorics but the chain-partition construction and case analysis push it slightly past trivial." + }, + { + "project_name": "Hinge", + "name": "hinge_iff_geometric", + "title": "Hinge Theorem", + "estimated_pages": 2, + "explanation": "This geometric (metric-space) version of the hinge/SAS-inequality requires deriving the law of cosines from the distance/angle structure and the monotonicity of cosine, modestly above the bare algebraic version but still elementary undergraduate Euclidean geometry." + }, + { + "project_name": "KoebeQuarterTheorem", + "name": "koebe", + "title": "Koebe quarter theorem", + "estimated_pages": 2, + "explanation": "A compact complex-analysis proof: the Gronwall area theorem gives Bieberbach's bound |a2| <= 2 for normalized univalent functions, and applying it to the auxiliary function w f/(w-f) yields the 1/4 radius bound; only a couple of pages beyond standard undergraduate complex analysis." + }, + { + "project_name": "ProthTheorem", + "name": "proth", + "title": "Proth's theorem", + "estimated_pages": 2, + "explanation": "A special case of the Pocklington-Lehmer test (like Pepin's test): the converse and forward directions follow from Euler's criterion and order-of-element arguments mod n for n = k*2^m+1, essentially elementary number theory." + }, + { + "project_name": "SchurRamsey", + "name": "schur", + "title": "Schur's theorem", + "estimated_pages": 2, + "explanation": "Short combinatorial pigeonhole/Ramsey argument: apply Ramsey's theorem to the complete graph colored by edge differences to get a monochromatic triangle yielding x+y=z, requiring development of finite Ramsey's theorem." + }, + { + "project_name": "StarOfDavid", + "name": "starofdavid", + "title": "Star of David", + "estimated_pages": 2, + "explanation": "Elementary number theory: prove the two triples of binomial coefficients have equal gcd by factorial manipulation of the Star-of-David hexagon identity, with care over the natural-number edge cases (k=0, n=0) in the formal statement." + }, + { + "project_name": "Vantieghem", + "name": "vantieghem", + "title": "Vantieghem's Theorem", + "estimated_pages": 2, + "explanation": "This primality criterion is proved from properties of cyclotomic polynomials over F_2 (or, for the 'if' direction, just Fermat's little theorem and elementary congruences), a short self-contained number-theory argument near the undergraduate level." + }, + { + "project_name": "VonStaudtClausen", + "name": "von_staudt_clausen", + "title": "Von Staudt-Clausen Theorem", + "estimated_pages": 2, + "explanation": "The classical proof expresses Bernoulli numbers via Stirling-number/binomial sums and uses Fermat's little theorem to evaluate power sums mod p, distinguishing whether p-1 divides 2n - entirely elementary modular arithmetic with only modest mileage beyond undergraduate." + }, + { + "project_name": "BergeTheorem", + "name": "SimpleGraph.Subgraph.IsMatching.berge", + "title": "Berge's theorem", + "estimated_pages": 1, + "explanation": "A standard undergraduate graph-theory result proved by analyzing the symmetric difference of two matchings into alternating paths and even cycles; the only effort is the component-structure lemma, requiring essentially no machinery beyond the undergraduate level." + }, + { + "project_name": "CasoratiWeierstrass", + "name": "casorati_weierstrass", + "title": "Casorati-Weierstrass", + "estimated_pages": 1, + "explanation": "Standard undergraduate complex analysis: assume the image misses a neighborhood of some value b, form the bounded holomorphic g=1/(f-b), apply Riemann's removable-singularity theorem, and derive that the singularity is not essential, a contradiction; a one-paragraph proof." + }, + { + "project_name": "CondorcetJury", + "name": "condorcet_jury_theorem", + "title": "Condorcet's Jury Theorem", + "estimated_pages": 1, + "explanation": "Fully elementary: the monotonicity in n follows from a short pivotal-voter/binomial-tail comparison (the (1-p)p^2 vs p(1-p)^2 argument) using only basic probability and combinatorics at the undergraduate level." + }, + { + "project_name": "ContinuousMappingAs", + "name": "ae_tendsto_comp_of_ae_tendsto_of_forall_continuousAt", + "title": "Continuous Mapping Theorem (almost sure convergence version)", + "estimated_pages": 1, + "explanation": "This is the almost-sure version, which is a few-line measure-theoretic argument intersecting two almost-sure events (continuity at the limit point and pointwise convergence) and applying the definition of continuity, entirely undergraduate measure theory." + }, + { + "project_name": "Froda", + "name": "Real.countable_not_continuousAt", + "title": "Froda's Theorem", + "estimated_pages": 1, + "explanation": "Elementary undergraduate real analysis: each jump discontinuity of a monotone function contains a distinct rational between its one-sided limits, injecting the discontinuity set into the countable rationals." + }, + { + "project_name": "GaussLucas", + "name": "Complex.mem_convexHull_roots_of_mem_derivative_roots", + "title": "Gauss-Lucas", + "estimated_pages": 1, + "explanation": "Undergraduate-level: the logarithmic-derivative identity P'(z)/P(z)=sum 1/(z-a_i) at a root of P' rearranges into an explicit positive convex combination of the roots, placing z in their convex hull." + }, + { + "project_name": "Hinge", + "name": "hinge_backward", + "title": "Hinge Theorem with Law of Cosines, Backward", + "estimated_pages": 1, + "explanation": "The converse direction is again pure algebra using the supplied cosine equations and strict monotonicity of cosine on [0,pi], entirely undergraduate." + }, + { + "project_name": "Hinge", + "name": "hinge_forward", + "title": "Hinge Theorem with Law of Cosines, Forward", + "estimated_pages": 1, + "explanation": "Given the two law-of-cosines equations as hypotheses, this reduces to algebra plus the monotonic decrease of cosine on [0,pi], fully elementary undergraduate real analysis." + }, + { + "project_name": "InverseEigenvalue", + "name": "Module.End.inv_eigenvalue_iff", + "title": "Inverse Eigenvalue Theorem", + "estimated_pages": 1, + "explanation": "Despite the 'inverse eigenvalue problem' title, the formalized statement is merely the trivial fact that r is an eigenvalue of an invertible map iff r^-1 is an eigenvalue of the inverse, a one-line linear-algebra computation on eigenvectors." + }, + { + "project_name": "JonesLemma", + "name": "jones", + "title": "Jones' Lemma", + "estimated_pages": 1, + "explanation": "A short cardinal-counting argument: each subset of the discrete closed set has disjoint open neighborhoods by normality, and restricting closures of these to a countable dense set injects the power set of Y into the continuum, using only point-set topology and basic cardinal arithmetic." + }, + { + "project_name": "Kraft", + "name": "kraft", + "title": "Kraft", + "estimated_pages": 1, + "explanation": "An entirely elementary combinatorial construction: sort the lengths and greedily assign codewords as nodes of an r-ary tree (or via the radix-point partial-sum construction), with the Kraft inequality guaranteeing a free node always remains; fully undergraduate." + }, + { + "project_name": "KrullSeparationLemma", + "name": "krull_separation", + "title": "Krull's separation lemma", + "estimated_pages": 1, + "explanation": "A direct Zorn's lemma argument producing an ideal maximal among those disjoint from the multiplicative set and showing it is prime, entirely within undergraduate commutative algebra." + }, + { + "project_name": "LagrangeTheorem", + "name": "lagrange", + "title": "Lagrange's theorem (number theory)", + "estimated_pages": 1, + "explanation": "Elementary induction on the degree using polynomial division by (x-k) over the field Z/pZ, fully undergraduate number theory." + }, + { + "project_name": "McMillan", + "name": "mcmillan", + "title": "McMillan", + "estimated_pages": 1, + "explanation": "Karush's counting argument: raise the Kraft sum to the m-th power, bound the count of length-l strings using unique decodability, then take m-th roots and let m->infinity, fully elementary combinatorics." + }, + { + "project_name": "OreTheorem", + "name": "ore_maximal_hamiltonian_cycle_free_graph", + "title": "Ore's theorem", + "estimated_pages": 1, + "explanation": "Purely elementary extremal graph argument on an edge-maximal non-Hamiltonian graph (the standard degree-sum lemma at the heart of Ore's theorem), fully undergraduate combinatorics." + }, + { + "project_name": "OreTheorem", + "name": "ore_theorem", + "title": "Ore's theorem", + "estimated_pages": 1, + "explanation": "Classic short extremal/contradiction proof (maximal non-Hamiltonian graph, longest-path rotation, pigeonhole on the degree condition); entirely undergraduate-level graph theory." + }, + { + "project_name": "RiemannSeries", + "name": "riemann_summation_atbot", + "title": "Riemann series theorem", + "estimated_pages": 1, + "explanation": "Elementary undergraduate real-analysis greedy-rearrangement construction (alternately accumulate positive/negative terms), here specialized to the easier divergence-to-negative-infinity case rather than the full rearrangement-to-any-value statement." + }, + { + "project_name": "RisingSunLemma", + "name": "risingsun", + "title": "Rising Sun Lemma", + "estimated_pages": 1, + "explanation": "Purely undergraduate real-analysis argument: openness of the shadow set plus a proof-by-contradiction about maxima of a continuous function, then decomposing an open subset of R into countably many disjoint intervals." + }, + { + "project_name": "RoucheCapelli", + "name": "rouche_capelli", + "title": "Rouché--Capelli", + "estimated_pages": 1, + "explanation": "Standard undergraduate linear algebra: row-reduce the augmented matrix and compare ranks of coefficient and augmented matrices, an inconsistency 0=1 appearing exactly when the ranks differ." + }, + { + "project_name": "Worpitzky", + "name": "worpitzky", + "title": "Worpitzky identity", + "estimated_pages": 1, + "explanation": "A standard combinatorial identity provable by induction/finite differences on the recurrence A(n,k) = (k+1)A(n-1,k) + (n-k)A(n-1,k-1) for Eulerian numbers together with the binomial Pascal/Vandermonde identities; entirely undergraduate combinatorics, and the formalized statement is the full general identity for all n." + } +] diff --git a/scripts/generate_all_files.py b/scripts/generate_all_files.py deleted file mode 100644 index bbd8d53..0000000 --- a/scripts/generate_all_files.py +++ /dev/null @@ -1,239 +0,0 @@ -#!/usr/bin/env python3 -"""Generate ``All.lean`` files for project folders in ``LiveLeanTriathlon/``. - -For each folder that contains ``MainTheorem.lean`` (and optionally -``BackgroundLemmas.lean``), produce an ``All.lean`` file that: - -- Imports the union of the imports from both files, excluding the cross-imports - ``LiveLeanTriathlon..MainTheorem`` and - ``LiveLeanTriathlon..BackgroundLemmas``. -- Has a single ``@[expose] public section``. -- Contains the post-``@[expose] public section`` content of - ``BackgroundLemmas.lean`` wrapped in ``section Background … end Background`` - (when that file is present), followed by the post-``@[expose] public section`` - content of ``MainTheorem.lean`` wrapped in ``section Main … end Main``. - -Run after editing project source: - python3 scripts/generate_all_files.py -""" - -import re -from pathlib import Path - -WORKSPACE = Path(__file__).resolve().parent.parent -LEAN_ROOT = WORKSPACE / "LiveLeanTriathlon" - -EXPOSE_RE = re.compile(r"^\s*@\[expose\]\s+public\s+section\s*$") -MODULE_RE = re.compile(r"^\s*module\s*$") -IMPORT_RE = re.compile( - r"^(?P(?:public\s+)?(?:meta\s+)?)import\s+(?P\S+)\s*$" -) -LICENSE_HEADER_RE = re.compile(r"\A\s*(/-.*?-/)", re.DOTALL) -SCOPE_OPEN_NAMED_RE = re.compile( - r"^\s*(?:noncomputable\s+)?(?:section|namespace)\s+([\w.]+)\s*$" -) -SCOPE_OPEN_ANON_RE = re.compile(r"^\s*(?:noncomputable\s+)?section\s*$") -END_NAMED_RE = re.compile(r"^\s*end\s+([\w.]+)\s*$") -END_ANON_RE = re.compile(r"^\s*end\s*$") - - -def parse_file(path: Path) -> tuple[str, list[tuple[str, str]], str]: - """Return ``(license_header, imports, post_expose_content)``. - - - ``license_header`` is the leading ``/- … -/`` block (without trailing - newlines), or empty if absent. - - ``imports`` is a list of ``(kind, name)`` from the import region (between - ``module`` and ``@[expose] public section``), preserving source order. - ``kind`` is one of ``""``, ``"public "``, ``"meta "``, ``"public meta "``. - - ``post_expose_content`` is everything after the ``@[expose] public - section`` line, with surrounding blank lines stripped. Empty if the - marker is absent. - """ - text = path.read_text(encoding="utf-8") - - m = LICENSE_HEADER_RE.match(text) - license_header = m.group(1) if m else "" - - lines = text.splitlines() - - module_idx = None - for i, line in enumerate(lines): - if MODULE_RE.match(line): - module_idx = i - break - - expose_idx = None - for i, line in enumerate(lines): - if EXPOSE_RE.match(line): - expose_idx = i - break - - import_start = (module_idx + 1) if module_idx is not None else 0 - import_end = expose_idx if expose_idx is not None else len(lines) - - imports: list[tuple[str, str]] = [] - for line in lines[import_start:import_end]: - im = IMPORT_RE.match(line) - if im: - kind = (im.group("kind") or "").strip() - kind = (kind + " ") if kind else "" - imports.append((kind, im.group("name"))) - - if expose_idx is not None: - post = "\n".join(lines[expose_idx + 1 :]).strip("\n") - else: - post = "" - - return license_header, imports, post - - -def _rewrite_to_all(name: str, all_folders: set[str]) -> str: - """Rewrite ``LiveLeanTriathlon..MainTheorem`` and - ``LiveLeanTriathlon..BackgroundLemmas`` to ``LiveLeanTriathlon..All`` when - ```` is a project folder that has its own ``All.lean``.""" - if not name.startswith("LiveLeanTriathlon."): - return name - parts = name.split(".") - if len(parts) < 3: - return name - target = parts[1] - if target not in all_folders: - return name - if parts[-1] not in ("MainTheorem", "BackgroundLemmas"): - return name - return f"LiveLeanTriathlon.{target}.All" - - -def merge_imports( - main_imports: list[tuple[str, str]], - bg_imports: list[tuple[str, str]], - folder: str, - all_folders: set[str], -) -> list[tuple[str, str]]: - """Return the union of imports, deduped, preserving first-seen order, with - the two cross-imports between ``MainTheorem`` and ``BackgroundLemmas`` - inside ``folder`` filtered out, and cross-folder imports of those modules - rewritten to ``All``. - - If the same import appears with both ``public`` and non-``public`` kinds, - the more permissive ``public`` form wins. - """ - cross_self = { - f"LiveLeanTriathlon.{folder}.MainTheorem", - f"LiveLeanTriathlon.{folder}.BackgroundLemmas", - } - seen: dict[str, str] = {} - order: list[str] = [] - for kind, name in [*main_imports, *bg_imports]: - if name in cross_self: - continue - name = _rewrite_to_all(name, all_folders) - if name not in seen: - seen[name] = kind - order.append(name) - elif "public" in kind and "public" not in seen[name]: - seen[name] = kind - return [(seen[n], n) for n in order] - - -def render_imports(imports: list[tuple[str, str]]) -> str: - """Render imports, with a blank line between Mathlib/external imports and - LiveLeanTriathlon imports.""" - external = [imp for imp in imports if not imp[1].startswith("LiveLeanTriathlon.")] - internal = [imp for imp in imports if imp[1].startswith("LiveLeanTriathlon.")] - groups = [] - if external: - groups.append("\n".join(f"{kind}import {name}" for kind, name in external)) - if internal: - groups.append("\n".join(f"{kind}import {name}" for kind, name in internal)) - return "\n\n".join(groups) - - -def close_unbalanced_scopes(content: str) -> str: - """Close any ``section``/``namespace`` scopes that ``content`` leaves open - at end-of-file. Lean auto-closes them at EOF, but when ``content`` is - nested inside ``section Background``/``section Main``, the outer ``end`` - fires while these scopes are still open, breaking the parse.""" - stack: list[str | None] = [] - for line in content.splitlines(): - m = SCOPE_OPEN_NAMED_RE.match(line) - if m: - stack.append(m.group(1)) - continue - if SCOPE_OPEN_ANON_RE.match(line): - stack.append(None) - continue - m = END_NAMED_RE.match(line) - if m and stack and stack[-1] == m.group(1): - stack.pop() - continue - if END_ANON_RE.match(line) and stack and stack[-1] is None: - stack.pop() - continue - if not stack: - return content - closes = [] - while stack: - scope = stack.pop() - closes.append("end" if scope is None else f"end {scope}") - return content.rstrip("\n") + "\n\n" + "\n".join(closes) - - -def render_section(name: str, body: str) -> str: - body = close_unbalanced_scopes(body.strip("\n")) - if not body: - return f"section {name}\n\nend {name}" - return f"section {name}\n\n{body}\n\nend {name}" - - -def make_all(folder_path: Path, all_folders: set[str]) -> str | None: - main_path = folder_path / "MainTheorem.lean" - bg_path = folder_path / "BackgroundLemmas.lean" - if not main_path.is_file(): - return None - - main_license, main_imports, main_post = parse_file(main_path) - if bg_path.is_file(): - _, bg_imports, bg_post = parse_file(bg_path) - has_bg = True - else: - bg_imports, bg_post, has_bg = [], "", False - - imports = merge_imports(main_imports, bg_imports, folder_path.name, all_folders) - - parts: list[str] = [] - if main_license: - parts.append(main_license) - parts.append("module") - if imports: - parts.append(render_imports(imports)) - parts.append("@[expose] public section") - if has_bg: - parts.append(render_section("Background", bg_post)) - parts.append(render_section("Main", main_post)) - return "\n\n".join(parts) + "\n" - - -def main() -> None: - folders = [f for f in sorted(LEAN_ROOT.iterdir()) if f.is_dir()] - all_folders = {f.name for f in folders if (f / "MainTheorem.lean").is_file()} - written = 0 - skipped: list[str] = [] - for folder in folders: - out = make_all(folder, all_folders) - if out is None: - skipped.append(folder.name) - continue - target = folder / "All.lean" - target.write_text(out, encoding="utf-8") - written += 1 - print(f"Wrote {written} All.lean files.") - if skipped: - print( - f"Skipped {len(skipped)} folders without MainTheorem.lean: " - + ", ".join(skipped) - ) - - -if __name__ == "__main__": - main() diff --git a/scripts/generate_theorem_stats.py b/scripts/generate_theorem_stats.py deleted file mode 100644 index ab29e0d..0000000 --- a/scripts/generate_theorem_stats.py +++ /dev/null @@ -1,346 +0,0 @@ -#!/usr/bin/env python3 -"""Generate scripts/theorem_stats.json from the current Lean and blueprint sources. - -Produces statistics including: - - AMS subject classification per theorem - - Whether each theorem's proof contains sorry - - Whether the theorem's blueprint .tex file has substantive informal - content (longer than 500 characters) - - Whether the theorem's directory contains a BackgroundLemmas.lean file - - Summary counts - -Run this after adding or modifying theorems: - python3 scripts/generate_theorem_stats.py -""" - -import re -import json -from pathlib import Path -from collections import defaultdict - -AMS_DESCRIPTIONS: dict[int, str] = { - 0: "General and overarching topics", - 1: "History and biography", - 3: "Mathematical logic and foundations", - 5: "Combinatorics", - 6: "Order, lattices, ordered algebraic structures", - 8: "General algebraic systems", - 11: "Number theory", - 12: "Field theory and polynomials", - 13: "Commutative algebra", - 14: "Algebraic geometry", - 15: "Linear and multilinear algebra; matrix theory", - 16: "Associative rings and algebras", - 17: "Nonassociative rings and algebras", - 18: "Category theory; homological algebra", - 19: "K-theory", - 20: "Group theory and generalizations", - 22: "Topological groups, Lie groups", - 26: "Real functions", - 28: "Measure and integration", - 30: "Functions of a complex variable", - 31: "Potential theory", - 32: "Several complex variables and analytic spaces", - 33: "Special functions", - 34: "Ordinary differential equations", - 35: "Partial differential equations", - 37: "Dynamical systems and ergodic theory", - 39: "Difference and functional equations", - 40: "Sequences, series, summability", - 41: "Approximations and expansions", - 42: "Harmonic analysis on Euclidean spaces", - 43: "Abstract harmonic analysis", - 44: "Integral transforms, operational calculus", - 45: "Integral equations", - 46: "Functional analysis", - 47: "Operator theory", - 49: "Calculus of variations and optimal control; optimization", - 51: "Geometry", - 52: "Convex and discrete geometry", - 53: "Differential geometry", - 54: "General topology", - 55: "Algebraic topology", - 57: "Manifolds and cell complexes", - 58: "Global analysis, analysis on manifolds", - 60: "Probability theory and stochastic processes", - 62: "Statistics", - 65: "Numerical analysis", - 68: "Computer science", - 70: "Mechanics of particles and systems", - 74: "Mechanics of deformable solids", - 76: "Fluid mechanics", - 78: "Optics, electromagnetic theory", - 80: "Classical thermodynamics, heat transfer", - 81: "Quantum theory", - 82: "Statistical mechanics, structure of matter", - 83: "Relativity and gravitational theory", - 85: "Astronomy and astrophysics", - 86: "Geophysics", - 90: "Operations research, mathematical programming", - 91: "Game theory, economics, social and behavioral sciences", - 92: "Biology and other natural sciences", - 93: "Systems theory; control", - 94: "Information and communication, circuits", - 97: "Mathematics education", -} - -# Regex to match `sorry` as a standalone tactic/term (not in comments or strings) -SORRY_RE = re.compile(r"\bsorry\b") -# Regex to match single-line comments -LINE_COMMENT_RE = re.compile(r"--.*$", re.MULTILINE) -# Regex to match block comments (non-nested, simple) -BLOCK_COMMENT_RE = re.compile(r"/-.*?-/", re.DOTALL) - - -def strip_comments(text: str) -> str: - """Remove Lean comments from source text.""" - text = BLOCK_COMMENT_RE.sub("", text) - text = LINE_COMMENT_RE.sub("", text) - return text - - -# Path components whose entire subtree is excluded from every scan in this -# script. ``Sorry`` is generated; ``Mistakes`` is a deliberate "this is what -# breakage looks like" demo and its declarations must not pollute lookups. -EXCLUDED_PATH_PARTS = ("/Sorry/", "/Mistakes/") - - -def _is_excluded(lean_file: Path) -> bool: - s = str(lean_file) - return any(part in s for part in EXCLUDED_PATH_PARTS) - - -def scan_lean_ams(lean_dir: Path) -> dict[str, list[int]]: - """Return mapping from declaration name to sorted list of AMS codes.""" - lean_ams: dict[str, list[int]] = {} - decl_keywords = ( - r"(?:theorem|lemma|def|noncomputable\s+def|abbrev|structure|class|instance)" - ) - pattern = re.compile( - r"@\[[^\]]*\bAMS\b([^\]]*)\]" - r"(?:\s*@\[[^\]]*\][^\S\n]*)*" - r"\s+" - r"(?:" + decl_keywords + r")\s+" - r"([\w.]+)", - re.MULTILINE, - ) - for lean_file in lean_dir.rglob("*.lean"): - if _is_excluded(lean_file): - continue - try: - content = lean_file.read_text(encoding="utf-8") - except Exception: - continue - for m in pattern.finditer(content): - nums = sorted(set(int(x) for x in m.group(1).split() if x.isdigit())) - decl = m.group(2) - lean_ams[decl] = nums - lean_ams[decl.split(".")[-1]] = nums - return lean_ams - - -NAMESPACE_OPEN_RE = re.compile(r"^\s*namespace\s+([\w.]+)\s*$") -NAMESPACE_END_RE = re.compile(r"^\s*end\s+([\w.]+)\s*$") -DECL_RE = re.compile( - r"^\s*" - r"(?:private\s+|protected\s+|noncomputable\s+|partial\s+|unsafe\s+|@\[expose\]\s+)*" - r"(?:theorem|lemma|def|abbrev|structure|class|instance)" - r"\s+([\w.]+)" -) - - -def scan_lean_decl_files(lean_dir: Path) -> dict[str, Path]: - """Return mapping from fully-qualified declaration name to the .lean file - that defines it. - - Tracks ``namespace … end`` blocks line-by-line so that - ``namespace PartialOrder ; theorem dilworth …`` is recorded under - ``PartialOrder.dilworth``, not just ``dilworth``. Bare-name aliases use - ``setdefault`` so they don't get clobbered by later same-bare-name - declarations. - """ - decl_to_file: dict[str, Path] = {} - for lean_file in lean_dir.rglob("*.lean"): - if _is_excluded(lean_file): - continue - try: - content = lean_file.read_text(encoding="utf-8") - except Exception: - continue - ns_stack: list[str] = [] - for line in content.splitlines(): - m_open = NAMESPACE_OPEN_RE.match(line) - if m_open: - ns_stack.append(m_open.group(1)) - continue - m_close = NAMESPACE_END_RE.match(line) - if m_close and ns_stack and ns_stack[-1] == m_close.group(1): - ns_stack.pop() - continue - m_decl = DECL_RE.match(line) - if m_decl: - bare = m_decl.group(1) - full = ".".join([*ns_stack, bare]) if ns_stack else bare - decl_to_file[full] = lean_file - decl_to_file.setdefault(bare, lean_file) - return decl_to_file - - -def directory_has_sorry(directory: Path) -> bool: - """Check if any .lean file in a directory tree contains sorry (outside comments).""" - for lean_file in directory.rglob("*.lean"): - if _is_excluded(lean_file): - continue - try: - content = lean_file.read_text(encoding="utf-8") - except Exception: - continue - cleaned = strip_comments(content) - if SORRY_RE.search(cleaned): - return True - return False - - -def scan_final_lean_names(theorems_dir: Path) -> dict[str, str]: - """Return mapping from tex filename stem to lean name of the final environment.""" - lean_re = re.compile(r"\\lean\{([^}]+)\}") - env_begin = re.compile(r"\\begin\{(theorem|lemma|definition)\}") - result: dict[str, str] = {} - for tex_file in sorted(theorems_dir.glob("*.tex")): - content = tex_file.read_text(encoding="utf-8") - blocks: list[tuple[int, str]] = [] - for begin_m in env_begin.finditer(content): - env_type = begin_m.group(1) - end_pat = re.compile(r"\\end\{" + env_type + r"\}") - end_m = end_pat.search(content, begin_m.end()) - if end_m: - block_content = content[begin_m.start() : end_m.end()] - lean_m = lean_re.search(block_content) - if lean_m: - blocks.append((begin_m.start(), lean_m.group(1).strip())) - if blocks: - result[tex_file.stem] = blocks[-1][1] - return result - - -INFORMAL_CHAR_THRESHOLD = 500 - - -def build_stats(workspace: Path) -> dict: - lean_dir = workspace / "LiveLeanTriathlon" - theorems_dir = workspace / "blueprint/src/theorems" - lean_ams = scan_lean_ams(lean_dir) - decl_to_file = scan_lean_decl_files(lean_dir) - final_names = scan_final_lean_names(theorems_dir) - - theorems: dict[str, dict] = {} - for stem, lean_name in sorted(final_names.items()): - short = lean_name.split(".")[-1] - codes = lean_ams.get(lean_name) or lean_ams.get(short) or [] - - # Determine sorry status and BackgroundLemmas.lean presence by checking - # the theorem's directory. - has_sorry = False - has_background_lemmas = False - decl_file = decl_to_file.get(lean_name) or decl_to_file.get(short) - if decl_file is not None: - theorem_dir = decl_file.parent - has_sorry = directory_has_sorry(theorem_dir) - has_background_lemmas = (theorem_dir / "BackgroundLemmas.lean").is_file() - - # has_informal: tex file for the theorem is longer than 500 chars. - tex_file = theorems_dir / f"{stem}.tex" - has_informal = False - if tex_file.is_file(): - has_informal = ( - len(tex_file.read_text(encoding="utf-8")) > INFORMAL_CHAR_THRESHOLD - ) - - theorems[lean_name] = { - "ams_codes": codes, - "has_sorry": has_sorry, - "has_informal": has_informal, - "has_background_lemmas": has_background_lemmas, - } - - # AMS summary: total / with_sorry / without_sorry per code - ams_summary: dict[int, dict[str, int]] = defaultdict( - lambda: {"count": 0, "with_sorry": 0, "without_sorry": 0} - ) - for info in theorems.values(): - for c in info["ams_codes"]: - ams_summary[c]["count"] += 1 - if info["has_sorry"]: - ams_summary[c]["with_sorry"] += 1 - else: - ams_summary[c]["without_sorry"] += 1 - - # Sorry summary - total = len(theorems) - with_sorry = sum(1 for info in theorems.values() if info["has_sorry"]) - without_sorry = total - with_sorry - - return { - "description": ( - "Statistics for LiveLeanTriathlon theorem declarations. " - "Each entry in 'theorems' maps a Lean declaration name to its AMS " - "subject code(s), whether its proof contains sorry, whether the " - "theorem's blueprint .tex file has substantive informal content " - "(longer than 500 characters), and whether the theorem's directory has a " - "BackgroundLemmas.lean file. " - "Regenerate with: python3 scripts/generate_theorem_stats.py" - ), - "sorry_summary": { - "total": total, - "with_sorry": with_sorry, - "without_sorry": without_sorry, - }, - "ams_summary": { - str(k): { - "description": AMS_DESCRIPTIONS.get(k, ""), - "count": v["count"], - "with_sorry": v["with_sorry"], - "without_sorry": v["without_sorry"], - } - for k, v in sorted( - ams_summary.items(), key=lambda item: (-item[1]["count"], item[0]) - ) - }, - "theorems": theorems, - } - - -def main() -> None: - workspace = Path(__file__).parent.parent - stats = build_stats(workspace) - out = workspace / "scripts" / "theorem_stats.json" - out.write_text(json.dumps(stats, indent=2) + "\n", encoding="utf-8") - print(f"Wrote {out}") - - total = len(stats["theorems"]) - tagged = sum(1 for v in stats["theorems"].values() if v["ams_codes"]) - print(f"\n--- AMS Classification ---") - print(f" {tagged}/{total} theorems have AMS tags") - for code, info in stats["ams_summary"].items(): - print( - f" AMS {code:>3} ({info['description']}): " - f"{info['count']} total, {info['without_sorry']} proved, {info['with_sorry']} sorry" - ) - - sorry = stats["sorry_summary"] - print(f"\n--- Sorry Status ---") - print(f" {sorry['without_sorry']}/{sorry['total']} theorems proven (no sorry)") - print(f" {sorry['with_sorry']}/{sorry['total']} theorems still have sorry") - - # List theorems with sorry - sorry_theorems = [ - name for name, info in stats["theorems"].items() if info["has_sorry"] - ] - if sorry_theorems: - print(f"\n Theorems with sorry:") - for name in sorry_theorems: - print(f" - {name}") - - -if __name__ == "__main__": - main() diff --git a/scripts/regenerate_content.py b/scripts/regenerate_content.py deleted file mode 100644 index 9f92fd0..0000000 --- a/scripts/regenerate_content.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -"""Regenerate blueprint/src/content.tex from all .tex files in blueprint/src/theorems/.""" - -import os -from pathlib import Path - -REPO_ROOT = Path(__file__).parent.parent -THEOREMS_DIR = REPO_ROOT / "blueprint" / "src" / "theorems" -CONTENT_TEX = REPO_ROOT / "blueprint" / "src" / "content.tex" - -HEADER = """\ -% In this file you should put the actual content of the blueprint. -% It will be used both by the web and the print version. -% It should *not* include the \\begin{document} -% -% If you want to split the blueprint content into several files then -% the current file can be a simple sequence of \\input. Otherwise It -% can start with a \\section or \\chapter for instance. - -""" - -def main(): - tex_files = sorted(THEOREMS_DIR.glob("*.tex")) - lines = [] - for f in tex_files: - stem = f.stem - lines.append(f"\\input{{theorems/{stem}}}\n") - - content = HEADER + "".join(lines) - CONTENT_TEX.write_text(content) - print(f"Wrote {len(lines)} entries to {CONTENT_TEX}") - -if __name__ == "__main__": - main() diff --git a/scripts/theorem_stats.json b/scripts/theorem_stats.json deleted file mode 100644 index 8c114bf..0000000 --- a/scripts/theorem_stats.json +++ /dev/null @@ -1,1038 +0,0 @@ -{ - "description": "Statistics for LiveLeanTriathlon theorem declarations. Each entry in 'theorems' maps a Lean declaration name to its AMS subject code(s), whether its proof contains sorry, whether the theorem's blueprint .tex file has substantive informal content (longer than 500 characters), and whether the theorem's directory has a BackgroundLemmas.lean file. Regenerate with: python3 scripts/generate_theorem_stats.py", - "sorry_summary": { - "total": 111, - "with_sorry": 69, - "without_sorry": 42 - }, - "ams_summary": { - "11": { - "description": "Number theory", - "count": 37, - "with_sorry": 30, - "without_sorry": 7 - }, - "5": { - "description": "Combinatorics", - "count": 15, - "with_sorry": 10, - "without_sorry": 5 - }, - "13": { - "description": "Commutative algebra", - "count": 7, - "with_sorry": 1, - "without_sorry": 6 - }, - "26": { - "description": "Real functions", - "count": 6, - "with_sorry": 2, - "without_sorry": 4 - }, - "30": { - "description": "Functions of a complex variable", - "count": 6, - "with_sorry": 5, - "without_sorry": 1 - }, - "60": { - "description": "Probability theory and stochastic processes", - "count": 5, - "with_sorry": 2, - "without_sorry": 3 - }, - "20": { - "description": "Group theory and generalizations", - "count": 4, - "with_sorry": 3, - "without_sorry": 1 - }, - "15": { - "description": "Linear and multilinear algebra; matrix theory", - "count": 3, - "with_sorry": 0, - "without_sorry": 3 - }, - "28": { - "description": "Measure and integration", - "count": 3, - "with_sorry": 1, - "without_sorry": 2 - }, - "40": { - "description": "Sequences, series, summability", - "count": 3, - "with_sorry": 2, - "without_sorry": 1 - }, - "54": { - "description": "General topology", - "count": 3, - "with_sorry": 2, - "without_sorry": 1 - }, - "3": { - "description": "Mathematical logic and foundations", - "count": 2, - "with_sorry": 2, - "without_sorry": 0 - }, - "12": { - "description": "Field theory and polynomials", - "count": 2, - "with_sorry": 2, - "without_sorry": 0 - }, - "17": { - "description": "Nonassociative rings and algebras", - "count": 2, - "with_sorry": 1, - "without_sorry": 1 - }, - "46": { - "description": "Functional analysis", - "count": 2, - "with_sorry": 1, - "without_sorry": 1 - }, - "51": { - "description": "Geometry", - "count": 2, - "with_sorry": 1, - "without_sorry": 1 - }, - "52": { - "description": "Convex and discrete geometry", - "count": 2, - "with_sorry": 2, - "without_sorry": 0 - }, - "68": { - "description": "Computer science", - "count": 2, - "with_sorry": 0, - "without_sorry": 2 - }, - "14": { - "description": "Algebraic geometry", - "count": 1, - "with_sorry": 1, - "without_sorry": 0 - }, - "16": { - "description": "Associative rings and algebras", - "count": 1, - "with_sorry": 0, - "without_sorry": 1 - }, - "18": { - "description": "Category theory; homological algebra", - "count": 1, - "with_sorry": 0, - "without_sorry": 1 - }, - "47": { - "description": "Operator theory", - "count": 1, - "with_sorry": 0, - "without_sorry": 1 - }, - "49": { - "description": "Calculus of variations and optimal control; optimization", - "count": 1, - "with_sorry": 1, - "without_sorry": 0 - } - }, - "theorems": { - "anderson": { - "ams_codes": [ - 26 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "apery": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": true - }, - "aztecDiamond_tiling": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "banach_mazur": { - "ams_codes": [ - 46 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "bauer_fike": { - "ams_codes": [ - 47 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "beckmann_quarles": { - "ams_codes": [ - 51 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "SimpleGraph.Subgraph.IsMatching.berge": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "bondy": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "borsuk_ulam": { - "ams_codes": [ - 54 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "BrascampLieb.upperBound": { - "ams_codes": [ - 26 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "brooks_theorem": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "brun": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "brunTitchmarsh": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "EuclideanSpace.volume_pow_mul_le": { - "ams_codes": [ - 28 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": true - }, - "cameron_erdos": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "caristi": { - "ams_codes": [ - 54 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "carlson": { - "ams_codes": [ - 30 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "carmichael": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "cartan_brauer_hua": { - "ams_codes": [ - 13 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "casorati_weierstrass": { - "ams_codes": [ - 30 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "chen": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "Ring.DirectLimit.instValuationRing": { - "ams_codes": [ - 13 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "condorcet_jury_theorem": { - "ams_codes": [ - 60 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "ae_tendsto_comp_of_ae_tendsto_of_forall_continuousAt": { - "ams_codes": [ - 60 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "ProbabilityMeasure.tendsto_map_of_forall_continuousAt": { - "ams_codes": [ - 60 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "critical_line": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "SimpleGraph.colorable_of_finitely_colorable": { - "ams_codes": [ - 5 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "nat_definable_in_rat": { - "ams_codes": [ - 3 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "exists_Ioo_subset_diff_self_of_measure_pos": { - "ams_codes": [ - 28 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "diller_dress": { - "ams_codes": [ - 12 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "PartialOrder.dilworth": { - "ams_codes": [ - 5 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "erdos_dushnik_miller": { - "ams_codes": [ - 3 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "ErdosGallaiTheorem": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "erdos_kac": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "farey_riemann_abs": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "feit_thompson": { - "ams_codes": [ - 20 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "fifteen_theorem": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "Ring.krullDimLE_one_of_finite_primeSpectrum": { - "ams_codes": [ - 13 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "fitting": { - "ams_codes": [ - 20 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "frank_wolfe_convergence_rate": { - "ams_codes": [ - 49 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "Freiman": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "friedlander_iwaniec": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "Real.countable_not_continuousAt": { - "ams_codes": [ - 26 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "Complex.mem_convexHull_roots_of_mem_derivative_roots": { - "ams_codes": [ - 30 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": true - }, - "gelfond_scheider": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "Nat.Prime.greenTao": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "grushko": { - "ams_codes": [ - 20 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "tauberian": { - "ams_codes": [ - 26 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "HasseBound": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "Ideal.ufd_iff_height_one_primes_principal": { - "ams_codes": [ - 13 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "hinge_iff_geometric": { - "ams_codes": [ - 51 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "hurwitz_approximation": { - "ams_codes": [ - 11 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "Module.End.inv_eigenvalue_iff": { - "ams_codes": [ - 15 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "jacobi": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "Jacobson_Morozov": { - "ams_codes": [ - 17 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "jones": { - "ams_codes": [ - 54 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "jordan_schur": { - "ams_codes": [ - 20 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "exists_generator_of_minpoly_with_some_zero_coeffs": { - "ams_codes": [ - 12 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "kaplansky_two": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "koebe": { - "ams_codes": [ - 30 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "kolmogorov_three_series_necessity": { - "ams_codes": [ - 40 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": true - }, - "kolmogorov_three_series_sufficiency": { - "ams_codes": [ - 40 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "koukoulopoulos_maynard": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "Kraft.kraft": { - "ams_codes": [ - 68 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "KroneckerWeber": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "krull_separation": { - "ams_codes": [ - 13 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "lagrange": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "LeCamTheorem": { - "ams_codes": [ - 60 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "Nat.LCM_lower_bound": { - "ams_codes": [ - 11 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "levitzky_theorem": { - "ams_codes": [ - 17 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "linnik": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "lukacs_proportion_sum_independence_iff": { - "ams_codes": [ - 60 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "lusin": { - "ams_codes": [ - 26 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "mcmillan": { - "ams_codes": [ - 68 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "mergelyan": { - "ams_codes": [ - 30 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "merten_first": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "IsMittagLeffler.mapShortExact": { - "ams_codes": [ - 18 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "SimpleGraph.mycielski": { - "ams_codes": [ - 5 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "NagellLutz2": { - "ams_codes": [ - 14 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "weird_squarefree_infinite": { - "ams_codes": [ - 11 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "ore_theorem": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "CommRing.Pic.instSubsingletonOfUFD": { - "ams_codes": [ - 13 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "picard": { - "ams_codes": [ - 30 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "polygonal_number_theorem_even": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": true - }, - "prekopa_leindler_dim1": { - "ams_codes": [ - 28 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "proth": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "smallest_period_div": { - "ams_codes": [ - 11 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "ramanujan_nagell": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "riemann_summation_atbot": { - "ams_codes": [ - 40 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "risingsun": { - "ams_codes": [ - 26 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "robin": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "roth": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "rouche_capelli": { - "ams_codes": [ - 15 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "Schanuel": { - "ams_codes": [ - 16 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "SchauderFixedPointTheorem": { - "ams_codes": [ - 46 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "schur": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "sinkhorn_existence": { - "ams_codes": [ - 15 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "starofdavid": { - "ams_codes": [ - 5 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "szemeredi": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "szemeredi_trotter": { - "ams_codes": [ - 52 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "totient_lower_bound": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "tverberg": { - "ams_codes": [ - 52 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "two_factor_theorem": { - "ams_codes": [ - 5 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "two_ninety_theorem": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": true, - "has_background_lemmas": false - }, - "ValuationRing.inter_subfield": { - "ams_codes": [ - 13 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "vantieghem": { - "ams_codes": [ - 11 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "von_staudt_clausen": { - "ams_codes": [ - 11 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": true - }, - "waring": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - }, - "wolstenholme": { - "ams_codes": [ - 11 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "worpitzky": { - "ams_codes": [ - 5 - ], - "has_sorry": false, - "has_informal": true, - "has_background_lemmas": false - }, - "zsigmondy_theorem": { - "ams_codes": [ - 11 - ], - "has_sorry": true, - "has_informal": false, - "has_background_lemmas": false - } - } -}