Strategies are used as follows: If you want to compute x^n, ( n > 4), then some strategy will give you some p (1 < p < n); then if you express n as qp+r (by euclidean division), then 0 < q < n, and r < n.
The computation schemes for computing p-th, q-th, and r-th powers, using the equality x^n=(x^p)^q . x^r are obtained by a well-founded recursion (see generation.v ).
In this development, we consider only deterministic strategies, whereas in the joined paper we consider non-deterministic strategies (to each n we can associate a set of integer naturals)
In the module binary_strat, we show that integer division by 2 is a strategy, and in the module dicho_strat, we present the "dichotomic" strategy which gave us the best results.
Inductive strategy:Set := mkstrat:((n:nat)(lt four n)-> {p:nat| (lt p n)/\ (le two p)})-> strategy.So, the standard way to define a strategy is to type the sequence:
Lemma my_strat:strategy. Proof. Realizer [n:nat]<some term of type nat>. Program_all. ... (logical goals solving ...) Qed.
int
to int
:
#load "Demo.ml" ##open "Demo";; #binary;; - : int -> int = <fun> #binary 87;; - : int = 43 #dicho;; - : (int -> (int, sumbool) sigS) -> int -> int = <fun> #dicho log2_impl;; - : int -> int = <fun> #dicho log2_impl 87;; - : int = 10