Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. Require Import List.
  3. Parameter A : Set.
  4. Parameter B : Set.
  5. Definition assoc_list := list (A * B)%type.
  6. Parameter eq_dec : forall (x:A) (y:A),{x=y}+{x<>y}.
  7.  
  8. Lemma assoc : forall (x:A) (l: assoc_list),
  9. {y | In (x,y) l} + {forall (y:B), ~In (x,y) l}.
  10. Proof.
  11. intros x l. induction l.
  12. (* nil *)
  13. right. auto.
  14. (* cons *)
  15. case (eq_dec x (fst a)).
  16. (* x = fst p *)
  17. intros eq.
  18. left. exists (snd a). rewrite eq.
  19. case a. firstorder.
  20. (* x <> fst a *)
  21. intros neq.
  22. case IHl.
  23. (* subcase left *)
  24. intro leftcase.
  25. left. inversion leftcase. exists x0.
  26. apply or_intror. auto.
  27. (* subcase right *)
  28. intro rightcase.
  29. right.
  30. intros y NotIn.
  31. apply (rightcase y).
  32. inversion NotIn ; auto.
  33. rewrite H in neq.
  34. contradiction neq. auto.
  35. Defined.
  36.  
  37. Extraction assoc.
  38. Print assoc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement