/meta/metatheory/LibLNgen.v

http://replib.googlecode.com/ · V · 138 lines · 105 code · 33 blank · 0 comment · 2 complexity · 3919e31707bc10f2299b4c6020e83be6 MD5 · raw file

  1. (* This file is distributed under the terms of the MIT License, also
  2. known as the X11 Licence. A copy of this license is in the README
  3. file that accompanied the original distribution of this file.
  4. Based on code written by:
  5. Brian Aydemir *)
  6. (** A library of code for supporting LNgen. *)
  7. Require Export LibDefaultSimp.
  8. Require Import Metatheory.
  9. (* ********************************************************************** *)
  10. (** * Assorted functions not in the standard library *)
  11. (** [lt_ge_dec] is a useful comparison operation when defining the
  12. "close" operation on locally nameless terms. *)
  13. Definition lt_ge_dec (n m : nat) : {n < m} + {n >= m} :=
  14. match Compare_dec.le_gt_dec m n with
  15. | left pf => right pf
  16. | right pf => left pf
  17. end.
  18. (* *********************************************************************** *)
  19. (** * Tactics *)
  20. (** [generalize_wrt x] is an ad hoc tactic that generalizes the goal
  21. with respect to everything that [x] does not depend on. It seems
  22. to work only if [x] is the most recently introduced item into the
  23. context. *)
  24. Ltac generalize_wrt x :=
  25. repeat (progress (match goal with
  26. | J : _ |- _ => move J after x; generalize dependent J
  27. end)).
  28. (** [apply_mutual_ind] applies to the current goal a mutual induction
  29. principle that is stated in the form generated by [Combined
  30. Scheme]. It works even in degenerate cases, i.e., when there is
  31. no mutual induction, only simple induction. It is intended to be
  32. used only at the start of a proof, and the argument(s) to induct
  33. over should come first. *)
  34. Ltac apply_mutual_ind ind :=
  35. let H := fresh in
  36. first [ apply ind
  37. | intros H; induction H using ind
  38. | intros ? H; induction H using ind
  39. | intros ? ? H; induction H using ind
  40. | intros ? ? ? H; induction H using ind
  41. | intros ? ? ? ? H; induction H using ind
  42. | intros ? ? ? ? ? H; induction H using ind
  43. | intros ? ? ? ? ? ? H; induction H using ind
  44. | intros ? ? ? ? ? ? ? H; induction H using ind
  45. | intros ? ? ? ? ? ? ? ? H; induction H using ind
  46. ].
  47. (** Renames the last hypothesis to the given identifier. *)
  48. Ltac rename_last_into H :=
  49. match goal with
  50. | J : _ |- _ => rename J into H
  51. end.
  52. (** Specializes every possible hypothesis with the given term. *)
  53. Ltac specialize_all x :=
  54. repeat (match goal with
  55. | H : _ |- _ => specialize (H x)
  56. end).
  57. (* *********************************************************************** *)
  58. (** * Facts about finite sets *)
  59. Lemma remove_union_distrib : forall (s1 s2 : atoms) (x : atom),
  60. remove x (union s1 s2) [=] union (remove x s1) (remove x s2).
  61. Proof. fsetdec. Qed.
  62. Lemma Equal_union_compat : forall (s1 s2 s3 s4 : atoms),
  63. s1 [=] s3 ->
  64. s2 [=] s4 ->
  65. union s1 s2 [=] union s3 s4.
  66. Proof. fsetdec. Qed.
  67. Lemma Subset_refl : forall (s : atoms),
  68. s [<=] s.
  69. Proof. fsetdec. Qed.
  70. Lemma Subset_empty_any : forall (s : atoms),
  71. empty [<=] s.
  72. Proof. fsetdec. Qed.
  73. Lemma Subset_union_compat : forall (s1 s2 s3 s4 : atoms),
  74. s1 [<=] s3 ->
  75. s2 [<=] s4 ->
  76. union s1 s2 [<=] union s3 s4.
  77. Proof. fsetdec. Qed.
  78. Lemma Subset_union_left : forall (s1 s2 s3 : atoms),
  79. s1 [<=] s2 ->
  80. s1 [<=] union s2 s3.
  81. Proof. fsetdec. Qed.
  82. Lemma Subset_union_right : forall (s1 s2 s3 : atoms),
  83. s1 [<=] s3 ->
  84. s1 [<=] union s2 s3.
  85. Proof. fsetdec. Qed.
  86. Lemma Subset_union_lngen_open_upper :
  87. forall (s1 s2 s3 s4 s5 : atoms),
  88. s1 [<=] union s3 s4 ->
  89. s2 [<=] union s3 s5 ->
  90. union s1 s2 [<=] union s3 (union s4 s5).
  91. Proof. fsetdec. Qed.
  92. (* *********************************************************************** *)
  93. (** * Hints *)
  94. Hint Resolve sym_eq : brute_force.
  95. Hint Extern 5 (_ = _ :> nat) => omega : brute_force.
  96. Hint Extern 5 (_ < _) => omega : brute_force.
  97. Hint Extern 5 (_ <= _) => omega : brute_force.
  98. Hint Rewrite @remove_union_distrib : lngen.
  99. Hint Resolve @Equal_union_compat : lngen.
  100. Hint Resolve @Subset_refl : lngen.
  101. Hint Resolve @Subset_empty_any : lngen.
  102. Hint Resolve @Subset_union_compat : lngen.
  103. Hint Resolve @Subset_union_left : lngen.
  104. Hint Resolve @Subset_union_right : lngen.
  105. Hint Resolve @Subset_union_lngen_open_upper : lngen.