lean 4 state of the
play

Lean 4: State of the Sebastian Ullrich Ullrich - Lean 4: State of - PowerPoint PPT Presentation

1 2020/01/09 IPD Snelting KIT Programming paradigms group - IPD Snelting KIT The Research University in the Helmholtz Association www.kit.edu Lean 4: State of the Sebastian Ullrich Ullrich - Lean 4: State of the A brief history


  1. 1 2020/01/09 IPD Snelting KIT Programming paradigms group - IPD Snelting KIT – The Research University in the Helmholtz Association www.kit.edu Lean 4: State of the ⋃ Sebastian Ullrich Ullrich - Lean 4: State of the ⋃

  2. A brief history of Lean Lean 3 (2017) X reimplement Lean in Lean make Lean a general-purpose language: native back end, FFI, ... Lean 4 (201X) backed by a bytecode interpreter make Lean a meta-programming language: build tactics in Lean fjxed tactic language 2 fjrst offjcial release Lean 2 (2015) Lean 0.1 (2014) KIT IPD Snelting 2020/01/09 10 Ullrich - Lean 4: State of the ⋃

  3. A brief history of Lean fjxed tactic language reimplement Lean in Lean make Lean a general-purpose language: native back end, FFI, ... Lean 4 (201X) backed by a bytecode interpreter make Lean a meta-programming language: build tactics in Lean Lean 3 (2017) fjrst offjcial release 2 Lean 2 (2015) Lean 0.1 (2014) KIT IPD Snelting 2020/01/09 X ≥ 10 Ullrich - Lean 4: State of the ⋃

  4. The Lean dream team 3 2020/01/09 IPD Snelting KIT Leonardo de Moura: everything, really Sebastian Ullrich: macros, interpreter Daniel Selsam: new typeclass resolution Simon Hudon: language server Ullrich - Lean 4: State of the ⋃

  5. The Lean dream team 3 2020/01/09 IPD Snelting KIT Leonardo de Moura: everything, really Sebastian Ullrich: macros, interpreter Daniel Selsam: new typeclass resolution Simon Hudon: language server Ullrich - Lean 4: State of the ⋃

  6. The Lean dream team 3 2020/01/09 IPD Snelting KIT Leonardo de Moura: everything, really Sebastian Ullrich: macros, interpreter Daniel Selsam: new typeclass resolution Simon Hudon: language server Ullrich - Lean 4: State of the ⋃

  7. Lean 4 progress: Jan 2019 compiler Lean C++ FFI macro expander typeclass resolution meta monad module system tactic framework kernel 4 elaborator parser language server editor KIT IPD Snelting 2020/01/09 other Ullrich - Lean 4: State of the ⋃

  8. Lean 4 progress: Jun 2019 compiler Lean C++ FFI macro hygiene typeclass resolution meta monad module system tactic framework kernel 4 elaborator parser language server editor KIT IPD Snelting 2020/01/09 other Ullrich - Lean 4: State of the ⋃

  9. Lean 4 progress: Dec 2019 tactic framework Lean C++ interpreter FFI macro hygiene typeclass resolution meta monad module system compiler 4 kernel elaborator parser language server editor KIT IPD Snelting 2020/01/09 other Ullrich - Lean 4: State of the ⋃

  10. Lean 4 progress: Jan 2020 tactic framework Lean C++ interpreter FFI macro hygiene typeclass resolution meta monad module system compiler 4 kernel elaborator parser language server editor KIT IPD Snelting 2020/01/09 other Ullrich - Lean 4: State of the ⋃

  11. lemma convention termName_property_of_assumption ? def hiThere : ... match ... with | pat1 , ... => ... | pat1 , ... => ... | ... | ... fun x => let y := 1 ; do a; b 5 consistent pattern syntax Minor syntax changes to make Lean a more consistent and pleasant language KIT IPD Snelting etc... 2020/01/09 Cosmetics naming convention: TypeName , ModuleName , termName Ullrich - Lean 4: State of the ⋃

  12. def hiThere : ... match ... with | pat1 , ... => ... | pat1 , ... => ... | ... | ... fun x => let y := 1 ; do a; b consistent pattern syntax 5 Minor syntax changes to make Lean a more consistent and pleasant language KIT IPD Snelting etc... 2020/01/09 Cosmetics naming convention: TypeName , ModuleName , termName lemma convention termName_property_of_assumption ? Ullrich - Lean 4: State of the ⋃

  13. fun x => let y := 1 ; do a; b consistent pattern syntax etc... 5 Cosmetics Minor syntax changes to make Lean a more consistent and pleasant language KIT IPD Snelting 2020/01/09 naming convention: TypeName , ModuleName , termName lemma convention termName_property_of_assumption ? def hiThere : ... match ... with | pat1 , ... => ... | pat1 , ... => ... | ... | ... Ullrich - Lean 4: State of the ⋃

  14. Cosmetics 5 2020/01/09 etc... IPD Snelting KIT Minor syntax changes to make Lean a more consistent and pleasant language consistent pattern syntax naming convention: TypeName , ModuleName , termName lemma convention termName_property_of_assumption ? def hiThere : ... match ... with | pat1 , ... => ... | pat1 , ... => ... | ... | ... fun x => let y := 1 ; do a; b Ullrich - Lean 4: State of the ⋃

  15. Compiler 6 2020/01/09 IPD Snelting KIT Ullrich and de Moura. Counting Immutable Beans: Reference Counting Optimized for Purely Functional Programming . IFL’19. Ullrich - Lean 4: State of the ⋃

  16. New typeclass resolution 7 2020/01/09 IPD Snelting KIT Performance issues with the old implementation: diamonds can lead to exponential runtime cycles can lead to nontermination Typeclass resolution follows a “Prolog-like search” adapt known Prolog optimization, tabled resolution , to Lean! Guarantees termination if size of typeclass problems is bounded Ullrich - Lean 4: State of the ⋃

  17. New typeclass resolution 7 2020/01/09 IPD Snelting KIT Performance issues with the old implementation: diamonds can lead to exponential runtime cycles can lead to nontermination Typeclass resolution follows a “Prolog-like search” adapt known Prolog optimization, tabled resolution , to Lean! Guarantees termination if size of typeclass problems is bounded Ullrich - Lean 4: State of the ⋃

  18. New typeclass resolution 7 2020/01/09 IPD Snelting KIT Performance issues with the old implementation: diamonds can lead to exponential runtime cycles can lead to nontermination Typeclass resolution follows a “Prolog-like search” Guarantees termination if size of typeclass problems is bounded ⇒ adapt known Prolog optimization, tabled resolution , to Lean! Ullrich - Lean 4: State of the ⋃

  19. 8 2020/01/09 IPD Snelting KIT State of the ⋃ notation " ⋃ " binders ", " r :( scoped f , Union f ) := r Ullrich - Lean 4: State of the ⋃

  20. 8 2020/01/09 IPD Snelting KIT State of the ⋃ notation " ⋃ " binders ", " r :( scoped f , Union f ) := r expected ' := ' Ullrich - Lean 4: State of the ⋃

  21. 8 2020/01/09 IPD Snelting KIT State of the ⋃ notation " ⋃ " b ", " r := Union (fun b => r ) # check ⋃ x , x = x # check ⋃ ( x : Set Unit ), x = x # check ⋃ x ∈ univ , x = x -- error Ullrich - Lean 4: State of the ⋃

  22. 8 2020/01/09 IPD Snelting KIT State of the ⋃ notation " ⋃ " b ", " r := Union { b | r } # check ⋃ x , x = x # check ⋃ ( x : Set Unit ), x = x # check ⋃ x ∈ univ , x = x -- works! Ullrich - Lean 4: State of the ⋃

  23. 8 2020/01/09 IPD Snelting KIT State of the ⋃ syntax " ⋃ " term ", " term : term macro ` ( ⋃ $b , $r ) => ` ( Union { $b | $r }) # check ⋃ x , x = x # check ⋃ ( x : Set Unit ), x = x # check ⋃ x ∈ univ , x = x -- works! Ullrich - Lean 4: State of the ⋃

  24. 2020/01/09 8 IPD Snelting KIT State of the ⋃ syntax " ⋃ " term ", " term : term macro ` ( ⋃ $b , $r ) => ` ( Union { $b | $r }) # check ⋃ x , x = x # check ⋃ ( x : Set Unit ), x = x # check ⋃ x ∈ univ , x = x -- works! syntax "{" term " | " term "}" : term macro | ` ({ $x ∈ $s | $p }) => ` ( setOf (fun $x => $x ∈ $s ∧ $p )) | ` ({ $x ≤ $e | $p }) => ` ( setOf (fun $x => $x ≤ $e ∧ $p )) | ` ({ $b | $r }) => ` ( setOf (fun $b => $r )) Ullrich - Lean 4: State of the ⋃

  25. 2020/01/09 8 IPD Snelting KIT State of the ⋃ syntax " ⋃ " setIdx ", " term : term macro ` ( ⋃ $b , $r ) => ` ( Union { $b | $r }) # check ⋃ x , x = x # check ⋃ x : Set Unit , x = x -- works! # check ⋃ x ∈ univ , x = x syntax "{" term " | " term "}" : term macro | ` ({ $x ∈ $s | $p }) => ` ( setOf (fun $x => $x ∈ $s ∧ $p )) | ` ({ $x ≤ $e | $p }) => ` ( setOf (fun $x => $x ≤ $e ∧ $p )) | ` ({ $b | $r }) => ` ( setOf (fun $b => $r )) Ullrich - Lean 4: State of the ⋃

  26. 2020/01/09 8 IPD Snelting KIT State of the ⋃ syntax " ⋃ " setIdx ", " term : term macro ` ( ⋃ $b , $r ) => ` ( Union { $b | $r }) # check ⋃ x , x = x # check ⋃ x : Set Unit , x = x -- works! # check ⋃ x ∈ univ , x = x declare_syntax_cat setIdx syntax term : setIdx syntax ident " : " term : setIdx syntax "{" setIdx " | " term "}" : term macro | ` ({ $x ∈ $s | $p }) => ` ( setOf (fun $x => $x ∈ $s ∧ $p )) | ` ({ $x ≤ $e | $p }) => ` ( setOf (fun $x => $x ≤ $e ∧ $p )) | ` ({ $x : $t | $r }) => ` ( setOf (fun ( $x : $t ) => $r )) | ` ({ $b | $r }) => ` ( setOf (fun $b => $r )) Ullrich - Lean 4: State of the ⋃

  27. $ lean --plugin lean3-compat mathlib/src/... Thoughts about eventual porting of Lean 3 code 9 2020/01/09 IPD Snelting KIT syntax changes: mostly superfjcial, automatable One possible path: Incrementally reimplement Lean 3 syntax as macros fjrst, then unfold them as fjnal step elaborator changes: probably not too drastic library changes: mostly missing API, needs to be reimplemented but not necessarily in the stdlib Ullrich - Lean 4: State of the ⋃

Recommend


More recommend