Functional Programming (FP) Languages : Lisp, Haskell, Scala, Kotlin, etc.
Inventor of Lambda Calculus : Alonzo Church (1903 – 1995), whose student in Princeton University (1936-1938) was Alan Turing (The Father of Artificial Intelligence).
Lambda Calculus is not : another Differential Calculus !
Note: Calculus has a meaning of manipulating symbolic expressions : either in functions (differentiation, integration) or computations.
Lambda Calculus is almost programming!
I. Syntax of Lambda Calculus:
Notice: it has only one parameter “x”.
- Function definition:
- Identifier reference:
- Function application:
II. Currying 柯里化 : (named after Haskell Curry ) for multiple parameters.
written by “Currying” as :
Syntactic Sugar 语法糖 : a notational shorthand. Eg. “cubic”
cubic = λ x . x * x * x
III. Binding: Every parameter (aka variable) must be declared (syntactically binding).
here, x is bound, but z is FREE (error!)
IV. Two Execution Methods:
- rename variables to avoid conflict
- Eager evaluation strategy : Right to Left (innermost expression first to outermost) or
- Lazy evaluation strategy : Left to Right (outermost expression first to innermost) – don’t compute the value of an expression until you need to – (save memory space and computing time)
- Most FP are Lazy.
- Most Procedural (Imperative) languages (C, Fortran, Basic, …) are Eager.
V. Lambda Calculus fulfilling the 3 conditions for “Turing Complete” Computation :
- Unbounded “Storage” (not necessarily a physical device) – generate arbitrarily complicated values in a variable or many functions without bound.
- Arithmetic – Church numerals (Peano arithmetic using functions): eg z=0, s= z+ 1 => 1 = λ s z . s z => 2 = λ s z . s ( s z ) … => 7= λ s z . s (s(s(s(s(s(s(z )))))))
- Control Flow – TRUE = λ t f . t / FALSE = λ t f . f / BoolAnd = λ x y . x y FALSE / BoolOr = λ x y . x TRUE y / Repetition by Recursion (Y Combinator )
Conclusion: Lambda Calculus = “Computer on paper”
VI. Type – Consistent Model (notation “:“)
eg. λ x : I . x + 3 ( I is Integer Type)
=> The result (x + 3) is also Type I since by inference “+” is of Type I -> I
Reference: “Good Math” by Mark Chu-Carroll https://www.amazon.com/Good-Math-Computation-Pragmatic-Programmers/dp/1937785335/
The more modern “Functional Programming” languages are yet to show the popularity : Haskell, Scala, Clojure, Kotlin (Google / Jetbean). Reason: High learning curve and too abstract mathematics .
Since May 2017 Kotlin released by Google, 12.8% Java developers have converted to Kotlin, yet they still keep to the OO spirit of Java (for Interoperability) , not taking full advantage of FP capability of Kotlin. The OO Design Patterns of Android Java still being used instead of the FP more elegant “Monadic” Design.
1. Interview with Kotlin Designer:
2. Android Studio 3.0 Released : https://www.androidauthority.com/android-studio-3-released-810099/
2a. Android Studio v3.0 with Kotlin built-in & many improvements.
(The previous stable v2.3 needs seperate Kotlin plug-in)
2c: Gradle upgrade
3. Inner / Infix Function
4. Test (Mockito)
5. Function vs Procedure vs Method – Kotlin simplifies all 3 into 1 : Function which always returns a value or UNIT.
6. Kotlin has which Java lacks … “with“, “?”, …
7. Kotlin Operator Overloading aka “Convention”: ‘plus’ / ‘+’
8. JVM Byte Code Generation:
9. Reified Types
10. SICP: Sequence as conventional interfaces: eg. flatmap, map, reduce, fold
12. Generic : Kotlin入门(11)江湖绝技之特殊函数
13. Array <String>: Kotlin入门(4)声明与操作数组
14. ViewPager (Horizontal Swipe)
15. Kotlin 1.2 Beta & Multiplatform iOS
16. Kotlin Edu ( Android Studio 3.0)
17. Kotlin Style Guide
18. Android Layout Foundamental – ConstraintLayout
19. Android SDK
20. Javalin v1.0 – Web Framework for Java + Kotlin
22. Function literals with receiver
23. Sealed classes: (restricted types no “else”)
24. Android Intent
The scary complex field of Math worried the mathematicians who would prove a theorem relying on the previous theorems assumed proven correct by other mathematicians.
A sad example was Zhang YiTang (1955 – ) who prepared his PhD Thesis based on a previous “flawed” Theorem proved by none other than his PhD Advisor Prof Mok in Purdue University. Unfortunately his Thesis was found wrong, and the tragic happened to Zhang as he had revealed the mistake of his PhD advisor who insisted his (Mok’s) Theorem was correct. As a result Zhang failed the 7-year PhD course without any teaching job recommendation letter from his angry advisor. He ended with a Subway Sandwich Kitchen job offered by his Chinese friend, sleeping in another Chinese music conductor’s house on a sofa. It was there he spent another 7 years thinking on Math, finally an Eureka breakthrough one 2013 morning in the backyard wild forest – the proof of the famous “70 million Prime Gap Conjecture”!
Univalent Foundation was born out of the same requirement by the (late) mathematician Vladimir Voevodsky (1966 – 2017) [#] – Use computer to prove Mathematics !
Note : [#] Vladimir Voevodsky