fact
stringlengths
19
8.26k
type
stringclasses
8 values
library
stringclasses
2 values
imports
listlengths
0
7
filename
stringclasses
397 values
symbolic_name
stringlengths
1
73
docstring
stringlengths
20
499
addModulesIn (recurse : Bool) (prev : Array Name) (root : Name := .anonymous) (path : FilePath) : IO (Array Name) := do let mut r := prev for entry in ← path.readDir do if ← entry.path.isDir then if recurse then r ← addModulesIn recurse r (root.mkStr entry.fileName) entry.path else let .some mod := FilePath.fileStem entry.fileName | continue r := r.push (root.mkStr mod) pure r /-- Compute imports expected by `PhysLean.lean` by looking at file structure. -/
def
scripts
[ "import Batteries.Lean.HashSet", "import Lean" ]
scripts/check_file_imports.lean
addModulesIn
/-- Recursively finds files in directory. -/
expectedPhysLeanImports : IO (Array Name) := do let mut needed := #[] for top in ← FilePath.readDir "PhysLean" do let nm := `PhysLean let rootname := FilePath.withExtension top.fileName "" let root := nm.mkStr rootname.toString if ← top.path.isDir then needed ← addModulesIn (recurse := true) needed (root := root) top.path else needed := needed.push root pure needed
def
scripts
[ "import Batteries.Lean.HashSet", "import Lean" ]
scripts/check_file_imports.lean
expectedPhysLeanImports
/-- Compute imports expected by `PhysLean.lean` by looking at file structure. -/
listDif : (a: List String) → (b : List String) → (List String × List String) | [], [] => ([], []) | a :: as, [] => (a :: as, []) | [], b :: bs => ([], b :: bs) | a :: as, b :: bs => if a = b then listDif as bs else (a :: (listDif as bs).1, b :: (listDif as bs).2) /-- Checks whether an array `imports` is sorted after `Init` is removed. -/
def
scripts
[ "import Batteries.Lean.HashSet", "import Lean" ]
scripts/check_file_imports.lean
listDif
null
arrayImportSorted (imports : Array Import) : IO Bool := do let X := (imports.map (fun x => x.module.toString)).filter (fun x => x != "Init") let mut warned := false if ! X = X.qsort (· < ·) then IO.print s!"Import file is not sorted. \n" let ldif := listDif X.toList (X.qsort (· < ·)).toList let lzip := List.zip ldif.1 ldif.2 let lstring := String.intercalate "\n" (lzip.map (fun x => s!"{x.1} > {x.2}")) println! lstring warned := true pure warned /-- Checks every file in `reqImports` is imported into `modData` return true if this is NOT the case. -/
def
scripts
[ "import Batteries.Lean.HashSet", "import Lean" ]
scripts/check_file_imports.lean
arrayImportSorted
/-- Checks whether an array `imports` is sorted after `Init` is removed. -/
checkMissingImports (modData : ModuleData) (reqImports : Array Name) : IO Bool := do let names : Std.HashSet Name := Std.HashSet.ofArray (modData.imports.map (·.module)) let mut warned := false let nameArray := reqImports.filterMap ( fun req => if !names.contains req then some req else none) if nameArray.size ≠ 0 then let nameArraySort := nameArray.qsort (·.toString < ·.toString) IO.print s!"Files are not imported add the following to the `PhysLean` file: \n" for name in nameArraySort do IO.print s!"import {name}\n" warned := true pure warned
def
scripts
[ "import Batteries.Lean.HashSet", "import Lean" ]
scripts/check_file_imports.lean
checkMissingImports
/-- Checks every file in `reqImports` is imported into `modData` return true if this is NOT the case. -/
main (_ : List String) : IO UInt32 := do initSearchPath (← findSysroot) let mods : Name := `PhysLean let imp : Import := {module := mods} let mFile ← findOLean imp.module unless (← mFile.pathExists) do throw <| IO.userError s!"object file '{mFile}' of module {imp.module} does not exist" let (hepLeanMod, _) ← readModuleData mFile let ePhysLeanImports ← expectedPhysLeanImports let sortedWarned ← arrayImportSorted hepLeanMod.imports let warned ← checkMissingImports hepLeanMod ePhysLeanImports if (warned ∨ sortedWarned) then throw <| IO.userError s!"\x1b[31mThe PhysLean.lean file is not sorted, or has missing imports.\x1b[0m" else IO.println s!"\x1b[32mAll files are imported correctly into PhysLean.lean.\x1b[0m" pure 0
def
scripts
[ "import Batteries.Lean.HashSet", "import Lean" ]
scripts/check_file_imports.lean
main
null
PhysLeanTODOItem : Type := Array String → Array (String × ℕ) /-- Checks if a . -/
def
scripts
[ "import Lean", "import Batteries.Data.String.Matcher", "import Mathlib.Data.Nat.Notation" ]
scripts/find_TODOs.lean
PhysLeanTODOItem
/-- Given a list of lines, outputs an error message and a line number. -/
TODOFinder : PhysLeanTODOItem := fun lines ↦ Id.run do let enumLines := (lines.toList.enumFrom 1) let todos := enumLines.filterMap (fun (lno1, l1) ↦ if l1.startsWith "/-! TODO:" then some ((l1.replace "/-! TODO: " "").replace "-/" "", lno1) else none) todos.toArray
def
scripts
[ "import Lean", "import Batteries.Data.String.Matcher", "import Mathlib.Data.Nat.Notation" ]
scripts/find_TODOs.lean
TODOFinder
/-- Checks if a . -/
TODOContext where /-- The underlying `message`. -/ statement : String /-- The line number -/ lineNumber : ℕ /-- The file path -/ path : FilePath
structure
scripts
[ "import Lean", "import Batteries.Data.String.Matcher", "import Mathlib.Data.Nat.Notation" ]
scripts/find_TODOs.lean
TODOContext
/-- Checks if a . -/
printTODO (todos : Array TODOContext) : IO Unit := do for e in todos do IO.println (s!"{e.path}:{e.lineNumber}: {e.statement}")
def
scripts
[ "import Lean", "import Batteries.Data.String.Matcher", "import Mathlib.Data.Nat.Notation" ]
scripts/find_TODOs.lean
printTODO
/-- The file path -/
filePathToGitPath (S : FilePath) (n : ℕ) : String := "https://github.com/HEPLean/PhysLean/blob/master/"++ (S.toString.replace "." "/").replace "/lean" ".lean" ++ "#L" ++ toString n
def
scripts
[ "import Lean", "import Batteries.Data.String.Matcher", "import Mathlib.Data.Nat.Notation" ]
scripts/find_TODOs.lean
filePathToGitPath
/-- The file path -/
docTODO (todos : Array TODOContext) : IO String := do let mut out := "" for e in todos do out := out ++ (s!" - [{e.statement}]("++ filePathToGitPath e.path e.lineNumber ++ ")\n") return out
def
scripts
[ "import Lean", "import Batteries.Data.String.Matcher", "import Mathlib.Data.Nat.Notation" ]
scripts/find_TODOs.lean
docTODO
/-- The file path -/
hepLeanLintFile (path : FilePath) : IO String := do let lines ← IO.FS.lines path let allOutput := (Array.map (fun lint ↦ (Array.map (fun (e, n) ↦ TODOContext.mk e n path)) (lint lines))) #[TODOFinder] let errors := allOutput.flatten printTODO errors docTODO errors
def
scripts
[ "import Lean", "import Batteries.Data.String.Matcher", "import Mathlib.Data.Nat.Notation" ]
scripts/find_TODOs.lean
hepLeanLintFile
null
todoFileHeader : String := s!" # TODO List This is an automatically generated list of TODOs appearing as `/-! TODO:...` in PhysLean. Please feel free to contribute to the completion of these tasks. "
def
scripts
[ "import Lean", "import Batteries.Data.String.Matcher", "import Mathlib.Data.Nat.Notation" ]
scripts/find_TODOs.lean
todoFileHeader
null
main (args : List String) : IO UInt32 := do initSearchPath (← findSysroot) let mods : Name := `PhysLean let imp : Import := {module := mods} let mFile ← findOLean imp.module unless (← mFile.pathExists) do throw <| IO.userError s!"object file '{mFile}' of module {imp.module} does not exist" let (hepLeanMod, _) ← readModuleData mFile let mut out : String := "" for imp in hepLeanMod.imports do if imp.module == `Init then continue let filePath := (mkFilePath (imp.module.toString.split (· == '.'))).addExtension "lean" let l ← hepLeanLintFile filePath if l != "" then out := out ++ "\n### " ++ imp.module.toString ++ "\n" out := out ++ l let fileOut : System.FilePath := {toString := "./docs/TODOList.md"} /- Below here is concerned with writing out to the docs. -/ if "mkFile" ∈ args then IO.println (s!"TODOList file made.") IO.FS.writeFile fileOut (todoFileHeader ++ out) return 0
def
scripts
[ "import Lean", "import Batteries.Data.String.Matcher", "import Mathlib.Data.Nat.Notation" ]
scripts/find_TODOs.lean
main
null
main (args : List String) : IO UInt32 := do println! "\x1b[36m(1/7) Style lint \x1b[0m" println! "\x1b[2mThis linter is not checked by GitHub but if you have time please fix these errors.\x1b[0m" let styleLint ← IO.Process.output {cmd := "lake", args := #["exe", "style_lint"]} println! styleLint.stdout println! "\x1b[36m(2/7) Building \x1b[0m" let build ← IO.Process.output {cmd := "lake", args := #["build"]} let s1 := "Build completed successfully" let s2 := build.stdout if ¬ (s2.splitOn s1).length = 2 then println! "\x1b[31mError: Build failed. Run `lake build` to see the errors.\x1b[0m\n" else println! "\x1b[32mBuild is successful.\x1b[0m\n" println! "\x1b[36m(3/7) File imports \x1b[0m" let importCheck ← IO.Process.output {cmd := "lake", args := #["exe", "check_file_imports"]} println! importCheck.stdout println! "\x1b[36m(4/7) TODO tag duplicates \x1b[0m" let todoCheck ← IO.Process.output {cmd := "lake", args := #["exe", "check_dup_tags"]} println! todoCheck.stdout println! "\x1b[36m(5/7) Sorry and pseudo attribute linter \x1b[0m" let sorryPseudoCheck ← IO.Process.output {cmd := "lake", args := #["exe", "sorry_lint"]} println! sorryPseudoCheck.stdout if ¬ "--fast" ∈ args then println! "\x1b[36m(6/7) Lean linter \x1b[0m" println! "\x1b[2mExpect this linter to take a while to run, it can be skipped with lake exe lint_all --fast" println! "You can manually perform this linter by placing `#lint` at the end of the files you have modified.\x1b[0m" let leanCheck ← IO.Process.output {cmd := "lake", args := #["exe", "runPhysLeanLinters", "PhysLean"]} println! leanCheck.stdout println! "\x1b[36m(7/7) Transitive imports \x1b[0m" println! "\x1b[2mExpect this linter to take a while to run, it can be skipped with lake exe lint_all --fast\x1b[0m" let redundentImports ← IO.Process.output {cmd := "lake", args := #["exe", "redundant_imports"]} println! redundentImports.stdout pure 0
def
scripts
[]
scripts/lint_all.lean
main
null
lintStyleCli (args : Cli.Parsed) : IO UInt32 := do let mode : OutputSetting := match (args.hasFlag "update", args.hasFlag "github") with | (true, _) => OutputSetting.update | (false, true) => OutputSetting.print ErrorFormat.github | (false, false) => OutputSetting.print ErrorFormat.humanReadable let mut allModules := #[] for s in ["PhysLean.lean"] do allModules := allModules.append ((← IO.FS.lines s).filter (!·.containsSubstr "Batteries") |>.map (·.stripPrefix "import ")) let numberErrorFiles ← lintModules allModules mode return min numberErrorFiles 125 /-- Setting up command line options and help text for `lake exe lint_style`. -/ -- so far, no help options or so: perhaps that is fine?
def
scripts
[ "import Mathlib.Tactic.Linter.TextBased", "import Cli.Basic" ]
scripts/mathlib_textLint_on_hepLean.lean
lintStyleCli
/-- Implementation of the `lint_style` command line program. -/
heplean_lint_style : Cmd := `[Cli| lint_style VIA lintStyleCli; ["0.0.1"] "Run text-based style linters on every Lean file in PhysLean (adapted from mathlib's lint_style). Print errors about any unexpected style errors to standard output." FLAGS: github; "Print errors in a format suitable for github problem matchers\n\ otherwise, produce human-readable output" update; "Print errors solely for the style exceptions file" ] /-- The entry point to the `lake exe mathlib_textLint_on_hepLean` command. -/
def
scripts
[ "import Mathlib.Tactic.Linter.TextBased", "import Cli.Basic" ]
scripts/mathlib_textLint_on_hepLean.lean
heplean_lint_style
/-- Setting up command line options and help text for `lake exe lint_style`. -/
main (args : List String) : IO UInt32 := do heplean_lint_style.validate args
def
scripts
[ "import Mathlib.Tactic.Linter.TextBased", "import Cli.Basic" ]
scripts/mathlib_textLint_on_hepLean.lean
main
/-- The entry point to the `lake exe mathlib_textLint_on_hepLean` command. -/
getDocString (constName : Array ConstantInfo) : MetaM String := do let env ← getEnv let mut docString := "" for c in constName do if ¬ Lean.Name.isInternalDetail c.name then let doc ← Lean.findDocString? env c.name match doc with | some x => docString := docString ++ "- " ++ x ++ "\n" | none => docString := docString return docString
def
scripts
[ "import Batteries.Lean.IO.Process", "import Lean", "import Lean.Parser", "import Lean.Data.Json", "import Mathlib.Lean.CoreM", "import LLM.GPT.Json", "import LLM.GPT.API" ]
scripts/openAI_doc_check.lean
getDocString
null
header : String := " Answer as if you an expert mathematician, physicist and software engineer. Below I have listed the doc strings of definitions and theorems in a Lean 4 file. Output a list of 1) spelling mistakes. 2) grammatical errors. 3) suggestions for improvement. Note that text within `...` should be treated as code and not spellchecked. Doc strings should be a complete sentence, or a noun phrase. "
def
scripts
[ "import Batteries.Lean.IO.Process", "import Lean", "import Lean.Parser", "import Lean.Data.Json", "import Mathlib.Lean.CoreM", "import LLM.GPT.Json", "import LLM.GPT.API" ]
scripts/openAI_doc_check.lean
header
null
main (args : List String) : IO UInt32 := do initSearchPath (← findSysroot) let firstArg := args.head? match firstArg with | some x => do let mut imp : Import := Import.mk x.toName false if x == "random" then let mods : Name := `PhysLean let imps : Import := {module := mods} let mFile ← findOLean imps.module unless (← mFile.pathExists) do throw <| IO.userError s!"object file '{mFile}' of module {imps.module} does not exist" let (hepLeanMod, _) ← readModuleData mFile let imports := hepLeanMod.imports let y ← IO.rand 0 (imports.size -1) imp := imports.get! y let mFile ← findOLean imp.module let filePath := (mkFilePath (imp.module.toString.split (· == '.'))).addExtension "lean" IO.println s!"Checking: {filePath}" let (modData, _) ← readModuleData mFile let cons := modData.constants let docString ← CoreM.withImportModules #[imp.module] (getDocString cons).run' let message : LLM.Message := {role := Role.user, content := header ++ docString} let request : GPT.Request := {messages := [message]} let response ← LLM.GPT.chat (toString <| ToJson.toJson request) let parsedRespone := GPT.parse response match parsedRespone with | .ok x => IO.println x | .error e => IO.println e | none => IO.println "No module provided." return 0
def
scripts
[ "import Batteries.Lean.IO.Process", "import Lean", "import Lean.Parser", "import Lean.Data.Json", "import Mathlib.Lean.CoreM", "import LLM.GPT.Json", "import LLM.GPT.API" ]
scripts/openAI_doc_check.lean
main
null
getStats : MetaM String := do let noDefsVal ← noDefs let noLemmasVal ← noLemmas let noImportsVal ← noImports let noDefsNoDocVal ← noDefsNoDocString let noLemmasNoDocVal ← noLemmasNoDocString let noLinesVal ← noLines let noInformalLemmasVal ← noInformalLemmas let s := s!" Number of Files 📄: {noImportsVal} Number of lines 💻: {noLinesVal} Number of Definitions (incl. instances): {noDefsVal - noInformalLemmasVal} - Of which {noDefsNoDocVal} do not have doc-strings Number of Lemmas: {noLemmasVal + noInformalLemmasVal} - Of which {noLemmasNoDocVal} do not have doc-strings" pure s
def
scripts
[ "import PhysLean.Meta.Informal.Post", "import Mathlib.Lean.CoreM" ]
scripts/stats.lean
getStats
null
Stats.toHtml : MetaM String := do let noDefsVal ← noDefs let noLemmasVal ← noLemmas let noImportsVal ← noImports let noDefsNoDocVal ← noDefsNoDocString let noLemmasNoDocVal ← noLemmasNoDocString let noLinesVal ← noLines let noInformalDefsVal ← noInformalDefs let noInformalLemmasVal ← noInformalLemmas let noTODOsVal ← noTODOs let noFilesWithTODOsVal ← noFilesWithTODOs let header := "--- layout: default --- <!DOCTYPE html> <html> <head> <title>Stats for PhysLean</title> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"> <style> /* Style the progress bar to be wider and take up more space */ progress { width: 80%; /* Adjust to take up more horizontal space */ height: 30px; /* Increase height to make it wider */ appearance: none; /* Remove default browser styles */ } /* Change the color for WebKit browsers (Chrome, Safari, etc.) */ progress::-webkit-progress-bar { background-color: #f3f3f3; /* Background color */ border-radius: 5px; overflow: hidden; } progress::-webkit-progress-value { background-color: #157878; /* Change this to your desired color */ border-radius: 5px; } /* Change the color for Firefox */ progress::-moz-progress-bar { background-color: #157878; /* Change this to your desired color */ } </style> </head> <body>" let body := s!" <h1>Stats for PhysLean</h1> <h3>Number of Files 📄: {noImportsVal}</h3> <h3>Number of lines 💻: {noLinesVal}</h3> <h3>Number of Definitions (incl. instances): {noDefsVal - noInformalLemmasVal}</h3> <p>- Of which {noDefsVal - noDefsNoDocVal- noInformalLemmasVal} have doc-strings:</p> <progress value=\"{noDefsVal - noDefsNoDocVal- noInformalLemmasVal}\" max=\"{noDefsVal- noInformalLemmasVal}\"></progress> <p>- Of which {noDefsVal - noInformalLemmasVal - noInformalDefsVal} are not <a href=\"https://heplean.github.io/HepLean/InformalGraph.html\">informal definitions</a>:</p> <progress value=\"{noDefsVal - noInformalLemmasVal - noInformalDefsVal}\" max=\"{noDefsVal - noInformalLemmasVal}\"></progress> <h3>Number of Lemmas: {noLemmasVal + noInformalLemmasVal}</h3> <p>- Of which {noLemmasVal - noLemmasNoDocVal + noInformalLemmasVal} have doc-strings:</p> <progress value=\"{noLemmasVal - noLemmasNoDocVal + noInformalLemmasVal}\" max=\"{noLemmasVal + noInformalLemmasVal}\"></progress> <p>- Of which {noLemmasVal} are not <a href=\"https://heplean.github.io/HepLean/InformalGraph.html\">informal lemmas</a>:</p> <progress value=\"{noLemmasVal}\" max=\"{noLemmasVal + noInformalLemmasVal}\"></progress> <h3>Number of <a href=\"https://heplean.github.io/HepLean/TODOList\">TODOs</a>: {noTODOsVal}</h3> <p>- There are {noImportsVal - noFilesWithTODOsVal} (of {noImportsVal}) files which are TODO free:</p> <progress value=\"{noImportsVal - noFilesWithTODOsVal}\" max=\"{noImportsVal}\"></progress> " let footer := " </body> </html> " pure (header ++ "\n" ++ body ++ "\n" ++ footer)
def
scripts
[ "import PhysLean.Meta.Informal.Post", "import Mathlib.Lean.CoreM" ]
scripts/stats.lean
Stats.toHtml
null
main (args : List String) : IO UInt32 := do let _ ← noImports let statString ← CoreM.withImportModules #[`PhysLean] (getStats).run' println! statString if "mkHTML" ∈ args then let html ← CoreM.withImportModules #[`PhysLean] (Stats.toHtml).run' let htmlFile : System.FilePath := {toString := "./docs/Stats.html"} IO.FS.writeFile htmlFile html IO.println (s!"HTML file made.") pure 0
def
scripts
[ "import PhysLean.Meta.Informal.Post", "import Mathlib.Lean.CoreM" ]
scripts/stats.lean
main
null
baseHtmlGenerator (title : String) (site : Array Html) : BaseHtmlM Html := do let moduleConstant := if let some module := ← getCurrentName then #[<script>{.raw s!"const MODULE_NAME={String.quote module.toString};"}</script>] else #[] pure <html lang="en"> <head> [← baseHtmlHeadDeclarations] <title>{title}</title> <script defer="true" src={s!"{← getRoot}mathjax-config.js"}></script> <script defer="true" src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script> <script defer="true" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script>{.raw s!"const SITE_ROOT={String.quote (← getRoot)};"}</script> [moduleConstant] <script type="module" src={s!"{← getRoot}jump-src.js"}></script> <script type="module" src={s!"{← getRoot}search.js"}></script> <script type="module" src={s!"{← getRoot}expand-nav.js"}></script> <script type="module" src={s!"{← getRoot}how-about.js"}></script> <script type="module" src={s!"{← getRoot}instances.js"}></script> <script type="module" src={s!"{← getRoot}importedBy.js"}></script> </head> <body> <input id="nav_toggle" type="checkbox"/> <header style="background-color: #2C3E50; color: #fff;"> <h1><label for="nav_toggle"></label><span> <a href="heplean.com" style="color: #fff; text-decoration: none; font-family: serif"> PhysLean Documentation</a> </span></h1> <h2 style="color: #fff; font-family: serif">[breakWithin title]</h2> <form action="https://google.com/search" method="get" id="search_form" style="color: var(--text-color);"> <input type="hidden" name="sitesearch" value="https://leanprover-community.github.io/mathlib4_docs"/> <input type="text" name="q" autocomplete="off"/>{.raw "&#32;"} <button id="search_button" onclick={s!"javascript: form.action='{← getRoot}search.html';"}>Search</button> <button>Google site search</button> </form> </header> [site] <nav class="nav"> <iframe src={s!"{← getRoot}navbar.html"} class="navframe" frameBorder="0"></iframe> </nav> </body> </html> /-- A comfortability wrapper around `baseHtmlGenerator`. -/
def
scripts
[ "import DocGen4.Output.ToHtmlFormat", "import DocGen4.Output.Navbar" ]
scripts/Template.lean
baseHtmlGenerator
/-- The HTML template used for all pages. -/
baseHtml (title : String) (site : Html) : BaseHtmlM Html := baseHtmlGenerator title #[site]
def
scripts
[ "import DocGen4.Output.ToHtmlFormat", "import DocGen4.Output.Navbar" ]
scripts/Template.lean
baseHtml
/-- A comfortability wrapper around `baseHtmlGenerator`. -/
IsUpperCamal (s : String) : Bool := let parts := s.splitOn "." let lastPart := parts.get! (parts.length - 1) lastPart = "noConfusionType" ∨ (¬ (lastPart.get 0 ≥ 'A' ∧ lastPart.get 0 ≤ 'z')) ∨ (lastPart.get 0 ≥ 'A' ∧ lastPart.get 0 ≤ 'Z')
def
scripts
[ "import Batteries.Lean.HashSet", "import Lean" ]
scripts/type_former_lint.lean
IsUpperCamal
/-- A rough definition of Upper Camal, checking that if a string starts with a latin letter then that letter is capital. -/
main (_ : List String) : IO UInt32 := do initSearchPath (← findSysroot) let mods : Name := `PhysLean let imp : Import := {module := mods} let mFile ← findOLean imp.module unless (← mFile.pathExists) do throw <| IO.userError s!"object file '{mFile}' of module {imp.module} does not exist" let (hepLeanMod, _) ← readModuleData mFile let mut warned := false for imp in hepLeanMod.imports do let mFile ← findOLean imp.module let (modData, _) ← readModuleData mFile let cons := modData.constants for c in cons do if c.hasValue ∧ ¬ Lean.Name.isInternal c.name ∧ Lean.Compiler.LCNF.isTypeFormerType c.type ∧ ¬ IsUpperCamal c.name.toString then warned := true IO.println s!"name: #{c.name}" if warned then throw <| IO.userError s!"There are type former definitions not in upper camal style." pure 0
def
scripts
[ "import Batteries.Lean.HashSet", "import Lean" ]
scripts/type_former_lint.lean
main
/-- A rough definition of Upper Camal, checking that if a string starts with a latin letter then that letter is capital. -/
eulerLagrangeOp (L : Time → X → X → ℝ) (q : Time → X) : Time → X := fun t => gradient (L t · (∂ₜ q t)) (q t) - ∂ₜ (fun t' => gradient (L t' (q t') ·) (∂ₜ q t')) t
def
PhysLean
[ "import PhysLean.Mathematics.VariationalCalculus.HasVarGradient" ]
PhysLean/ClassicalMechanics/EulerLagrange.lean
eulerLagrangeOp
/-- The Euler Lagrange operator, for a trajectory `q : Time → X`, and a lagrangian `Time → X → X → ℝ`, the Euler-Lagrange operator is `∂L/∂q - dₜ(∂L/∂(dₜ q))`. -/
eulerLagrangeOp_eq (L : Time → X → X → ℝ) (q : Time → X) : eulerLagrangeOp L q = fun t => gradient (L t · (∂ₜ q t)) (q t) - ∂ₜ (fun t' => gradient (L t' (q t') ·) (∂ₜ q t')) t := by rfl
lemma
PhysLean
[ "import PhysLean.Mathematics.VariationalCalculus.HasVarGradient" ]
PhysLean/ClassicalMechanics/EulerLagrange.lean
eulerLagrangeOp_eq
/-- The Euler Lagrange operator, for a trajectory `q : Time → X`, and a lagrangian `Time → X → X → ℝ`, the Euler-Lagrange operator is `∂L/∂q - dₜ(∂L/∂(dₜ q))`. -/
eulerLagrangeOp_zero (q : Time → X) : eulerLagrangeOp (fun _ _ _ => 0) q = fun _ => 0 := by simp [eulerLagrangeOp_eq, Time.deriv_eq] /- The variational derivative of `L t (q' t) (deriv q' t))` for a lagrangian `L` is equal to the `eulerLagrangeOp`. -/
lemma
PhysLean
[ "import PhysLean.Mathematics.VariationalCalculus.HasVarGradient" ]
PhysLean/ClassicalMechanics/EulerLagrange.lean
eulerLagrangeOp_zero
null
euler_lagrange_varGradient (L : Time → X → X → ℝ) (q : Time → X) (hq : ContDiff ℝ ∞ q) (hL : ContDiff ℝ ∞ ↿L) : (δ (q':=q), ∫ t, L t (q' t) (fderiv ℝ q' t 1)) = eulerLagrangeOp L q := by rw [eulerLagrangeOp_eq] simp only [Time.deriv_eq] apply HasVarGradientAt.varGradient apply HasVarGradientAt.intro _ · apply HasVarAdjDerivAt.comp (F := fun (φ : Time → X × X) t => L t (φ t).fst (φ t).snd) (G := fun (φ : Time → X) t => (φ t, fderiv ℝ φ t 1)) · apply HasVarAdjDerivAt.fmap (f := fun t => ↿(L t)) · fun_prop · fun_prop intro x u apply DifferentiableAt.hasAdjFDerivAt apply Differentiable.differentiableAt apply ContDiff.differentiable fun_prop simp · apply HasVarAdjDerivAt.prod (F:=fun φ => φ) · apply HasVarAdjDerivAt.id _ hq · apply HasVarAdjDerivAt.fderiv · exact hq case hgrad => funext t simp (disch:=fun_prop) only simp[sub_eq_add_neg] congr rw [gradient_eq_adjFDeriv, adjFDeriv_uncurry] apply ContDiff.differentiable (n := ∞) (by fun_prop) ENat.LEInfty.out apply ContDiff.differentiable (n := ∞) (by fun_prop) ENat.LEInfty.out funext t rw [gradient_eq_adjFDeriv, adjFDeriv_uncurry] apply ContDiff.differentiable (n := ∞) (by fun_prop) ENat.LEInfty.out apply ContDiff.differentiable (n := ∞) (by fun_prop) ENat.LEInfty.out
theorem
PhysLean
[ "import PhysLean.Mathematics.VariationalCalculus.HasVarGradient" ]
PhysLean/ClassicalMechanics/EulerLagrange.lean
euler_lagrange_varGradient
null
hamiltonEqOp (H : Time → X → X → ℝ) (p : Time → X) (q : Time → X) : Time → X × X := fun t => (∂ₜ q t + -gradient (fun x => H t x (q t)) (p t), - ∂ₜ p t + -gradient (fun x => H t (p t) x) (q t))
def
PhysLean
[ "import PhysLean.Mathematics.VariationalCalculus.HasVarGradient" ]
PhysLean/ClassicalMechanics/HamiltonsEquations.lean
hamiltonEqOp
/-- Given a hamiltonian `H : Time → X → X → ℝ` the operator which when set to zero implies the Hamilton equations. -/
hamiltonEqOp_eq (H : Time → X → X → ℝ) (p : Time → X) (q : Time → X) : hamiltonEqOp H p q = fun t => (∂ₜ q t + -gradient (fun x => H t x (q t)) (p t), - ∂ₜ p t + -gradient (fun x => H t (p t) x) (q t)) := by rfl
lemma
PhysLean
[ "import PhysLean.Mathematics.VariationalCalculus.HasVarGradient" ]
PhysLean/ClassicalMechanics/HamiltonsEquations.lean
hamiltonEqOp_eq
/-- Given a hamiltonian `H : Time → X → X → ℝ` the operator which when set to zero implies the Hamilton equations. -/
hamiltonEqOp_eq_zero_iff_hamiltons_equations (H : Time → X → X → ℝ) (p : Time → X) (q : Time → X) : hamiltonEqOp H p q = 0 ↔ (∀ t, ∂ₜ q t = gradient (fun x => H t x (q t)) (p t)) ∧ (∀ t, ∂ₜ p t = -gradient (fun x => H t (p t) x) (q t)) := by simp [hamiltonEqOp_eq] simp_all only [Time.deriv_eq] rw [funext_iff] simp_all only [Pi.zero_apply, Prod.mk_eq_zero] apply Iff.intro · intro h1 apply And.intro · intro t conv_rhs => rw [← add_zero (gradient (fun x => H t x (q t)) (p t)), ← (h1 t).1] simp · intro t conv_lhs => rw [← add_zero (fderiv ℝ p t 1), ← (h1 t).2] simp · intro a x simp_all only [add_neg_cancel, neg_neg, and_self]
lemma
PhysLean
[ "import PhysLean.Mathematics.VariationalCalculus.HasVarGradient" ]
PhysLean/ClassicalMechanics/HamiltonsEquations.lean
hamiltonEqOp_eq_zero_iff_hamiltons_equations
null
hamiltons_equations_varGradient (H : Time → X → X → ℝ) (pq : Time → X × X) (hp : ContDiff ℝ ∞ pq) (hL : ContDiff ℝ ∞ ↿H) : (δ (pq':= pq), ∫ t, ⟪(pq' t).1, ∂ₜ (Prod.snd ∘ pq') t⟫_ℝ - H t (pq' t).1 (pq' t).2) = fun t => hamiltonEqOp H (fun t => (pq t).1) (fun t => (pq t).2) t := by apply HasVarGradientAt.varGradient apply HasVarGradientAt.intro _ · apply HasVarAdjDerivAt.add · let i := fun (t : Time) (x : X × X) => ⟪x.1, x.2⟫_ℝ apply HasVarAdjDerivAt.comp (F := fun (φ : Time → X × X) t => i t (φ t)) (G := fun (φ : Time → X × X) t => ((φ t).1, fderiv ℝ (Prod.snd ∘ φ) t 1)) · apply HasVarAdjDerivAt.fmap · fun_prop · fun_prop intro t x apply DifferentiableAt.hasAdjFDerivAt fun_prop · apply HasVarAdjDerivAt.prod · apply HasVarAdjDerivAt.fst apply HasVarAdjDerivAt.id fun_prop · apply HasVarAdjDerivAt.fderiv' (F := fun (φ : Time → X × X) t => (φ t).2) apply HasVarAdjDerivAt.fmap · fun_prop · fun_prop intro t x apply DifferentiableAt.hasAdjFDerivAt fun_prop · apply HasVarAdjDerivAt.neg let H' := fun t => ↿(H t) change HasVarAdjDerivAt (fun φ x => H' x (φ x)) _ pq apply HasVarAdjDerivAt.fmap · fun_prop · fun_prop intro x u apply DifferentiableAt.hasAdjFDerivAt apply Differentiable.differentiableAt apply ContDiff.differentiable fun_prop simp · simp only [adjFDeriv_prod_snd, Prod.mk_add_mk, add_zero, zero_add] funext x rw [adjFDeriv_uncurry] swap · apply ContDiff.differentiable fun_prop simp simp only [Prod.neg_mk, Prod.mk_add_mk] rw [adjFDeriv_inner] simp only [one_smul] conv_rhs => enter [2, 1, 1, 1, 2, x] rw [adjFDeriv_inner] simp rw [← gradient_eq_adjFDeriv, ← gradient_eq_adjFDeriv] rfl · apply ContDiff.differentiable fun_prop simp · apply ContDiff.differentiable fun_prop simp
theorem
PhysLean
[ "import PhysLean.Mathematics.VariationalCalculus.HasVarGradient" ]
PhysLean/ClassicalMechanics/HamiltonsEquations.lean
hamiltons_equations_varGradient
null
ElectricField (d : ℕ := 3) := Time → Space d → EuclideanSpace ℝ (Fin d) /-- The magnetic field is a map from `d+1` dimensional spacetime to the vector space `ℝ^d`. -/
abbrev
PhysLean
[ "import PhysLean.SpaceAndTime.SpaceTime.Basic" ]
PhysLean/Electromagnetism/Basic.lean
ElectricField
/-- The electric field is a map from `d`+1 dimensional spacetime to the vector space `ℝ^d`. -/
MagneticField (d : ℕ := 3) := Time → Space d → EuclideanSpace ℝ (Fin d) open IndexNotation open realLorentzTensor /-- The vector potential of an electromagnetic field-/
abbrev
PhysLean
[ "import PhysLean.SpaceAndTime.SpaceTime.Basic" ]
PhysLean/Electromagnetism/Basic.lean
MagneticField
/-- The magnetic field is a map from `d+1` dimensional spacetime to the vector space `ℝ^d`. -/
VectorPotential (d : ℕ := 3) := SpaceTime d → ℝT[d, .up] /-- The electric permittivity and the magnetic permeability of free space. -/
abbrev
PhysLean
[ "import PhysLean.SpaceAndTime.SpaceTime.Basic" ]
PhysLean/Electromagnetism/Basic.lean
VectorPotential
/-- The vector potential of an electromagnetic field-/
EMSystem where /-- The permittivity of free space. -/ ε₀ : ℝ /-- The permeability of free space. -/ μ₀ : ℝ TODO "6V2UZ" "Charge density and current density should be generalized to signed measures, in such a way that they are still easy to work with and can be integrated with with tensor notation. See here: https://leanprover.zulipchat.com/#narrow/channel/479953-PhysLean/topic/Maxwell's.20Equations" /-- The charge density. -/
structure
PhysLean
[ "import PhysLean.SpaceAndTime.SpaceTime.Basic" ]
PhysLean/Electromagnetism/Basic.lean
EMSystem
/-- The electric permittivity and the magnetic permeability of free space. -/
ChargeDensity := Time → Space → ℝ /-- Current density. -/
abbrev
PhysLean
[ "import PhysLean.SpaceAndTime.SpaceTime.Basic" ]
PhysLean/Electromagnetism/Basic.lean
ChargeDensity
/-- The charge density. -/
CurrentDensity := Time → Space → EuclideanSpace ℝ (Fin 3) namespace EMSystem variable (𝓔 : EMSystem) open SpaceTime /-- The speed of light. -/
abbrev
PhysLean
[ "import PhysLean.SpaceAndTime.SpaceTime.Basic" ]
PhysLean/Electromagnetism/Basic.lean
CurrentDensity
/-- Current density. -/
c : ℝ := 1/(√(𝓔.μ₀ * 𝓔.ε₀)) /-- Coulomb's constant. -/
def
PhysLean
[ "import PhysLean.SpaceAndTime.SpaceTime.Basic" ]
PhysLean/Electromagnetism/Basic.lean
c
/-- The speed of light. -/
coulombConstant : ℝ := 1/(4 * Real.pi * 𝓔.ε₀)
def
PhysLean
[ "import PhysLean.SpaceAndTime.SpaceTime.Basic" ]
PhysLean/Electromagnetism/Basic.lean
coulombConstant
/-- Coulomb's constant. -/
fderiv_uncurry (f : X → Y → Z) (xy dxy : X × Y) (hf : DifferentiableAt 𝕜 (↿f) xy) : fderiv 𝕜 ↿f xy dxy = fderiv 𝕜 (f · xy.2) xy.1 dxy.1 + fderiv 𝕜 (f xy.1 ·) xy.2 dxy.2 := by have hx : (f · xy.2) = ↿f ∘ (fun x' => (x',xy.2)) := by rfl have hy : (f xy.1 ·) = ↿f ∘ (fun y' => (xy.1,y')) := by rfl rw [hx,hy] repeat rw [fderiv_comp (hg := by fun_prop) (hf := by fun_prop)] dsimp rw [← ContinuousLinearMap.map_add] congr repeat rw [DifferentiableAt.fderiv_prodMk (hf₁ := by fun_prop) (hf₂ := by fun_prop)] simp
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry
null
fderiv_curry_fst (f : X × Y → Z) (x : X) (y : Y) (h : DifferentiableAt 𝕜 f (x,y)) (dx : X) : fderiv 𝕜 (fun x' => Function.curry f x' y) x dx = fderiv 𝕜 f (x,y) (dx, 0) := by have h1 : f = ↿(Function.curry f) := by ext x rfl conv_rhs => rw [h1] rw [fderiv_uncurry] simp only [Function.curry_apply, map_zero, add_zero] exact h
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_curry_fst
null
fderiv_curry_snd (f : X × Y → Z) (x : X) (y : Y) (h : DifferentiableAt 𝕜 f (x,y)) (dy : Y) : fderiv 𝕜 (Function.curry f x) y dy = fderiv 𝕜 (f) (x,y) (0, dy) := by have h1 : f = ↿(Function.curry f) := by ext x rfl conv_rhs => rw [h1] rw [fderiv_uncurry] simp rfl exact h
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_curry_snd
null
fderiv_uncurry_clm_comp (f : X → Y → Z) (hf : Differentiable 𝕜 (↿f)) : fderiv 𝕜 ↿f = fun xy => (fderiv 𝕜 (f · xy.2) xy.1).comp (ContinuousLinearMap.fst 𝕜 X Y) + (fderiv 𝕜 (f xy.1 ·) xy.2).comp (ContinuousLinearMap.snd 𝕜 X Y) := by funext xy apply ContinuousLinearMap.ext intro dxy rw [fderiv_uncurry] simp only [ContinuousLinearMap.add_apply, ContinuousLinearMap.coe_comp', ContinuousLinearMap.coe_fst', Function.comp_apply, ContinuousLinearMap.coe_snd'] fun_prop
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry_clm_comp
null
fderiv_wrt_prod {f : X × Y → Z} {xy} (hf : DifferentiableAt 𝕜 f xy) : fderiv 𝕜 f xy = (fderiv 𝕜 (fun x' => f (x',xy.2)) xy.1).comp (ContinuousLinearMap.fst 𝕜 X Y) + (fderiv 𝕜 (fun y' => f (xy.1,y')) xy.2).comp (ContinuousLinearMap.snd 𝕜 X Y) := by apply ContinuousLinearMap.ext; intro (dx,dy) apply fderiv_uncurry (fun x y => f (x,y)) _ _ hf
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_wrt_prod
null
fderiv_wrt_prod_clm_comp (f : X × Y → Z) (hf : Differentiable 𝕜 f) : fderiv 𝕜 f = fun xy => (fderiv 𝕜 (fun x' => f (x',xy.2)) xy.1).comp (ContinuousLinearMap.fst 𝕜 X Y) + (fderiv 𝕜 (fun y' => f (xy.1,y')) xy.2).comp (ContinuousLinearMap.snd 𝕜 X Y) := fderiv_uncurry_clm_comp (fun x y => f (x,y)) hf
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_wrt_prod_clm_comp
null
fderiv_curry_clm_apply (f : X → Y →L[𝕜] Z) (y : Y) (x dx : X) (h : Differentiable 𝕜 f) : fderiv 𝕜 f x dx y = fderiv 𝕜 (f · y) x dx := by rw [fderiv_clm_apply] <;> first | simp | fun_prop /- Helper rw lemmas for proving differentiability conditions. -/
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_curry_clm_apply
null
fderiv_uncurry_comp_fst (f : X → Y → Z) (y : Y) (hf : Differentiable 𝕜 (↿f)) : fderiv 𝕜 (fun x' => (↿f) (x', y)) = fun x => (fderiv 𝕜 (↿f) ((·, y) x)).comp (fderiv 𝕜 (·, y) x) := by have hl (y : Y) : (fun x' => (↿f) (x', y)) = ↿f ∘ (·, y) := by rfl rw [hl] funext x rw [fderiv_comp] · fun_prop · fun_prop
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry_comp_fst
null
fderiv_uncurry_comp_snd (f : X → Y → Z) (x : X) (hf : Differentiable 𝕜 (↿f)) : fderiv 𝕜 (fun y' => (↿f) (x, y')) = fun y => (fderiv 𝕜 (↿f) ((x, ·) y)).comp (fderiv 𝕜 (x, ·) y) := by have hl (x : X) : (fun y' => (↿f) (x, y')) = ↿f ∘ (x, ·) := by rfl rw [hl] funext y rw [fderiv_comp] · fun_prop · fun_prop
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry_comp_snd
null
fderiv_curry_comp_fst (f : X → Y → Z) (x dx : X) (y : Y) (hf : Differentiable 𝕜 (↿f)) : (fderiv 𝕜 (fun x' => f x' y) x) dx = (fderiv 𝕜 (↿f) ((·, y) x)) ((fderiv 𝕜 (·, y) x) dx) := by have hl (y : Y) : (fun x' => f x' y) = ↿f ∘ (·, y) := by rfl rw [hl] rw [fderiv_comp] simp only [ContinuousLinearMap.coe_comp', Function.comp_apply] · fun_prop · fun_prop
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_curry_comp_fst
null
fderiv_curry_comp_snd (f : X → Y → Z) (x : X) (y dy : Y) (hf : Differentiable 𝕜 (↿f)) : (fderiv 𝕜 (fun y' => f x y') y) dy = (fderiv 𝕜 (↿f) ((x, ·) y)) ((fderiv 𝕜 (x, ·) y) dy) := by have hl (x : X) : (fun y' => f x y') = ↿f ∘ (x, ·) := by rfl rw [hl] rw [fderiv_comp] simp only [ContinuousLinearMap.coe_comp', Function.comp_apply] · fun_prop · fun_prop
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_curry_comp_snd
null
fderiv_inr_fst_clm (x : X) (y : Y) : (fderiv 𝕜 (x, ·) y) = ContinuousLinearMap.inr 𝕜 X Y := by rw [(hasFDerivAt_prodMk_right x y).fderiv]
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_inr_fst_clm
null
fderiv_inl_snd_clm (x : X) (y : Y) : (fderiv 𝕜 (·, y) x) = ContinuousLinearMap.inl 𝕜 X Y := by rw [(hasFDerivAt_prodMk_left x y).fderiv] /- Differentiability conditions. -/
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_inl_snd_clm
null
function_differentiableAt_fst (f : X → Y → Z) (x : X) (y : Y) (hf : Differentiable 𝕜 (↿f)) : DifferentiableAt 𝕜 (fun x' => f x' y) x := by have hl : (fun x' => f x' y) = ↿f ∘ (·, y) := by funext x' rfl rw [hl] apply Differentiable.differentiableAt apply Differentiable.comp · fun_prop · fun_prop
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
function_differentiableAt_fst
null
function_differentiableAt_snd (f : X → Y → Z) (x : X) (y : Y) (hf : Differentiable 𝕜 (↿f)) : DifferentiableAt 𝕜 (fun y' => f x y') y := by have hl : (fun y' => f x y') = ↿f ∘ (x, ·) := by funext y' rfl rw [hl] apply Differentiable.differentiableAt apply Differentiable.comp · fun_prop · fun_prop @[fun_prop]
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
function_differentiableAt_snd
null
fderiv_uncurry_differentiable_fst (f : X → Y → Z) (y : Y) (hf : ContDiff 𝕜 2 ↿f) : Differentiable 𝕜 (fderiv 𝕜 fun x' => (↿f) (x', y)) := by fun_prop @[fun_prop]
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry_differentiable_fst
null
fderiv_uncurry_differentiable_snd (f : X → Y → Z) (x : X) (hf : ContDiff 𝕜 2 ↿f) : Differentiable 𝕜 (fderiv 𝕜 fun y' => (↿f) (x, y')) := by fun_prop @[fun_prop]
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry_differentiable_snd
null
fderiv_uncurry_differentiable_fst_comp_snd (f : X → Y → Z) (x : X) (hf : ContDiff 𝕜 2 ↿f) : Differentiable 𝕜 (fun y' => fderiv 𝕜 (fun x' => (↿f) (x', y')) x) := by fun_prop @[fun_prop]
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry_differentiable_fst_comp_snd
null
fderiv_uncurry_differentiable_fst_comp_snd_apply (f : X → Y → Z) (x δx : X) (hf : ContDiff 𝕜 2 ↿f) : Differentiable 𝕜 (fun y' => fderiv 𝕜 (fun x' => (↿f) (x', y')) x δx) := by fun_prop @[fun_prop]
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry_differentiable_fst_comp_snd_apply
null
fderiv_uncurry_differentiable_snd_comp_fst (f : X → Y → Z) (y : Y) (hf : ContDiff 𝕜 2 ↿f) : Differentiable 𝕜 (fun x' => fderiv 𝕜 (fun y' => (↿f) (x', y')) y) := by fun_prop @[fun_prop]
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry_differentiable_snd_comp_fst
null
fderiv_uncurry_differentiable_snd_comp_fst_apply (f : X → Y → Z) (y δy : Y) (hf : ContDiff 𝕜 2 ↿f) : Differentiable 𝕜 (fun x' => fderiv 𝕜 (fun y' => (↿f) (x', y')) y δy) := by fun_prop @[fun_prop]
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_uncurry_differentiable_snd_comp_fst_apply
null
fderiv_curry_differentiableAt_fst_comp_snd (f : X → Y → Z) (x dx : X) (y : Y) (hf : ContDiff 𝕜 2 ↿f) : DifferentiableAt 𝕜 (fun y' => (fderiv 𝕜 (fun x' => f x' y') x) dx) y := by apply Differentiable.differentiableAt fun_prop
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_curry_differentiableAt_fst_comp_snd
null
fderiv_curry_differentiableAt_snd_comp_fst (f : X → Y → Z) (x : X) (y dy : Y) (hf : ContDiff 𝕜 2 ↿f) : DifferentiableAt 𝕜 (fun x' => (fderiv 𝕜 (fun y' => f x' y') y) dy) x := by apply Differentiable.differentiableAt fun_prop /- fderiv commutes on X × Y. -/
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_curry_differentiableAt_snd_comp_fst
null
fderiv_swap [IsRCLikeNormedField 𝕜] (f : X → Y → Z) (x dx : X) (y dy : Y) (hf : ContDiff 𝕜 2 ↿f) : fderiv 𝕜 (fun x' => fderiv 𝕜 (fun y' => f x' y') y dy) x dx = fderiv 𝕜 (fun y' => fderiv 𝕜 (fun x' => f x' y') x dx) y dy := by have hf' : IsSymmSndFDerivAt 𝕜 (↿f) (x,y) := by apply ContDiffAt.isSymmSndFDerivAt (n := 2) · exact ContDiff.contDiffAt hf · simp have h := IsSymmSndFDerivAt.eq hf' (dx,0) (0,dy) rw [fderiv_wrt_prod_clm_comp, fderiv_wrt_prod_clm_comp] at h simp only [ContinuousLinearMap.add_apply, ContinuousLinearMap.coe_comp', ContinuousLinearMap.coe_fst', Function.comp_apply, ContinuousLinearMap.coe_snd', map_zero, add_zero, zero_add] at h rw [fderiv_curry_clm_apply, fderiv_curry_clm_apply] at h simp only [ContinuousLinearMap.add_apply, ContinuousLinearMap.coe_comp', ContinuousLinearMap.coe_fst', Function.comp_apply, map_zero, ContinuousLinearMap.coe_snd', zero_add, add_zero] at h exact h /- Start of differentiability conditions. -/ · fun_prop · fun_prop · exact hf.differentiable (by simp) · fun_prop
lemma
PhysLean
[ "import Mathlib.Analysis.Calculus.FDeriv.Symmetric" ]
PhysLean/Mathematics/FDerivCurry.lean
fderiv_swap
null
predAboveI (i x : Fin n.succ.succ) : Fin n.succ := if h : x.val < i.val then ⟨x.val, by omega⟩ else ⟨x.val - 1, by by_cases hx : x = 0 · omega · omega⟩
def
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
predAboveI
/-- Given a `i` and `x` in `Fin n.succ.succ` returns an element of `Fin n.succ` subtracting 1 if `i.val ≤ x.val` else casting x. -/
predAboveI_self (i : Fin n.succ.succ) : predAboveI i i = ⟨i.val - 1, by omega⟩ := by simp [predAboveI] @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
predAboveI_self
/-- Given a `i` and `x` in `Fin n.succ.succ` returns an element of `Fin n.succ` subtracting 1 if `i.val ≤ x.val` else casting x. -/
predAboveI_succAbove (i : Fin n.succ.succ) (x : Fin n.succ) : predAboveI i (Fin.succAbove i x) = x := by simp only [Nat.succ_eq_add_one, predAboveI, Fin.succAbove, Fin.val_fin_lt, Fin.ext_iff] split_ifs · rfl · rename_i h1 h2 simp only [Fin.lt_def, Fin.coe_castSucc, not_lt, Fin.val_succ] at h1 h2 omega · rfl
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
predAboveI_succAbove
/-- Given a `i` and `x` in `Fin n.succ.succ` returns an element of `Fin n.succ` subtracting 1 if `i.val ≤ x.val` else casting x. -/
succsAbove_predAboveI {i x : Fin n.succ.succ} (h : i ≠ x) : Fin.succAbove i (predAboveI i x) = x := by simp only [Fin.succAbove, predAboveI, Nat.succ_eq_add_one, Fin.val_fin_lt, Fin.ext_iff] split_ifs · rfl · rename_i h1 h2 rw [Fin.lt_def] at h1 h2 simp only [Fin.succ_mk, add_eq_left, one_ne_zero] simp only [Fin.castSucc_mk, Fin.eta, Fin.val_fin_lt, not_lt] at h2 rw [Fin.le_def] at h2 omega · rename_i h1 h2 simp only [not_lt] at h1 rw [Fin.le_def] at h1 rw [Fin.lt_def] at h2 simp only [Fin.castSucc_mk] at h2 omega · rename_i h1 h2 simp only [Fin.succ_mk] rw [not_lt, Fin.le_def] at h1 omega
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
succsAbove_predAboveI
null
predAboveI_eq_iff {i x : Fin n.succ.succ} (h : i ≠ x) (y : Fin n.succ) : y = predAboveI i x ↔ i.succAbove y = x := by apply Iff.intro <;> intro h · subst h rw [succsAbove_predAboveI h] · simp [← h]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
predAboveI_eq_iff
null
predAboveI_lt {i x : Fin n.succ.succ} (h : x.val < i.val) : predAboveI i x = ⟨x.val, by omega⟩ := by simp [predAboveI, h]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
predAboveI_lt
null
predAboveI_ge {i x : Fin n.succ.succ} (h : i.val < x.val) : predAboveI i x = ⟨x.val - 1, by omega⟩ := by simp only [Nat.succ_eq_add_one, predAboveI, Fin.val_fin_lt, dite_eq_right_iff, Fin.mk.injEq] omega
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
predAboveI_ge
null
succAbove_succAbove_predAboveI (i : Fin n.succ.succ) (j : Fin n.succ) (x : Fin n) : i.succAbove (j.succAbove x) = (i.succAbove j).succAbove ((predAboveI (i.succAbove j) i).succAbove x) := by by_cases h1 : j.castSucc < i · have hx := Fin.succAbove_of_castSucc_lt _ _ h1 rw [hx, predAboveI_ge h1] by_cases hx1 : x.castSucc < j · rw [Fin.succAbove_of_castSucc_lt _ _ hx1, Fin.succAbove_of_castSucc_lt] · nth_rewrite 2 [Fin.succAbove_of_castSucc_lt] · rw [Fin.succAbove_of_castSucc_lt] exact hx1 · rw [Fin.lt_def] at h1 hx1 ⊢ simp_all only [Nat.succ_eq_add_one, Fin.coe_castSucc] omega · exact Nat.lt_trans hx1 h1 · simp only [not_lt] at hx1 rw [Fin.le_def] at hx1 rw [Fin.lt_def] at h1 rw [Fin.succAbove_of_le_castSucc _ _ hx1] by_cases hx2 : x.succ.castSucc < i · rw [Fin.succAbove_of_castSucc_lt _ _ hx2] nth_rewrite 2 [Fin.succAbove_of_castSucc_lt] · rw [Fin.succAbove_of_le_castSucc] · rfl · assumption · rw [Fin.lt_def] at hx2 ⊢ simp_all only [Nat.succ_eq_add_one, Fin.coe_castSucc, Fin.val_succ] omega · simp only [not_lt] at hx2 rw [Fin.succAbove_of_le_castSucc _ _ hx2] nth_rewrite 2 [Fin.succAbove_of_le_castSucc] · rw [Fin.succAbove_of_le_castSucc] rw [Fin.le_def] exact Nat.le_succ_of_le hx1 · rw [Fin.le_def] at hx2 ⊢ simp_all · simp only [Nat.succ_eq_add_one, not_lt] at h1 have hx := Fin.succAbove_of_le_castSucc _ _ h1 rw [hx, predAboveI_lt (Nat.lt_add_one_of_le h1)] by_cases hx1 : j ≤ x.castSucc · rw [Fin.succAbove_of_le_castSucc _ _ hx1, Fin.succAbove_of_le_castSucc _ _] · nth_rewrite 2 [Fin.succAbove_of_le_castSucc _ _] · rw [Fin.succAbove_of_le_castSucc] rw [Fin.le_def] at hx1 ⊢ simp_all only [Nat.succ_eq_add_one, Fin.coe_castSucc, Fin.val_succ, add_le_add_iff_right] · rw [Fin.le_def] at h1 hx1 ⊢ simp_all only [Nat.succ_eq_add_one, Fin.coe_castSucc] omega · rw [Fin.le_def] at hx1 h1 ⊢ simp_all only [Nat.succ_eq_add_one, Fin.coe_castSucc, Fin.val_succ] omega · simp only [Nat.succ_eq_add_one, not_le] at hx1 rw [Fin.lt_def] at hx1 rw [Fin.le_def] at h1 rw [Fin.succAbove_of_castSucc_lt _ _ hx1] by_cases hx2 : x.castSucc.castSucc < i · rw [Fin.succAbove_of_castSucc_lt _ _ hx2] nth_rewrite 2 [Fin.succAbove_of_castSucc_lt] · rw [Fin.succAbove_of_castSucc_lt] rw [Fin.lt_def] at hx2 ⊢ simp_all only [Nat.succ_eq_add_one, Fin.coe_castSucc, Fin.val_succ] omega · rw [Fin.lt_def] at hx2 ⊢ simp_all · simp only [not_lt] at hx2 rw [Fin.succAbove_of_le_castSucc _ _ hx2] nth_rewrite 2 [Fin.succAbove_of_le_castSucc] · rw [Fin.succAbove_of_castSucc_lt] · rfl exact Fin.castSucc_lt_succ_iff.mpr hx1 · rw [Fin.le_def] at hx2 ⊢ simp_all /-- The equivalence between `Fin n.succ` and `Fin 1 ⊕ Fin n` extracting the `i`th component. -/
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
succAbove_succAbove_predAboveI
null
finExtractOne {n : ℕ} (i : Fin (n + 1)) : Fin (n + 1) ≃ Fin 1 ⊕ Fin n := (finCongr (by omega : n.succ = i + 1 + (n - i))).trans <| finSumFinEquiv.symm.trans <| (Equiv.sumCongr (finSumFinEquiv.symm.trans (Equiv.sumComm (Fin i) (Fin 1))) (Equiv.refl (Fin (n-i)))).trans <| (Equiv.sumAssoc (Fin 1) (Fin i) (Fin (n - i))).trans <| Equiv.sumCongr (Equiv.refl (Fin 1)) (finSumFinEquiv.trans (finCongr (by omega))) @[simp]
def
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOne
/-- The equivalence between `Fin n.succ` and `Fin 1 ⊕ Fin n` extracting the `i`th component. -/
finExtractOne_apply_eq {n : ℕ} (i : Fin n.succ) : finExtractOne i i = Sum.inl 0 := by simp only [Nat.succ_eq_add_one, finExtractOne, Equiv.trans_apply, finCongr_apply, Equiv.sumCongr_apply, Equiv.coe_trans, Equiv.sumComm_apply, Equiv.coe_refl, Fin.isValue] rw [show Fin.cast _ i = Fin.castAdd ((n - ↑i)) ⟨i.1, lt_add_one i.1⟩ from rfl, finSumFinEquiv_symm_apply_castAdd] simp only [Nat.succ_eq_add_one, Sum.map_inl, Function.comp_apply, Fin.isValue] have h2 : @Fin.mk (↑i + 1) ↑i (lt_add_one i.1) = Fin.natAdd i.val 1 := rfl rw [h2, finSumFinEquiv_symm_apply_natAdd] rfl
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOne_apply_eq
null
finExtractOne_symm_inr {n : ℕ} (i : Fin n.succ) : (finExtractOne i).symm ∘ Sum.inr = i.succAbove := by ext x simp only [Nat.succ_eq_add_one, finExtractOne, Function.comp_apply, Equiv.symm_trans_apply, finCongr_symm, Equiv.symm_symm, Equiv.sumCongr_symm, Equiv.refl_symm, Equiv.sumCongr_apply, Equiv.coe_refl, Sum.map_inr, finCongr_apply, Fin.coe_cast] change (finSumFinEquiv (Sum.map (⇑(finSumFinEquiv.symm.trans (Equiv.sumComm (Fin ↑i) (Fin 1))).symm) id ((Equiv.sumAssoc (Fin 1) (Fin ↑i) (Fin (n - i))).symm (Sum.inr (finSumFinEquiv.symm (Fin.cast _ x)))))).val = _ by_cases hi : x.1 < i.1 · generalize_proofs hp have h1 : (finSumFinEquiv.symm (Fin.cast hp x)) = Sum.inl ⟨x, hi⟩ := by rw [← finSumFinEquiv_symm_apply_castAdd] rfl rw [h1] simp only [Nat.succ_eq_add_one, Equiv.sumAssoc_symm_apply_inr_inl, Sum.map_inl, Equiv.symm_trans_apply, Equiv.symm_symm, Equiv.sumComm_symm, Equiv.sumComm_apply, Sum.swap_inr, finSumFinEquiv_apply_left, Fin.castAdd_mk] rw [Fin.succAbove] split · rfl rename_i hn simp_all only [Nat.succ_eq_add_one, not_lt, Fin.le_def, Fin.coe_castSucc, Fin.val_succ, left_eq_add, one_ne_zero] omega · generalize_proofs hp have h1 : (finSumFinEquiv.symm (Fin.cast hp x)) = Sum.inr ⟨x - i, by omega⟩ := by rw [← finSumFinEquiv_symm_apply_natAdd] apply congrArg ext simp only [Nat.succ_eq_add_one, Fin.coe_cast, Fin.natAdd_mk] omega rw [h1, Fin.succAbove] split · rename_i hn simp_all [Fin.lt_def] simp only [Nat.succ_eq_add_one, Equiv.sumAssoc_symm_apply_inr_inr, Sum.map_inr, id_eq, finSumFinEquiv_apply_right, Fin.natAdd_mk, Fin.val_succ] omega @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOne_symm_inr
null
finExtractOne_symm_inr_apply {n : ℕ} (i : Fin n.succ) (x : Fin n) : (finExtractOne i).symm (Sum.inr x) = i.succAbove x := calc _ = ((finExtractOne i).symm ∘ Sum.inr) x := rfl _ = i.succAbove x := by rw [finExtractOne_symm_inr] @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOne_symm_inr_apply
null
finExtractOne_symm_inl_apply {n : ℕ} (i : Fin n.succ) : (finExtractOne i).symm (Sum.inl 0) = i := by rfl
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOne_symm_inl_apply
null
finExtractOne_apply_neq {n : ℕ} (i j : Fin (n + 1 + 1)) (hij : i ≠ j) : finExtractOne i j = Sum.inr (predAboveI i j) := by symm apply (Equiv.symm_apply_eq _).mp ?_ simp only [Nat.succ_eq_add_one, finExtractOne_symm_inr_apply] exact succsAbove_predAboveI hij /-- Given an equivalence `Fin n.succ.succ ≃ Fin n.succ.succ`, and an `i : Fin n.succ.succ`, the map `Fin n.succ → Fin n.succ` obtained by dropping `i` and it's image. -/
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOne_apply_neq
null
finExtractOnPermHom {m : ℕ} (i : Fin n.succ.succ) (σ : Fin n.succ.succ ≃ Fin m.succ.succ) : Fin n.succ → Fin m.succ := fun x => predAboveI (σ i) (σ ((finExtractOne i).symm (Sum.inr x)))
def
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOnPermHom
/-- Given an equivalence `Fin n.succ.succ ≃ Fin n.succ.succ`, and an `i : Fin n.succ.succ`, the map `Fin n.succ → Fin n.succ` obtained by dropping `i` and it's image. -/
finExtractOnPermHom_inv {m : ℕ} (i : Fin n.succ.succ) (σ : Fin n.succ.succ ≃ Fin m.succ.succ) : (finExtractOnPermHom (σ i) σ.symm) ∘ (finExtractOnPermHom i σ) = id := by funext x simp only [Nat.succ_eq_add_one, Function.comp_apply, finExtractOnPermHom, Equiv.symm_apply_apply, finExtractOne_symm_inr_apply, id_eq] by_cases h : σ (i.succAbove x) < σ i · rw [predAboveI_lt h, Fin.succAbove_of_castSucc_lt] · simp · simp_all have hσ : σ (i.succAbove x) ≠ σ i := by simp only [Nat.succ_eq_add_one, ne_eq, EmbeddingLike.apply_eq_iff_eq] exact Fin.succAbove_ne i x have hn : σ i < σ (i.succAbove x) := by omega rw [predAboveI_ge hn] rw [Fin.succAbove_of_le_castSucc] · simp only [Nat.succ_eq_add_one, Fin.succ_mk] trans predAboveI i (σ.symm (σ (i.succAbove x))) · congr exact Nat.sub_add_cancel (Fin.lt_of_le_of_lt (Fin.zero_le (σ i)) hn) simp rw [Fin.le_def] simp only [Nat.succ_eq_add_one, Fin.castSucc_mk] omega /-- Given an equivalence `Fin n.succ.succ ≃ Fin n.succ.succ`, and an `i : Fin n.succ.succ`, the equivalence `Fin n.succ ≃ Fin n.succ` obtained by dropping `i` and it's image. -/
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOnPermHom_inv
/-- Given an equivalence `Fin n.succ.succ ≃ Fin n.succ.succ`, and an `i : Fin n.succ.succ`, the map `Fin n.succ → Fin n.succ` obtained by dropping `i` and it's image. -/
finExtractOnePerm {m : ℕ} (i : Fin n.succ.succ) (σ : Fin n.succ.succ ≃ Fin m.succ.succ) : Fin n.succ ≃ Fin m.succ where toFun x := finExtractOnPermHom i σ x invFun x := finExtractOnPermHom (σ i) σ.symm x left_inv x := by simpa using congrFun (finExtractOnPermHom_inv i σ) x right_inv x := by simpa using congrFun (finExtractOnPermHom_inv (σ i) σ.symm) x
def
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOnePerm
/-- Given an equivalence `Fin n.succ.succ ≃ Fin n.succ.succ`, and an `i : Fin n.succ.succ`, the equivalence `Fin n.succ ≃ Fin n.succ` obtained by dropping `i` and it's image. -/
finExtractOnePerm_equiv {n m : ℕ} (e : Fin n.succ.succ ≃ Fin m.succ.succ) (i : Fin n.succ.succ) : e ∘ i.succAbove = (e i).succAbove ∘ finExtractOnePerm i e := by simp only [Nat.succ_eq_add_one, finExtractOnePerm, Equiv.coe_fn_mk] funext x simp only [Function.comp_apply, finExtractOnPermHom, Nat.succ_eq_add_one, finExtractOne_symm_inr_apply] rw [succsAbove_predAboveI] simp only [Nat.succ_eq_add_one, ne_eq, EmbeddingLike.apply_eq_iff_eq] exact Fin.ne_succAbove i x @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOnePerm_equiv
null
finExtractOnePerm_apply (i : Fin n.succ.succ) (σ : Fin n.succ.succ ≃ Fin n.succ.succ) (x : Fin n.succ) : finExtractOnePerm i σ x = predAboveI (σ i) (σ ((finExtractOne i).symm (Sum.inr x))) := rfl @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOnePerm_apply
null
finExtractOnePerm_symm_apply (i : Fin n.succ.succ) (σ : Fin n.succ.succ ≃ Fin n.succ.succ) (x : Fin n.succ) : (finExtractOnePerm i σ).symm x = predAboveI (σ.symm (σ i)) (σ.symm ((finExtractOne (σ i)).symm (Sum.inr x))) := rfl /-- The equivalence of types `Fin n.succ.succ ≃ (Fin 1 ⊕ Fin 1) ⊕ Fin n` extracting the `i` and `(i.succAbove j)`. -/
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractOnePerm_symm_apply
null
finExtractTwo {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : Fin n.succ.succ ≃ (Fin 1 ⊕ Fin 1) ⊕ Fin n := (finExtractOne i).trans <| (Equiv.sumCongr (Equiv.refl (Fin 1)) (finExtractOne j)).trans <| (Equiv.sumAssoc (Fin 1) (Fin 1) (Fin n)).symm @[simp]
def
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractTwo
/-- The equivalence of types `Fin n.succ.succ ≃ (Fin 1 ⊕ Fin 1) ⊕ Fin n` extracting the `i` and `(i.succAbove j)`. -/
finExtractTwo_apply_fst {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : finExtractTwo i j i = Sum.inl (Sum.inl 0) := by simp [finExtractTwo]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractTwo_apply_fst
/-- The equivalence of types `Fin n.succ.succ ≃ (Fin 1 ⊕ Fin 1) ⊕ Fin n` extracting the `i` and `(i.succAbove j)`. -/
finExtractTwo_symm_inr {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : (finExtractTwo i j).symm ∘ Sum.inr = i.succAbove ∘ j.succAbove := by rw [finExtractTwo] ext1 x simp @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractTwo_symm_inr
null
finExtractTwo_symm_inr_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) (x : Fin n) : (finExtractTwo i j).symm (Sum.inr x) = i.succAbove (j.succAbove x) := by simp [finExtractTwo] @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractTwo_symm_inr_apply
null
finExtractTwo_symm_inl_inr_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : (finExtractTwo i j).symm (Sum.inl (Sum.inr 0)) = i.succAbove j := by simp [finExtractTwo] @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractTwo_symm_inl_inr_apply
null
finExtractTwo_symm_inl_inl_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : (finExtractTwo i j).symm (Sum.inl (Sum.inl 0)) = i := by rfl @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractTwo_symm_inl_inl_apply
null
finExtractTwo_apply_snd {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : finExtractTwo i j (i.succAbove j) = Sum.inl (Sum.inr 0) := by simp [← Equiv.eq_symm_apply] /-- Takes two maps `Fin n → Fin n` and returns the equivalence they form. -/
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finExtractTwo_apply_snd
null
finMapToEquiv (f1 : Fin n → Fin m) (f2 : Fin m → Fin n) (h : ∀ x, f1 (f2 x) = x := by decide) (h' : ∀ x, f2 (f1 x) = x := by decide) : Fin n ≃ Fin m where toFun := f1 invFun := f2 left_inv := h' right_inv := h @[simp]
def
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finMapToEquiv
/-- Takes two maps `Fin n → Fin n` and returns the equivalence they form. -/
finMapToEquiv_apply {f1 : Fin n → Fin m} {f2 : Fin m → Fin n} {h : ∀ x, f1 (f2 x) = x} {h' : ∀ x, f2 (f1 x) = x} (x : Fin n) : finMapToEquiv f1 f2 h h' x = f1 x := rfl @[simp]
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finMapToEquiv_apply
/-- Takes two maps `Fin n → Fin n` and returns the equivalence they form. -/
finMapToEquiv_symm_apply {f1 : Fin n → Fin m} {f2 : Fin m → Fin n} {h : ∀ x, f1 (f2 x) = x} {h' : ∀ x, f2 (f1 x) = x} (x : Fin m) : (finMapToEquiv f1 f2 h h').symm x = f2 x := rfl
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finMapToEquiv_symm_apply
null
finMapToEquiv_symm_eq {f1 : Fin n → Fin m} {f2 : Fin m → Fin n} {h : ∀ x, f1 (f2 x) = x} {h' : ∀ x, f2 (f1 x) = x} : (finMapToEquiv f1 f2 h h').symm = finMapToEquiv f2 f1 h' h := rfl /-- Given an equivalence between `Fin n` and `Fin m`, the induced equivalence between `Fin n.succ` and `Fin m.succ` derived by `Fin.cons`. -/
lemma
PhysLean
[ "import Mathlib.Tactic.Polyrith", "import Mathlib.Tactic.Linarith", "import Mathlib.Logic.Equiv.Fin.Basic" ]
PhysLean/Mathematics/Fin.lean
finMapToEquiv_symm_eq
null