Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. module Main
  2.  
  3. import Data.Vect
  4. import Data.Fin
  5.  
  6. %default total
  7.  
  8. find : Eq x => List x -> x -> Maybe Int
  9. find [] elem = Nothing
  10. find (y :: xs) elem = if y == elem then (Just 0) else (map (\ n => n + 1) (find xs elem))
  11.  
  12. find2 : Eq x => {n : Nat} -> Vect n x -> x -> Maybe (Fin n)
  13. find2 [] elem = Nothing
  14. find2 (y :: xs) elem = if y == elem then (Just FZ) else (map FS (find2 xs elem))
  15.  
  16. ex : find2 [1, 2, 3] 2 = Just 1
  17. ex = Refl
  18.  
  19. nothingProof : Eq x => (n : Nat) -> (v : Vect n x) -> (e : x) -> Not (Elem e v) -> (find2 v e) = Nothing
  20. nothingProof n v elem notIn = ?noIdea1
  21.  
  22. justProof : Eq x => (n : Nat) -> (v : Vect n x) -> (e : x) -> (find2 v e = Just r) -> (index r v == e) = True
  23. justProof n v elem findProof = ?noIdea2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement