Library DeltaList: lists of natural numbers with constrained differences


Require Import Arith Omega Wf_nat List.
Import ListNotations.
Set Implicit Arguments.

Increasing lists

Delta p l means that consecutives values in the list l have differences of at least p.

Inductive Delta (p:nat) : list natProp :=
  | Dnil : Delta p []
  | Done n : Delta p [n]
  | Dcons n m l : m+p nDelta p (n::l) → Delta p (m::n::l).
Hint Constructors Delta.

In particular:
  • Delta 0 l means that l is increasing
  • Delta 1 l means that l is stricly increasing
  • Delta 2 l implies in addition that no consecutive numbers can occur in l.

Lemma Delta_alt p x l :
 Delta p (x::l) Delta p l ( y, In y lx+p y).

Lemma Delta_inv p x l : Delta p (x::l) → Delta p l.

Lemma Delta_more l p : p Delta lDelta p l.

Lemma Delta_21 l : Delta 2 lDelta 1 l.

Lemma Delta_nz p k l : 0<kDelta p (k::l) → ¬In 0 (k::l).
Hint Resolve Delta_21 Delta_inv Delta_nz.

Lemma Delta_low_hd p k l :
 kDelta p (k::l) → Delta p (::l).

Lemma Delta_21_S x l : Delta 2 (x::l) → Delta 1 (S x::l).
Hint Resolve Delta_21_S.

Lemma Delta_map p f l :
  ( x y, x+p yf x + f y) →
  Delta p lDelta (map f l).

Lemma Delta_pred p l :
 ¬In 0 lDelta p lDelta p (map pred l).


Lemma Delta_seq n k : Delta 1 (seq n k).

Lemma Delta_app p x l :
  Delta p lDelta p (x::) →
  ( y, In y ly x) → Delta p (l++).

Lemma Delta_app_inv p l :
 Delta p (l++) →
 Delta p l Delta p
  x , In x lIn x+p .

Decreasing lists

DeltaRev p l is Delta p (rev l) : it considers differences in the reversed order, leading to decreasing lists

Inductive DeltaRev (p:nat) : list natProp :=
  | DRnil : DeltaRev p []
  | DRone n : DeltaRev p [n]
  | DRcons n m l : n+p mDeltaRev p (n::l) → DeltaRev p (m::n::l).
Hint Constructors DeltaRev.

Lemma DeltaRev_alt p x l :
 DeltaRev p (x::l) DeltaRev p l ( y, In y ly+p x).

Lemma DeltaRev_app p x l :
  DeltaRev p lDeltaRev p (x::) →
  ( y, In y lx y) → DeltaRev p (l++).

Lemma DeltaRev_app_inv p l :
 DeltaRev p (l++) →
 DeltaRev p l DeltaRev p
  x , In x lIn +p x.

Lemma Delta_rev p l : Delta p (rev l) DeltaRev p l.

Lemma DeltaRev_rev p l : DeltaRev p (rev l) Delta p l.