Section generation.
Variable gamma : strategy.
Variable log2_r : forall n : nat, 0 < n -> log2_spec n.
(* treatment of the 3 cases for (Call_M p) - p = 3 - p is a power of 2 (q is the exponent) - we use (gamma p) as an intermediate value *)
(*******************************************************)
(* rougly speaking, COND3 can be used as a specialized control structure: In Real programs, (Cond3 A p case3 case_2q case_gamma) is equivalent to : "if p = 3 then case3 else if p is the q_th power of 2, then (case_2q q) else (case_gamma (gamma p))" *)
(*********************************************)
(* the code generation algorithm  *)
(* the labels A,B,C,A1,A2,A3,B1,B2,C1,C2, in the proof comments correspond to the following places in the program:  Match c with A: (Call_M p) (COND3 A1: (p=3) ... A2: (p=2^q) ... A3: (q=gamma(p)) ...) B: (Call_C n n0) ... if (zerop r) then B1: ... else B2: ...  C: (Call_K n n0) ... if (zerop r) then C1: ... else C2: ... end. *)
(******************************************)

Lemma power_algo : forall n : nat, 0 < n -> addchain_spec n.