stop thinking about bottoms when writing programs
play

Stop thinking about bottoms when writing programs . . . Thorsten - PowerPoint PPT Presentation

Stop thinking about bottoms when writing programs . . . Thorsten Altenkirch University of Nottingham BCTCS 06 p.1/19 Trouble with BCTCS 06 p.2/19


  1. Stop thinking about bottoms when writing programs . . . Thorsten Altenkirch University of Nottingham BCTCS 06 – p.1/19

  2. Trouble with BCTCS 06 – p.2/19

  3. ✟ � ✁ ✠ ✟ ✞ ✁ ✂ ☞ ☛ ✞ ✝ ✞ ☛ ✁ ✝ ☎ ✆ ☎ ✆ ☎ ✄ ✄ ✂ ✁ ✞ Trouble with �✡✠ BCTCS 06 – p.2/19

  4. BCTCS 06 – p.2/19 ✞ ✞ ✟ ✠ ✁ ✞ ☛ ✌ ✂ ✁ ✍ ✟ ✍ ✁ ✌ ✎ ✁ ☞ � ☎ ✁ ✂ ✄ ✄ ☎ ✆ ✆ ☛ ☎ ✝ ✁ ✞ ✟ ✝ Trouble with �✡✠

  5. BCTCS 06 – p.2/19 ✎ ☛ ✞ ✌ ✁ ✍ ✟ ✍ ✁ ✌ ✝ � ✁ ✏ ✟ ✝ ✏ ✁ ✝ ✟ ✏ ✞ ✁ ✠ ✁ ✄ ☎ ✆ ☎ ✆ ☎ ✝ ✟ ✞ ✂ ✟ ✝ ✁ ☛ ☞ ✂ ✁ ✞ ✄ Trouble with No, because �✡✠

  6. Trouble with . . . BCTCS 06 – p.3/19

  7. ✑ Trouble with . . . Many useful algebraic properties do not hold. BCTCS 06 – p.3/19

  8. ✑ ✑ ✏ Trouble with . . . Many useful algebraic properties do not hold. Correctness proofs get obliterated with reasoning about . BCTCS 06 – p.3/19

  9. ✑ ✑ ✏ ✑ Trouble with . . . Many useful algebraic properties do not hold. Correctness proofs get obliterated with reasoning about . Do we actually care about non-terminating programs? BCTCS 06 – p.3/19

  10. ✑ ✑ ✏ ✑ ✑ Trouble with . . . Many useful algebraic properties do not hold. Correctness proofs get obliterated with reasoning about . Do we actually care about non-terminating programs? Programs are not natural phenomena. . . BCTCS 06 – p.3/19

  11. ✑ ✑ ✏ ✑ ✑ ✑ Trouble with . . . Many useful algebraic properties do not hold. Correctness proofs get obliterated with reasoning about . Do we actually care about non-terminating programs? Programs are not natural phenomena. . . Programs are constructed ! BCTCS 06 – p.3/19

  12. Do we need to be lazy? BCTCS 06 – p.4/19

  13. ✟ ✞ � ✠ ✕ ✓ ✒ � ✄ ✞ ☞ ✠ ☛ ✂ ✗ ☎ ✖ ✆ ☎ ✄ ✄ ✠ ✂ ✞ Do we need to be lazy? ✒✔✓✕ ✒✔✓✕ BCTCS 06 – p.4/19

  14. � ✂ ✠ ✘ ✞ ☛ ☞ ✂ ✑ ✓ ☛ ✠ ☞ ✖ ✘ ✗ ✕ ✒ ✙ ✖ ✚ ✠ ✄ ✄ ☎ ✆ ☎ � ✗ ✢ ✠ ✞ ✟ ✞ ✄ ✟ Do we need to be lazy? ✒✔✓✕ ✒✔✓✕ is total, if we interpret lists as a terminal coalgebra. ✒✔✓✕ ✚✜✛ BCTCS 06 – p.4/19

  15. data vs codata BCTCS 06 – p.5/19

  16. ✲ ✩ ✣✤ ✣✤ ✣ ✞ ✥ ✣ ✞ ✦ ✧ ★ � ✄ ✟ ✩✳ ✂ ✟ ✴ � ✣ ✤ ✣ ✞ ✥ ✣ ✞ ★ ✗ ✧ ✗ ✣ ✞ ✥ ✣ ✞ ✦ ✧ ★ ✄ ✄ ✂ ✆ ✖ ✞ ✫ ✭ ✣✤ ✣ ✞ ✥ ✣ ✞ ✦ ✧ ★ ✦ data vs codata ✖✡✩ ✪✬✫ ✮✰✯✱ BCTCS 06 – p.5/19

  17. BCTCS 06 – p.5/19 ✟ ✞ ✣ ✤ ✣ � ✴ ✂ ✣ ✩✳ ✄ ✩ � ★ ✧ ✥ ✞ ✣✤ ✞ ★ ✧ ✦ ✞ ✣ ✥ ✣ ✦ ✤ ✣ ✑ ✂ ✞ ★ ✧ ✦ ✞ ✣ ✥ ✣ ✞ ✥ ✣ ✞ ✦ ✧ ★ ✄ ✄ ✗ ✆ ✫ ✭ ✣✤ ✣ ✞ ✞ ✣ ✣✤ ✲ ✟ ✗ ✖ ★ ✧ ✦ ✞ ✣ ✥ ✮✰✯✱ is total, . . . data vs codata ✪✬✫ ✖✡✩

  18. BCTCS 06 – p.5/19 ✣ ✑ ✂ ✞ ★ ✧ ✦ ✞ ✥ ✤ ✞ ✣ ✤ ✣ � ✴ ✟ ✂ ✣ ✣ ✣✤ ✗ ✚ ✢ ✘ ☛ ☞ ✵ ✟ ✘ ✞ ✖ ✑ ★ ✧ ✦ ✞ ✣ ✥ ✩✳ ✄ ✩ ✄ ✣ ✣✤ ✭ ✫ ✆ ✗ ✄ ★ ✥ ✧ ✦ ✞ ✣ ✥ ✞ ✣ � ✞ ✣ ✦ ✞ ✣ ✣✤ ✲ ✞ ✞ ✧ ✣ ✟ ★ ✗ ✖ ★ ✧ ✦ ✥ if we interpret lists as initial algebra: ✚✜✛ ✮✰✯✱ is total, . . . data vs codata ✪✬✫ ✖✡✩

  19. BCTCS 06 – p.5/19 ✥ ✟ ✗ ✘ ✖ ✑ ★ ✧ ✦ ✞ ✣ ✞ ☞ ✣ ✤ ✣ ✑ ✂ ✞ ★ ✧ ✦ ✞ ✵ ☛ ✥ ✧ ✏ ✟ ✂ ✝ ✠ ✕ ✓ ✒ � ★ ✦ ✘ ✞ ✣ ✥ ✞ ✣ ✤ ✣ ✑ ✚ ✢ ✣✤ ✣ ✞ ✞ ✖ ✣ ★ ✧ ✦ ✞ ✣ ✥ ✥ ✣ ✟ ✣✤ ✭ ✫ ✣ ✆ ✗ ✞ ✄ ✄ ★ ✗ ✞ ✦ � ✤ ✣ � ✴ ✟ ✂ ✩✳ ✄ ✩ ★ ✲ ✧ ✦ ✞ ✣ ✥ ✞ ✣ ✣ ✣✤ ✧ if we interpret lists as initial algebra: ✚✜✛ ✮✰✯✱ is total, . . . data vs codata ✪✬✫ ✖✡✩ Problem:

  20. data vs codata BCTCS 06 – p.6/19

  21. ✟ ✄ ✗ ✩ ✸ ✷ ✖ ✗ ✑ ✖ ✗✹ ✩ data vs codata Finite lists ✖✡✩ ✶✰✷ BCTCS 06 – p.6/19

  22. ✺ ✗ ✟ ✩ ✼ ✗ ✩ ✷ ✸ ✄ ✫ ✑ ✖ ✑ ✩ ✗✹ ✖ ✄ ✩ ✗✹ ✖ ✟ ✗ ✻ ✷ ✸ ✗ ✼ ✖ data vs codata Finite lists ✖✡✩ ✶✰✷ Potentially infinite lists: ✖✡✻ ✶✰✷ BCTCS 06 – p.6/19

  23. ✗ ✖ ✖ ✻ ✑ ✼ ✑ ✩ ✖ ✠ ✄ ✄ ☎ ✆ ✻ ✩ ✗ ✼ ✣ ✤ ✣ ✞ ✥ ✣ ✞ ✦ ✧ ★ ✄ ✗✹ ✄ ✩ ✭ ✫ ✸ ✷ ✫ ✗ ✟ ✖ ✗✹ ✩ ✄ ✖ ✗ ✖ ✑ ✪ ✺ ✫ ✆ ✸ ✷ ✗ ✗ ✼ ✩ ✟ ✄ data vs codata Finite lists ✖✡✩ ✶✰✷ Potentially infinite lists: ✖✡✻ ✶✰✷ Better types ✒✔✓✕ BCTCS 06 – p.6/19

  24. BCTCS 06 – p.6/19 ✦ ✗ ✩ ✖ ✄ ✄ ★ ✧ ✞ ✪ ✣ ✥ ✞ ✣ ✤ ✣ ✼ ✗ ✆ ✫ ✖ ✦ ✂ ✝ ✠ ✓✕ ✒ � ★ ✧ ✞ ✫ ✣ ✥ ✞ ✣ ✤ ✣ ✑ ✭ ✻ ✆ ✑ ✖ ☎ ✫ ✺ ✑ ✗ ✩ ✄ ✗ ✩ ✗✹ ✖ ✟ ✗ ✷ ✸ ✷ ✸ ✼ ✖ ✄ ✄ ✠ ✑ ✼ ✻ ✗ ✄ ✩ ✗✹ ✖ ✟ ✩ doesn’t typecheck. Potentially infinite lists: data vs codata ✖✡✻ ✖✡✩ Better types Finite lists ✶✰✷ ✒✔✓✕ ✶✰✷

  25. Can we always avoid ? BCTCS 06 – p.7/19

  26. BCTCS 06 – p.7/19 ❁ ❂ ❁ ✂ ✧ ❁ ✄ ✿ � ✧ ❁ ✄ ✿ ✟ ✧ ✿ � ❀ ✟ ❀ ✄ ❁ ✧ � ✄ ✧ ❁ ✧ ✂ ❁ ❂ ✟ ✟ ✿ ❁ ✂ ✂ ✤ ❁ ❂ � ❁ ✂ ✤ ❁ ✧ � ✟ ✤ ❁ ❂ ✄ � ❁ ✧ ✂ ✄ ❁ ❂ � ❁ ✿ ✄ ❁ ✧ ✂ ✄ ✧ ❀ ✟ ✄ ❀ ✒ ✞ ✿ ✟ ✿ ✒ ✞ ✾ ✽ ✆ ✾ ✽ ✄ ❀ ✒ ✞ ✾ ✽ ❁ ✄ ✾ ✽ ✹ ❀ ✹ ✿ ✟ ✾ ✾ ✞ ✷ ❂ ✽ ✆ ✾ ✽ ✆ ✾ ✽ ✄ ✄ ✂ ❁ � ✂ ✒ ✒ ✞ � ❁ ✂ ✧ ✒ ✞ � ✟ ✂ ✸ ✄ ✧ � ✽ ? Can we always avoid ❁✔❂ ✶✰✷

  27. Computational Reals BCTCS 06 – p.8/19

  28. ✑ ❃ Computational Reals Define computational reals ( ) using Cauchy sequences. BCTCS 06 – p.8/19

  29. ✳ ❃ ✭ ❃ ✫ ✑ ✆ ❄ ✕ ✑ ✄ ✄ Computational Reals Define computational reals ( ) using Cauchy sequences. We cannot implement ✪✬✫ BCTCS 06 – p.8/19

  30. ✆ ✳ ✫ ❃ ✑ ❃ ✄ ✄ ✕ ✑ ❄ ✆ ✑ ✫ ❃ ✭ ✭ Computational Reals Define computational reals ( ) using Cauchy sequences. We cannot implement ✪✬✫ Indeed, all total computable functions of type are ✪✬✫ constant (Brouwer). BCTCS 06 – p.8/19

  31. ✑ ✄ ❃ ✭ ✑ ✭ ✫ ✑ ✆ ❃ ✄ ✫ ✳ ✕ ❄ ❄ ✑ ✕ ❃ ✳ ✆ Computational Reals Define computational reals ( ) using Cauchy sequences. We cannot implement ✪✬✫ Indeed, all total computable functions of type are ✪✬✫ constant (Brouwer). However, there are perfectly reasonable partial implementations of . BCTCS 06 – p.8/19

  32. We need for: BCTCS 06 – p.9/19

  33. ✑ We need for: Interpreters. BCTCS 06 – p.9/19

  34. ✑ ✑ ❃ We need for: Interpreters. Functions on . BCTCS 06 – p.9/19

  35. ✑ ✑ ❃ ✑ We need for: Interpreters. Functions on . more examples ? BCTCS 06 – p.9/19

  36. Epigram BCTCS 06 – p.10/19

  37. ✑ Epigram Epigram is a dependently typed programming language... BCTCS 06 – p.10/19

  38. ✑ ✑ ✏ Epigram Epigram is a dependently typed programming language... All Epigram programs are total (i.e. no ). BCTCS 06 – p.10/19

  39. ✑ ✑ ✏ ✑ Epigram Epigram is a dependently typed programming language... All Epigram programs are total (i.e. no ). It is not a programming language in Peter Mosses sense. BCTCS 06 – p.10/19

  40. ✑ ✑ ✏ ✑ ✑ Epigram Epigram is a dependently typed programming language... All Epigram programs are total (i.e. no ). It is not a programming language in Peter Mosses sense. because not all computable functions can be expressed. BCTCS 06 – p.10/19

  41. ✑ ✑ ✏ ✑ ✑ ✑ Epigram Epigram is a dependently typed programming language... All Epigram programs are total (i.e. no ). It is not a programming language in Peter Mosses sense. because not all computable functions can be expressed. I am going to show how we can fix this. . . BCTCS 06 – p.10/19

Recommend


More recommend