Guest User

Untitled

a guest
Jul 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. inductive seq (α: Type) : Type
  2. | cons : α -> seq -> seq
  3. | nil {} : seq
  4.  
  5. open seq
  6.  
  7. def apply {α β} (f: α -> β) : seq α -> seq β
  8. | nil := nil
  9. | (cons x rst) := cons (f x) (apply rst)
  10.  
  11. theorem apply_singleton {α β} :
  12. forall (f: α -> β) (x: α),
  13. apply f (cons x nil) = cons (f x) nil :=
  14. begin
  15. intros,
  16. refl,
  17. end
  18.  
  19. def size {α: Type} : seq α -> nat
  20. | nil := 0
  21. | (cons _ rst) := size rst + 1
  22.  
  23. def head {α} (l: seq α) : (0 < size l) -> α :=
  24. begin
  25. intro H,
  26. induction l with x rst,
  27. case seq.cons { exact x },
  28. case seq.nil { unfold size at H, exfalso, cases H }
  29. end
Add Comment
Please, Sign In to add comment