Fixpoint count_undecs (n : nested_imps) : nat :=
  match n with
  | nil => 0
  | Undecorated _ :: n => S (count_undecs n)
  | Decorated _ _ :: n => count_undecs n
  end.Inductive Lt_Ks (ni1 : nested_imps) (dni1 : decorated_nested_imps)
(ni2 : nested_imps) (dni2 : decorated_nested_imps) : Set :=
  | lt_ks_count_undecs :
      le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) ->
      count_undecs ni1 < count_undecs ni2 -> Lt_Ks ni1 dni1 ni2 dni2
  | lt_ks_length :
      le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) ->
      length ni1 < length ni2 -> Lt_Ks ni1 dni1 ni2 dni2.Inductive Lt_Ks (ni1 : nested_imps) (dni1 : decorated_nested_imps)
(ni2 : nested_imps) (dni2 : decorated_nested_imps) : Set :=
  | lt_ks_count_undecs :
      le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) ->
      count_undecs ni1 < count_undecs ni2 -> Lt_Ks ni1 dni1 ni2 dni2
  | lt_ks_length :
      le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) ->
      length ni1 < length ni2 -> Lt_Ks ni1 dni1 ni2 dni2.Inductive Lt_Ks (ni1 : nested_imps) (dni1 : decorated_nested_imps)
(ni2 : nested_imps) (dni2 : decorated_nested_imps) : Set :=
  | lt_ks_count_undecs :
      le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) ->
      count_undecs ni1 < count_undecs ni2 -> Lt_Ks ni1 dni1 ni2 dni2
  | lt_ks_length :
      le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) ->
      length ni1 < length ni2 -> Lt_Ks ni1 dni1 ni2 dni2.

(* Specifications: *)
Lemma le_ni_le_count_undecs : forall ni1 ni2 : nested_imps, le_ni ni1 ni2 -> count_undecs ni1 <= count_undecs ni2.
Lemma count_undecs_rev_app : forall (dni : decorated_nested_imps) (ni : nested_imps), count_undecs (rev_app dni ni) = count_undecs ni.
Lemma le_ks_le_count_undecs : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (ni2 : nested_imps) (dni2 : decorated_nested_imps), le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) -> count_undecs ni1 <= count_undecs ni2.
Lemma My_Lt_Ks_rec : forall P : nested_imps -> Set, (forall (ni2 : nested_imps) (dni2 : decorated_nested_imps), (forall (ni1 : nested_imps) (dni1 : decorated_nested_imps), Lt_Ks ni1 dni1 ni2 dni2 -> P (rev_app dni1 ni1)) -> P (rev_app dni2 ni2)) -> forall ni : nested_imps, P ni.
Lemma lt_ks_shift_nd : forall (ni ni1 : nested_imps) (dni dni1 : decorated_nested_imps) (x : nimp) (k : kripke_tree), le_ni (rev_app dni1 ni1) (rev_app ((x, k) :: dni) ni) -> Lt_Ks ni1 dni1 (Undecorated x :: ni) dni.
Lemma lt_ks_shift_dd : forall (ni : nested_imps) (dni : decorated_nested_imps) (x : nimp) (k : kripke_tree), Lt_Ks ni ((x, k) :: dni) (Decorated x k :: ni) dni.