Successfully reported this slideshow.
Upcoming SlideShare
×

# Keynote, Lambdaconf 2016 - Equality is Hard

1,418 views

Published on

Equality (in the sense of "when is one thing equal to another thing") is hard. Some comments about that.

Published in: Software
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### Keynote, Lambdaconf 2016 - Equality is Hard

1. 1. Equality is Hard paul phillips lambdaconf 2016
2. 2. Too hard. It's not even 10AM.
3. 3. If A = B, does F[A] = F[B] ? • A ma&er of overriding interest to func4onal programmers • Subs4tu4on is the founda4on of equa4onal reasoning • Without subs4tu4on, we are lost
4. 4. Boolean values in a nutshell
5. 5. The meaning of a ques/on is the method of answering it. Tell me how you are searching, and I will tell you what you are searching for.
6. 6. Two possible truth values? "Are you s*ll abusing animals?" "This statement is false." "The program will halt."
7. 7. • I don't know. • I don't know yet. • I forgot. • Pre2y sure. • Doub7ul. • The ques<on is nonsense.
8. 8. Category Theory in a nutshell
9. 9. It depends on what the meaning of the word 'is' is.
10. 10. Classical logic in a nutshell
11. 11. Two truth values ought to be enough for anybody.
12. 12. Nega%on: not without its problems Classical logic: p <=> !!p Intuitionist: p => !!p Paraconsistent: p <= !!p Intui&onist: even if p is not false, that doesn't make it true Paraconsistent: even if p is true, that doesn't mean it isn't false
13. 13. Is nega(on inver(ble? • He's certainly a/rac0ve. • He's certainly una/rac0ve. • He's certainly not una/rac0ve...
14. 14. Is nega(on inver(ble? • The boss has accepted my plan. • The boss has rejected my plan. • The boss has not rejected my plan.
15. 15. Is nega(on inver(ble? • There is evidence he is at fault. • There is no evidence he is at fault. • There is no evidence he is not at fault.
16. 16. I'm exploi+ng natural language. Maybe it's chea-ng. But what do Boolean values encode?
17. 17. Taking the principle of excluded middle from the mathema5cian would be like proscribing the boxer the use of his ﬁsts.
18. 18. Object-oriented equality in a nutshell
19. 19. All instances are equal, but some instances are more equal than others.
20. 20. Equality depends desperately on symmetry. Um. trait Any { def ==(x: Any): Bool def !=(x: Any): Bool = !(this == x) } trait AnyRef extends Any { def eq(x: AnyRef): Bool def ne(x: AnyRef): Bool = !(this eq x) }
21. 21. Floa%ng point equality in a nutshell
22. 22. The worst form of inequality is to try to make unequal things equal.
23. 23. FP equality is ﬁsh in a barrel, sure. Why then is it s*ll to be found?
24. 24. def s1(n: Int) = 0.1 * n def s2(n: Int) = Stream continually 0.1 take n reduceLeft (_ + _) def s3(n: Int) = BigDecimal("0." + n) 1 to 9 map (n => Seq( s1(n) == s2(n), s2(n) == s3(n), s3(n) == s1(n) ))
25. 25. TTT TTT TFF TTT TTT FTF FTF FFT FFT
26. 26. TTT TTT TFF TTT TTT FTF FTF FFT FFT
27. 27. Booleans without totality in a nutshell
28. 28. He said to his friend, "If the Bri2sh march By land or sea from the town to-night, Hang a lantern alo+ in the belfry arch Of the North Church tower as a signal light, Zero if by land, and one if by sea; And I on the opposite shore will be...
29. 29. Overspeciﬁca+on in a nutshell
30. 30. The diﬃculty in philosophy is to say no more than we know.
31. 31. We habitually work with values which convey total certainty boiled down to a single bit. Is this the most robust approach?
32. 32. A typical scala compiler method. def isMethodWithExtension = ( isMethod && owner.isDerivedValueClass && !isParamAccessor && !isConstructor && !hasFlag(SUPERACCESSOR) && !isMacro && !isSpecialized )
33. 33. ex falso quodlibet in a nutshell
34. 34. You get tragedy where the tree, instead of bending, breaks.
35. 35. The principle of explosion Rejected by paraconsistent "inconsistency tolerant" logics
36. 36. You can have it all True or False? Why stop at one?
37. 37. Logic is a system for preserving some property across logical opera3ons. • Classical logic: truth • Intui0onist logic: jus'ﬁca'on • Probability logic: likelihood
38. 38. Laws to consider repealing • Law of non-contradic/on: !(p && !p) "Contradictory statements cannot both be true." • Law of the excluded middle: p || !p "Either a proposi/on is true or its nega/on is true."
39. 39. Ari\$es of truthiness. _0 = Void // The void stares back at you _1 = Unit // Indifference logic _2 = Bool // You Are Here _3 = Opt[Bool] // billion dollar mistake? _4 = Bool x Bool // Is it true? Y/N Is it false? Y/N R = [0,1) // Fuzzy, possibility, probability logics
40. 40. Setoids In a nutshell
41. 41. Whereof one cannot speak, thereof one must be silent.
42. 42. A setoid is a set equipped with an equivalence rela1on. A construc(ve setoid is equipped with an apartness rela1on.
43. 43. Boolean Blindness To make use of a Boolean you have to know its provenance so that you can know what it means.
44. 44. Haskell class Eq a where (==) :: a -> a -> Bool
45. 45. I know, "performance" data Compared a = Equal a a | DisEqual a a | Incomparable class Eq a where (==) :: a -> a -> Compared a
46. 46. Laws: do not confuse with fallacies
47. 47. PhilosphyProgramming is a ba0le against the bewitchment of our intelligence by means of our language.
48. 48. The purpose of abstrac/on is not to be vague, but to create a new seman/c level in which one can be absolutely precise.
49. 49. The real founda-ons of his enquiry do not strike a man at all. Unless that fact has at some -me struck him.
50. 50. [Wi\$genstein] says every morning he begins his work with hope, and every evening he ends in despair.
51. 51. If a lion could talk, we could not understand him.
52. 52. If you want to learn more about the law of the excluded middle, take a voyage down to your public library. It's all in books!