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