meeting_050901 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. Inductive families and pattern matching
  2. Pattern matching only if we can figure out which constructors are
  3. allowed (by first order unification).
  4. Meaning constructor targets and scrutinee should be indexed by
  5. constructor patterns.
  6. Allow repeated variables in patterns as long as the type checker can
  7. figure out that they have to be equal anyway.
  8. No: Force the user call equal things by the same name.
  9. Not allowed:
  10. f : (n : Nat) -> Vec A n -> ...
  11. f n (cons m x xs) = ...
  12. Allowed
  13. f (s m) (cons m x xs) = ...
  14. Issues: what about (m is hidden)
  15. f n (x::xs) = ...
  16. Not allowed.
  17. When can we translate to Core?
  18. Completeness: the dot notation
  19. f 0 tt = e
  20. f (s n) .
  21. You can leave out clauses if the missing cases immediately lead to an
  22. empty type.
  23. -- corresponds to pattern matching on the Even
  24. f : (n : Nat) -> Even n -> X
  25. f 0 even0 = a
  26. -- missing case for (s 0). Even (s 0) is decidably empty.
  27. f (s (s n)) (evenSS n) = b
  28. -- pattern matching on the number and then the Even
  29. f 0 even0 = a
  30. f (s 0) .
  31. f (s (s n)) (evenSS n) = b
  32. vim: sts=2 sw=2 tw=75