(** Def 5 of (Rose) *)

Definition Mod2_e : Cobham :=
  Rec
    Zero
    (False_e 2)
    (One_e 2)
    (One_e 1).

(* Specifications: *)
Lemma arity_Mod2 : arity Mod2_e = ok_arity 1.
Lemma rec_bounded_Mod2 : rec_bounded Mod2_e.
Lemma Mod2_correct : forall l, bs2nat (Sem Mod2_e l) = mod2 (bs2nat (hd nil l)).
Lemma arity_Length : arity Length_e = ok_arity 1.
Lemma rec_bounded_Length : rec_bounded Length_e.
Lemma Length_correct : forall l, bs2nat (Sem Length_e l) = length (hd nil l).
Lemma arity_MultOneMinus' : arity MultOneMinus'_e = ok_arity 2.
Lemma rec_bounded_MultOneMinus' : rec_bounded MultOneMinus'_e.
Lemma MultOneMinus'_correct : forall l, hd nil (tl l) = nil \/ bs2nat (hd nil (tl l)) <> 0 -> bs2nat (Sem MultOneMinus'_e l) = bs2nat (hd nil l) * (1 - bs2nat (hd nil (tl l))).
Lemma arity_MultOneMinus : arity MultOneMinus_e = ok_arity 2.
Lemma rec_bounded_MultOneMinus : rec_bounded MultOneMinus_e.
Lemma MultOneMinus_correct : forall l, bs2nat (Sem MultOneMinus_e l) = bs2nat (hd nil l) * (1 - bs2nat (hd nil (tl l))).
Lemma arity_PlusOneMinus' : arity PlusOneMinus'_e = ok_arity 2.
Lemma rec_bounded_PlusOneMinus' : rec_bounded PlusOneMinus'_e.
Lemma PlusOneMinus'_correct : forall l, hd nil (tl l) = nil \/ bs2nat (hd nil (tl l)) <> 0 -> bs2nat (Sem PlusOneMinus'_e l) = bs2nat (hd nil l) + (1 - bs2nat (hd nil (tl l))).
Lemma arity_PlusOneMinus : arity PlusOneMinus_e = ok_arity 2.
Lemma rec_bounded_PlusOneMinus : rec_bounded PlusOneMinus_e.
Lemma PlusOneMinus_correct : forall l, bs2nat (Sem PlusOneMinus_e l) = bs2nat (hd nil l) + (1 - bs2nat (hd nil (tl l))).
Lemma arity_OneMinusMultPlus' : arity OneMinusMultPlus'_e = ok_arity 2.
Lemma rec_bounded_OneMinusMultPlus' : rec_bounded OneMinusMultPlus'_e.
Lemma OneMinusMultPlus'_correct : forall l, hd nil l = nil \/ bs2nat (hd nil l) <> 0 -> bs2nat (Sem OneMinusMultPlus'_e l) = (1 - bs2nat (hd nil l)) * bs2nat (hd nil (tl l)) + bs2nat (hd nil l) * (1 - (1 - bs2nat (hd nil l))).
Lemma arity_OneMinusMultPlus : arity OneMinusMultPlus_e = ok_arity 2.
Lemma rec_bounded_OneMinusMultPlus : rec_bounded OneMinusMultPlus_e.
Lemma OneMinusMultPlus_correct : forall l, bs2nat (Sem OneMinusMultPlus_e l) = (1 - bs2nat (hd nil l)) * bs2nat (hd nil (tl l)) + bs2nat (hd nil l) * (1 - (1 - bs2nat (hd nil l))).
Lemma arity_PlusMod2 : arity PlusMod2_e = ok_arity 2.
Lemma rec_bounded_PlusMod2 : rec_bounded PlusMod2_e.
Lemma PlusMod2_correct : forall l, bs2nat (Sem PlusMod2_e l) = bs2nat (hd nil l) + mod2 (bs2nat (hd nil (tl l))).
Lemma arity_PlusOneMinusMod2 : arity PlusOneMinusMod2_e = ok_arity 3.
Lemma rec_bounded_PlusOneMinusMod2 : rec_bounded PlusOneMinusMod2_e.
Lemma PlusOneMinusMod2_correct : forall l, bs2nat (Sem PlusOneMinusMod2_e l) = bs2nat (hd nil l) + (1 - bs2nat (hd nil (tl l))) * mod2 (bs2nat (hd nil (tl (tl l)))).
Lemma PlusOneMinusMod2_length : forall l, length (Sem PlusOneMinusMod2_e l) <= S (length (hd nil l)).
Lemma arity_MultTwoPowerLength' : arity MultTwoPowerLength'_e = ok_arity 2.
Lemma rec_bounded_MultTwoPowerLength' : rec_bounded MultTwoPowerLength'_e.
Lemma MultTwoPowerLength'_correct : forall l, bs2nat (Sem MultTwoPowerLength'_e l) = power 2 (length (hd nil l)) * bs2nat (hd nil (tl l)).
Lemma arity_MultTwoPowerLength : arity MultTwoPowerLength_e = ok_arity 2.
Lemma rec_bounded_MultTwoPowerLength : rec_bounded MultTwoPowerLength_e.
Lemma MultTwoPowerLength_correct : forall l, bs2nat (Sem MultTwoPowerLength_e l) = bs2nat (hd nil l) * power 2 (length (hd nil (tl l))).
Lemma arity_DivTwoPower' : arity DivTwoPower'_e = ok_arity 2.
Lemma length_DivTwoPower' : forall l, length (Sem DivTwoPower'_e l) = length (hd nil (tl l)) - length (hd nil l).
Lemma rec_bounded_DivTwoPower' : rec_bounded DivTwoPower'_e.
Lemma DivTwoPower'_correct_bs : forall l, Sem DivTwoPower'_e l = fun_power (length (hd nil l)) (@tl _) (hd nil (tl l)).
Lemma DivTwoPower'_correct : forall l, bs2nat (Sem DivTwoPower'_e l) = fun_power (length (hd nil l)) div2 (bs2nat (hd nil (tl l))).
Lemma arity_DivTwoPower : arity DivTwoPower_e = ok_arity 2.
Lemma rec_bounded_DivTwoPower : rec_bounded DivTwoPower_e.
Lemma DivTwoPower_correct_bs : forall l, Sem DivTwoPower_e l = fun_power (length (hd nil (tl l))) (@tl _) (hd nil l).
Lemma length_DivTwoPower : forall l, length (Sem DivTwoPower_e l) = length (hd nil l) - length (hd nil (tl l)).
Lemma skipn_tl : forall n (l : bs), skipn (S n) l = tl (skipn n l).
Lemma DivTwoPower_correct : forall l, Sem DivTwoPower_e l = skipn (length (nth 1 l nil)) (nth 0 l nil).
Lemma arity_DivDivTwoPower : arity DivDivTwoPower_e = ok_arity 3.
Lemma rec_bounded_DivDivTwoPower : rec_bounded DivDivTwoPower_e.
Lemma DivDivTwoPower_correct : forall l, Sem DivDivTwoPower_e l = skipn (length (nth 1 l nil) - length (nth 2 l nil)) (nth 0 l nil).
Lemma arity_Repeat : forall n len b, arity (Repeat_e n len b) = ok_arity n.
Lemma rec_bounded_Repeat : forall n len b, rec_bounded (Repeat_e n len b).
Lemma length_Repeat : forall n l b l', length (Sem (Repeat_e n l b) l') = l.