ATBR.Common
(**************************************************************************)
(* This is part of ATBR, it is distributed under the terms of the *)
(* GNU Lesser General Public License version 3 *)
(* (see file LICENSE for more details) *)
(* *)
(* Copyright 2009-2011: Thomas Braibant, Damien Pous. *)
(**************************************************************************)
(* This is part of ATBR, it is distributed under the terms of the *)
(* GNU Lesser General Public License version 3 *)
(* (see file LICENSE for more details) *)
(* *)
(* Copyright 2009-2011: Thomas Braibant, Damien Pous. *)
(**************************************************************************)
This small module is imported in all our files, it exports useful
modules and defines some basic utilities and tactics
Require Export Arith.
Require Export Omega.
Require Export Coq.Program.Equality.
Require Export Setoid Morphisms.
Set Implicit Arguments.
Bind Scope nat_scope with nat.
Functional composition
Definition comp A B C (f: A -> B) (g: B -> C) := fun x => g (f x).
Notation "f >> g" := (comp f g) (at level 50).
Notation "f >> g" := (comp f g) (at level 50).
This lemma is useful when applied in hypotyheses (apply apply in H makes it possible to specialize
an hypothesis H by generating the corresponding subgoals)
Tactics to resolve a goal by using a contradiction in the hypotheses, using either omega or tauto
Ltac omega_false := exfalso; omega.
Ltac tauto_false := exfalso; tauto.
Ltac tauto_false := exfalso; tauto.
This destructor sometimes works better that the standard destruct
Ltac idestruct H :=
let H' := fresh in generalize H; intro H'; destruct H'.
let H' := fresh in generalize H; intro H'; destruct H'.
For debugging
Ltac print_goal := match goal with |- ?x => idtac x end.
This tactic allows one to infere maximally implicit arguments that failed to be inferred and were
replaced by sub-goals
Ltac ti_auto := eauto with typeclass_instances.
The following databases are used all along the library:
- <compat> contains most "compatibility with equality" and "monotonicity" lemmas: Morphisms with respects to
- <simpl> is a rewriting database, to be used with the rsimpl tactic. It contains lemmas like 1*x == x
- <omega> contains hints to use omega when proof search failed ; this basically allows us to avoid
Create HintDb compat discriminated.
Create HintDb algebra discriminated.
Ltac rsimpl := simpl; autorewrite with simpl using ti_auto.
Hint Extern 9 (@eq nat ?x ?y) => instantiate; abstract omega: omega.
Hint Extern 9 (Peano.le ?x ?y) => instantiate; abstract omega: omega.
Hint Extern 9 (Peano.lt ?x ?y) => instantiate; abstract omega: omega.
Create HintDb algebra discriminated.
Ltac rsimpl := simpl; autorewrite with simpl using ti_auto.
Hint Extern 9 (@eq nat ?x ?y) => instantiate; abstract omega: omega.
Hint Extern 9 (Peano.le ?x ?y) => instantiate; abstract omega: omega.
Hint Extern 9 (Peano.lt ?x ?y) => instantiate; abstract omega: omega.
Tactic to use when apply does not smartly unify
Ltac rapply H := first
[ refine H
| refine (H _)
| refine (H _ _)
| refine (H _ _ _)
| refine (H _ _ _ _)
| refine (H _ _ _ _ _)
| refine (H _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _ _ _ _ _)
| fail 1 "extend rapply"
].
[ refine H
| refine (H _)
| refine (H _ _)
| refine (H _ _ _)
| refine (H _ _ _ _)
| refine (H _ _ _ _ _)
| refine (H _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _ _ _ _)
| refine (H _ _ _ _ _ _ _ _ _ _ _ _)
| fail 1 "extend rapply"
].