Load loadpath.
Require MSets.
Require Coq.Structures.Orders.
Require Coq.Structures.OrdersFacts.
Require Recdef.
Require Omega.
Definition list_bound {A: Type} (f: A -> Prop) (l: list A):=
Forall f l /\  NoDup l.
Definition vset := Ensemble var.
Definition expr_bound (n: vset) (e: expr) :=
match e with Nil => True | Var v => n v end.
Definition pure_bound (n: vset) (a : pure_atom) :=
match a with
| Eqv e e' => expr_bound n e /\ expr_bound n e'
end.
Definition space_bound (n: vset) (a: space_atom) :=
match a with
| Next e e' =>  expr_bound n e /\ expr_bound n e'
| Lseg e e' =>  expr_bound n e /\ expr_bound n e'
end.
Definition pures_bound n := list_bound (pure_bound n).
Definition spaces_bound n := list_bound (space_bound n).
Definition pures_bound' n := Forall (pure_bound n).
Definition spaces_bound' n := Forall (space_bound n).
Definition clause_bound' (n: vset)  (cl: clause) :=
match cl with
| PureClause pi pi' _ _ =>  pures_bound' n pi /\ pures_bound' n pi'
| PosSpaceClause pi pi' sigma =>
pures_bound' n pi /\ pures_bound' n pi'/\ spaces_bound' n sigma
| NegSpaceClause pi sigma pi' =>
pures_bound' n pi /\ pures_bound' n pi'/\ spaces_bound' n sigma
end.
Definition clause_bound (n: vset)  (cl: clause) :=
match cl with
| PureClause pi pi' _ _ =>  pures_bound n pi /\ pures_bound n pi'
| PosSpaceClause pi pi' sigma =>
pures_bound n pi /\ pures_bound n pi'/\ spaces_bound n sigma
| NegSpaceClause pi sigma pi' =>
pures_bound n pi /\ pures_bound n pi'/\ spaces_bound n sigma
end.

(* Specifications: *)
Lemma expr_bound_more: forall  n n' e,
Included _ n n' -> expr_bound n e -> expr_bound n' e.
Lemma pure_bound_more:
forall n n' a, Included _ n n' -> pure_bound n a -> pure_bound n' a.
Lemma pures_bound'_more:
forall n n' gamma, Included _ n n' -> pures_bound' n gamma -> pures_bound' n' gamma.
Lemma space_bound_more:
forall n n' a, Included _ n n' -> space_bound n a -> space_bound n' a.
Lemma spaces_bound'_more:
forall n n' gamma, Included _ n n' -> spaces_bound' n gamma -> spaces_bound' n' gamma.
Lemma clause_bound'_more:
forall n n' c, Included _ n n' -> clause_bound' n c -> clause_bound' n' c.