| 1 |
8.0 -> today |
| 2 |
|
| 3 |
See the main CHANGES file in the archive |
| 4 |
|
| 5 |
|
| 6 |
7.4 -> 8.0 |
| 7 |
|
| 8 |
No revolution this time. Mostly "behind-the-scene" clean-up and bug-fixes, |
| 9 |
but also a few steps toward a more user-friendly extraction: |
| 10 |
|
| 11 |
* syntax of extraction: |
| 12 |
- The old (Recursive) Extraction Module M. |
| 13 |
is now (Recursive) Extraction Library M. |
| 14 |
The old name was misleading since this command only works with M being a |
| 15 |
library M.v, and not a module produced by interactive command Module M. |
| 16 |
- The other commands |
| 17 |
Extraction foo. |
| 18 |
Recursive Extraction foo bar. |
| 19 |
Extraction "myfile.ml" foo bar. |
| 20 |
now accept that foo can be a module name instead of just a constant name. |
| 21 |
|
| 22 |
* Support of type scheme axioms (i.e. axiom whose type is an arity |
| 23 |
(x1:X1)...(xn:Xn)s with s a sort). For example: |
| 24 |
|
| 25 |
Axiom myprod : Set -> Set -> Set. |
| 26 |
Extract Constant myprod "'a" "'b" => "'a * 'b". |
| 27 |
Recursive Extraction myprod. |
| 28 |
-------> type ('a,'b) myprod = 'a * 'b |
| 29 |
|
| 30 |
* More flexible support of axioms. When an axiom isn't realized via Extract |
| 31 |
Constant before extraction, a warning is produced (instead of an error), |
| 32 |
and the extracted code must be completed later by hand. To find what |
| 33 |
needs to be completed, search for the following string: AXIOM TO BE REALIZED |
| 34 |
|
| 35 |
* Cosmetics: When extraction produces a file, it tells it. |
| 36 |
|
| 37 |
* (Experimental) It is allowed to extract under a opened interactive module |
| 38 |
(but still outside sections). Feature to be used with caution. |
| 39 |
|
| 40 |
* A problem has been identified concerning .v files used as normal interactive |
| 41 |
modules, like in |
| 42 |
|
| 43 |
<file A.v> |
| 44 |
Definition foo :=O. |
| 45 |
<End file A.v> |
| 46 |
|
| 47 |
<at toplevel> |
| 48 |
Require A. |
| 49 |
Module M:=A |
| 50 |
Extraction M. |
| 51 |
|
| 52 |
I might try to support that in the future. In the meanwhile, the |
| 53 |
current behaviour of extraction is to forbid this. |
| 54 |
|
| 55 |
* bug fixes: |
| 56 |
- many concerning Records. |
| 57 |
- a Stack Overflow with mutual inductive (BZ#320) |
| 58 |
- some optimizations have been removed since they were not type-safe: |
| 59 |
For example if e has type: type 'x a = A |
| 60 |
Then: match e with A -> A -----X----> e |
| 61 |
To be investigated further. |
| 62 |
|
| 63 |
|
| 64 |
7.3 -> 7.4 |
| 65 |
|
| 66 |
* The two main new features: |
| 67 |
- Automatic generation of Obj.magic when the extracted code |
| 68 |
in Ocaml is not directly typable. |
| 69 |
- An experimental extraction of Coq's new modules to Ocaml modules. |
| 70 |
|
| 71 |
* Concerning those Obj.magic: |
| 72 |
- The extraction now computes the expected type of any terms. Then |
| 73 |
it compares it with the actual type of the produced code. And when |
| 74 |
a mismatch is found, a Obj.magic is inserted. |
| 75 |
|
| 76 |
- As a rule, any extracted development that was compiling out of the box |
| 77 |
should not contain any Obj.magic. At the other hand, generation of |
| 78 |
Obj.magic is not optimized yet: there might be several of them at a place |
| 79 |
were one would have been enough. |
| 80 |
|
| 81 |
- Examples of code needing those Obj.magic: |
| 82 |
* plugins/extraction/test_extraction.v in the Coq source |
| 83 |
* in the users' contributions: |
| 84 |
Lannion |
| 85 |
Lyon/CIRCUITS |
| 86 |
Rocq/HIGMAN |
| 87 |
|
| 88 |
- As a side-effect of this Obj.magic feature, we now print the types |
| 89 |
of the extracted terms, both in .ml files as commented documentation |
| 90 |
and in interfaces .mli files |
| 91 |
|
| 92 |
- This feature hasn't been ported yet to Haskell. We are aware of |
| 93 |
some unsafe casting functions like "unsafeCoerce" on some Haskell implems. |
| 94 |
So it will eventually be done. |
| 95 |
|
| 96 |
* Concerning the extraction of Coq's new modules: |
| 97 |
- Taking in account the new Coq's modules system has implied a *huge* |
| 98 |
rewrite of most of the extraction code. |
| 99 |
|
| 100 |
- The extraction core (translation from Coq to an abstract mini-ML) |
| 101 |
is now complete and fairly stable, and supports modules, modules type |
| 102 |
and functors and all that stuff. |
| 103 |
|
| 104 |
- The ocaml pretty-print part, especially the renaming issue, is |
| 105 |
clearly weaker, and certainly still contains bugs. |
| 106 |
|
| 107 |
- Nothing done for translating these Coq Modules to Haskell. |
| 108 |
|
| 109 |
- A temporary drawback of this module extraction implementation is that |
| 110 |
efficiency (especially extraction speed) has been somehow neglected. |
| 111 |
To improve ... |
| 112 |
|
| 113 |
- As an interesting side-effect, definitions are now printed according to |
| 114 |
the user's original order. No more of this "dependency-correct but weird" |
| 115 |
order. In particular realized axioms via Extract Constant are now at their |
| 116 |
right place, and not at the beginning. |
| 117 |
|
| 118 |
* Other news: |
| 119 |
|
| 120 |
- Records are now printed using the Ocaml record syntax |
| 121 |
|
| 122 |
- Syntax output toward Scheme. Quite funny, but quite experimental and |
| 123 |
not documented. I recommend using the bigloo compiler since it contains |
| 124 |
natively some pattern matching. |
| 125 |
|
| 126 |
- the dummy constant "__" have changed. see README |
| 127 |
|
| 128 |
- a few bug-fixes (BZ#191 and others) |
| 129 |
|
| 130 |
7.2 -> 7.3 |
| 131 |
|
| 132 |
* Improved documentation in the Reference Manual. |
| 133 |
|
| 134 |
* Theoretical bad news: |
| 135 |
- a naughty example (see the end of test_extraction.v) |
| 136 |
forced me to stop eliminating lambdas and arguments corresponding to |
| 137 |
so-called "arity" in the general case. |
| 138 |
|
| 139 |
- The dummy constant used in extraction ( let prop = () in ocaml ) |
| 140 |
may in some cases be applied to arguments. This problem is dealt by |
| 141 |
generating sufficient abstraction before the (). |
| 142 |
|
| 143 |
|
| 144 |
* Theoretical good news: |
| 145 |
- there is now a mechanism that remove useless prop/arity lambdas at the |
| 146 |
top of function declarations. If your function had signature |
| 147 |
nat -> prop -> nat in the previous extraction, it will now be nat -> nat. |
| 148 |
So the extractions of common terms should look very much like the old |
| 149 |
V6.2 one, except in some particular cases (functions as parameters, partial |
| 150 |
applications, etc). In particular the bad news above have nearly no |
| 151 |
impact... |
| 152 |
|
| 153 |
|
| 154 |
* By the way there is no more "let prop = ()" in ocaml. Those () are |
| 155 |
directly inlined. And in Haskell the dummy constant is now __ (two |
| 156 |
underscore) and is defined by |
| 157 |
__ = Prelude.error "Logical or arity value used" |
| 158 |
This dummy constant should never be evaluated when computing an |
| 159 |
informative value, thanks to the lazy strategy. Hence the error message. |
| 160 |
|
| 161 |
|
| 162 |
* Syntax changes, see Documentation for details: |
| 163 |
|
| 164 |
Extraction Language Ocaml. |
| 165 |
Extraction Language Haskell. |
| 166 |
Extraction Language Toplevel. |
| 167 |
|
| 168 |
That fixes the target language of extraction. Default is Ocaml, even in the |
| 169 |
coq toplevel: you can now do copy-paste from the coq toplevel without |
| 170 |
renaming problems. Toplevel language is the ocaml pseudo-language used |
| 171 |
previously used inside the coq toplevel: coq names are printed with the coq |
| 172 |
way, i.e. with no renaming. |
| 173 |
|
| 174 |
So there is no more particular commands for Haskell, like |
| 175 |
Haskell Extraction "file" id. Just set your favourite language and go... |
| 176 |
|
| 177 |
|
| 178 |
* Haskell extraction has been tested at last (and corrected...). |
| 179 |
See specificities in Documentation. |
| 180 |
|
| 181 |
|
| 182 |
* Extraction of CoInductive in Ocaml language is now correct: it uses the |
| 183 |
Lazy.force and lazy features of Ocaml. |
| 184 |
|
| 185 |
|
| 186 |
* Modular extraction in Ocaml is now far more readable: |
| 187 |
instead of qualifying everywhere (A.foo), there are now some "open" at the |
| 188 |
beginning of files. Possible clashes are dealt with. |
| 189 |
|
| 190 |
|
| 191 |
* By default, any recursive function associated with an inductive type |
| 192 |
(foo_rec and foo_rect when foo is inductive type) will now be inlined |
| 193 |
in extracted code. |
| 194 |
|
| 195 |
|
| 196 |
* A few constants are explicitly declared to be inlined in extracted code. |
| 197 |
For the moment there are: |
| 198 |
Wf.Acc_rec |
| 199 |
Wf.Acc_rect |
| 200 |
Wf.well_founded_induction |
| 201 |
Wf.well_founded_induction_type |
| 202 |
Those constants does not match the auto-inlining criterion based on strictness. |
| 203 |
Of course, you can still override this behaviour via some Extraction NoInline. |
| 204 |
|
| 205 |
* There is now a web page showing the extraction of all standard theories: |
| 206 |
http://www.lri.fr/~letouzey/extraction |
| 207 |
|
| 208 |
|
| 209 |
7.1 -> 7.2 : |
| 210 |
|
| 211 |
* Syntax changes, see Documentation for more details: |
| 212 |
|
| 213 |
Set/Unset Extraction Optimize. |
| 214 |
|
| 215 |
Default is Set. This control all optimizations made on the ML terms |
| 216 |
(mostly reduction of dummy beta/iota redexes, but also simplications on |
| 217 |
Cases, etc). Put this option to Unset if you what a ML term as close as |
| 218 |
possible to the Coq term. |
| 219 |
|
| 220 |
Set/Unset Extraction AutoInline. |
| 221 |
|
| 222 |
Default in Set, so by default, the extraction mechanism feels free to |
| 223 |
inline the bodies of some defined constants, according to some heuristics |
| 224 |
like size of bodies, useness of some arguments, etc. Those heuristics are |
| 225 |
not always perfect, you may want to disable this feature, do it by Unset. |
| 226 |
|
| 227 |
Extraction Inline toto foo. |
| 228 |
Extraction NoInline titi faa bor. |
| 229 |
|
| 230 |
In addition to the automatic inline feature, you can now tell precisely to |
| 231 |
inline some more constants by the Extraction Inline command. Conversely, |
| 232 |
you can forbid the inlining of some specific constants by automatic inlining. |
| 233 |
Those two commands enable a precise control of what is inlined and what is not. |
| 234 |
|
| 235 |
Print Extraction Inline. |
| 236 |
|
| 237 |
Sum up the current state of the table recording the custom inlinings |
| 238 |
(Extraction (No)Inline). |
| 239 |
|
| 240 |
Reset Extraction Inline. |
| 241 |
|
| 242 |
Put the table recording the custom inlinings back to empty. |
| 243 |
|
| 244 |
As a consequence, there is no more need for options inside the commands of |
| 245 |
extraction: |
| 246 |
|
| 247 |
Extraction foo. |
| 248 |
Recursive Extraction foo bar. |
| 249 |
Extraction "file" foo bar. |
| 250 |
Extraction Module Mymodule. |
| 251 |
Recursive Extraction Module Mymodule. |
| 252 |
|
| 253 |
New: The last syntax extracts the module Mymodule and all the modules |
| 254 |
it depends on. |
| 255 |
|
| 256 |
You can also try the Haskell versions (not tested yet): |
| 257 |
|
| 258 |
Haskell Extraction foo. |
| 259 |
Haskell Recursive Extraction foo bar. |
| 260 |
Haskell Extraction "file" foo bar. |
| 261 |
Haskell Extraction Module Mymodule. |
| 262 |
Haskell Recursive Extraction Module Mymodule. |
| 263 |
|
| 264 |
And there's still the realization syntax: |
| 265 |
|
| 266 |
Extract Constant coq_bla => "caml_bla". |
| 267 |
Extract Inlined Constant coq_bla => "caml_bla". |
| 268 |
Extract Inductive myinductive => mycamlind [my_caml_constr1 ... ]. |
| 269 |
|
| 270 |
Note that now, the Extract Inlined Constant command is sugar for an Extract |
| 271 |
Constant followed by a Extraction Inline. So be careful with |
| 272 |
Reset Extraction Inline. |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
* Lot of works around optimization of produced code. Should make code more |
| 277 |
readable. |
| 278 |
|
| 279 |
- fixpoint definitions : there should be no more stupid printings like |
| 280 |
|
| 281 |
let foo x = |
| 282 |
let rec f x = |
| 283 |
.... (f y) .... |
| 284 |
in f x |
| 285 |
|
| 286 |
but rather |
| 287 |
|
| 288 |
let rec foo x = |
| 289 |
.... (foo y) .... |
| 290 |
|
| 291 |
- generalized iota (in particular iota and permutation cases/cases): |
| 292 |
|
| 293 |
A generalized iota redex is a "Cases e of ...." where e is ok. |
| 294 |
And the recursive predicate "ok" is given by: |
| 295 |
e is ok if e is a Constructor or a Cases where all branches are ok. |
| 296 |
In the case of generalized iota redex, it might be good idea to reduce it, |
| 297 |
so we do it. |
| 298 |
Example: |
| 299 |
|
| 300 |
match (match t with |
| 301 |
O -> Left |
| 302 |
| S n -> match n with |
| 303 |
O -> Right |
| 304 |
| S m -> Left) with |
| 305 |
Left -> blabla |
| 306 |
| Right -> bloblo |
| 307 |
|
| 308 |
After simplification, that gives: |
| 309 |
|
| 310 |
match t with |
| 311 |
O -> blabla |
| 312 |
| S n -> match n with |
| 313 |
O -> bloblo |
| 314 |
| S n -> blabla |
| 315 |
|
| 316 |
As shown on the example, code duplication can occur. In practice |
| 317 |
it seems not to happen frequently. |
| 318 |
|
| 319 |
- "constant" case: |
| 320 |
In V7.1 we used to simplify cases where all branches are the same. |
| 321 |
In V7.2 we can simplify in addition terms like |
| 322 |
cases e of |
| 323 |
C1 x y -> f (C x y) |
| 324 |
| C2 z -> f (C2 z) |
| 325 |
If x y z don't occur in f, we can produce (f e). |
| 326 |
|
| 327 |
- permutation cases/fun: |
| 328 |
extracted code has frequenty functions in branches of cases: |
| 329 |
|
| 330 |
let foo x = match x with |
| 331 |
O -> fun _ -> .... |
| 332 |
| S y -> fun _ -> .... |
| 333 |
|
| 334 |
the optimization consist in lifting the common "fun _ ->", and that gives |
| 335 |
|
| 336 |
let foo x _ = match x with |
| 337 |
O -> ..... |
| 338 |
| S y -> .... |
| 339 |
|
| 340 |
|
| 341 |
* Some bug corrections (many thanks in particular to Michel Levy). |
| 342 |
|
| 343 |
* Testing in coq contributions: |
| 344 |
If you are interested in extraction, you can look at the extraction tests |
| 345 |
I'have put in the following coq contributions |
| 346 |
|
| 347 |
Bordeaux/Additions computation of fibonacci(2000) |
| 348 |
Bordeaux/EXCEPTIONS multiplication using exception. |
| 349 |
Bordeaux/SearchTrees list -> binary tree. maximum. |
| 350 |
Dyade/BDDS boolean tautology checker. |
| 351 |
Lyon/CIRCUITS multiplication via a modelization of a circuit. |
| 352 |
Lyon/FIRING-SQUAD print the states of the firing squad. |
| 353 |
Marseille/CIRCUITS compares integers via a modelization of a circuit. |
| 354 |
Nancy/FOUnify unification of two first-order terms. |
| 355 |
Rocq/ARITH/Chinese computation of the chinese remainder. |
| 356 |
Rocq/COC small coc typechecker. (test by B. Barras, not by me) |
| 357 |
Rocq/HIGMAN run the proof on one example. |
| 358 |
Rocq/GRAPHS linear constraints checker in Z. |
| 359 |
Sophia-Antipolis/Stalmarck boolean tautology checker. |
| 360 |
Suresnes/BDD boolean tautology checker. |
| 361 |
|
| 362 |
Just do "make" in those contributions, the extraction test is integrated. |
| 363 |
More tests will follow on more contributions. |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
7.0 -> 7.1 : mostly bug corrections. No theoretical problems dealed with. |
| 368 |
|
| 369 |
* The semantics of Extract Constant changed: If you provide a extraction |
| 370 |
for p by Extract Constant p => "0", your generated ML file will begin by |
| 371 |
a let p = 0. The old semantics, which was to replace p everywhere by the |
| 372 |
provided terms, is still available via the Extract Inlined Constant p => |
| 373 |
"0" syntax. |
| 374 |
|
| 375 |
|
| 376 |
* There are more optimizations applied to the generated code: |
| 377 |
- identity cases: match e with P x y -> P x y | Q z -> Q z | ... |
| 378 |
is simplified into e. Especially interesting with the sumbool terms: |
| 379 |
there will be no more match ... with Left -> Left | Right -> Right |
| 380 |
|
| 381 |
- constant cases: match e with P x y -> c | Q z -> c | ... |
| 382 |
is simplified into c as soon as x, y, z do not occur in c. |
| 383 |
So no more match ... with Left -> Left | Right -> Left. |
| 384 |
|
| 385 |
|
| 386 |
* the extraction at Toplevel (Extraction foo and Recursive Extraction foo), |
| 387 |
which was only a development tool at the beginning, is now closer to |
| 388 |
the real extraction to a file. In particular optimizations are done, |
| 389 |
and constants like recursors ( ..._rec ) are expanded. |
| 390 |
|
| 391 |
|
| 392 |
* the singleton optimization is now protected against circular type. |
| 393 |
( Remind : this optimization is the one that simplify |
| 394 |
type 'a sig = Exists of 'a into type 'a sig = 'a and |
| 395 |
match e with (Exists c) -> d into let c = e in d ) |
| 396 |
|
| 397 |
|
| 398 |
* Fixed one bug concerning casted code |
| 399 |
|
| 400 |
|
| 401 |
* The inductives generated should now have always correct type-var list |
| 402 |
('a,'b,'c...) |
| 403 |
|
| 404 |
|
| 405 |
* Code cleanup until three days before release. Messing-up code |
| 406 |
in the last three days before release. |
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
6.x -> 7.0 : Everything changed. See README |