Source file wp_parameters.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
let () = Plugin.is_share_visible ()
let () = Plugin.is_session_visible ()
include Plugin.Register
(struct
let name = "WP"
let shortname = "wp"
let help = "Proof by Weakest Precondition Calculus"
end)
let warning ?wkey ?current = match current with
| None -> warning ?wkey ~current:true
| Some b -> warning ?wkey ~current:b
let wkey_hyp = register_warn_category "hypothesis"
let hypothesis ?current ?source ?emitwith ?echo ?once ?append text =
warning ~wkey:wkey_hyp ?current ?source ?emitwith ?echo ?once ?append text
let resetdemon = ref []
let on_reset f = resetdemon := f :: !resetdemon
let reset () = List.iter (fun f -> f ()) !resetdemon
let has_dkey (k:category) = is_debug_key_enabled k
let server = ref false
let () = Server.Main.once (fun () -> server := true)
let is_interactive () = System_config.is_gui || !server
let wp_generation = add_group "Goal Generator"
let () = Parameter_customize.set_group wp_generation
let () = Parameter_customize.do_not_save ()
module WP =
Action(struct
let option_name = "-wp"
let help = "Generate proof obligations for all (selected) properties."
end)
let () = on_reset WP.clear
let () = Parameter_customize.set_group wp_generation
module Dump =
Action(struct
let option_name = "-wp-dump"
let help = "Dump WP calculus graph."
end)
let () = on_reset Dump.clear
let () = Parameter_customize.set_group wp_generation
let () = Parameter_customize.do_not_save ()
module Functions =
Kernel_function_set
(struct
let option_name = "-wp-fct"
let arg_name = "f,..."
let help = "Select properties of given functions (defaults to all functions)."
end)
let () = on_reset Functions.clear
let () = Parameter_customize.set_group wp_generation
let () = Parameter_customize.do_not_save ()
module SkipFunctions =
Kernel_function_set
(struct
let option_name = "-wp-skip-fct"
let arg_name = "f,..."
let help = "Skip the specified functions (defaults to none)."
end)
let () = on_reset SkipFunctions.clear
let () = Parameter_customize.set_group wp_generation
let () = Parameter_customize.do_not_save ()
module Behaviors =
String_list
(struct
let option_name = "-wp-bhv"
let arg_name = "b,..."
let help = "Select only properties belonging to listed behaviors (the name \"default!\" can be used to select the default anonymous behavior) of the selected functions (defaults to all behaviors)."
end)
let () = on_reset Behaviors.clear
let () = Parameter_customize.set_group wp_generation
let () = Parameter_customize.do_not_save ()
let () = Parameter_customize.no_category ()
module Properties =
String_list
(struct
let option_name = "-wp-prop"
let arg_name = "p,..."
let help =
"Select properties based names and category.\n\
Use +name or +category to select properties and -name or -category \
to remove them from the selection. The '+' sign can be omitted.\n\
Categories are: @lemma, @requires, @assigns, @ensures, @exits, \
@assert, @invariant, @variant, @breaks, @continues, @returns, \
@complete_behaviors, @disjoint_behaviors, @terminates, \
@decreases and @check (which includes all check clauses)."
end)
let () = on_reset Properties.clear
let () = Parameter_customize.set_group wp_generation
module StatusAll =
False(struct
let option_name = "-wp-status-all"
let help = "Select properties with any status."
end)
let () = Parameter_customize.set_group wp_generation
module StatusTrue =
False(struct
let option_name = "-wp-status-valid"
let help = "Select properties with status 'Valid'."
end)
let () = Parameter_customize.set_group wp_generation
module StatusFalse =
False(struct
let option_name = "-wp-status-invalid"
let help = "Select properties with status 'Invalid'."
end)
let () = Parameter_customize.set_group wp_generation
module StatusMaybe =
True(struct
let option_name = "-wp-status-maybe"
let help = "Select properties with status 'Maybe'."
end)
module Fct = Cil_datatype.Kf.Set
type functions =
| Fct_none
| Fct_all
| Fct_skip of Fct.t
| Fct_list of Fct.t
let iter_fct phi = function
| Fct_none -> ()
| Fct_all -> Globals.Functions.iter phi
| Fct_skip fs ->
Globals.Functions.iter
(fun kf -> if not (Fct.mem kf fs) then phi kf)
| Fct_list fs -> Fct.iter phi fs
let get_kfs () =
if Functions.is_empty() then
if SkipFunctions.is_empty () then Fct_all
else Fct_skip (SkipFunctions.get())
else
Fct_list (Fct.diff (Functions.get()) (SkipFunctions.get()))
let get_fct () =
if WP.get () || not (Functions.is_empty()) ||
not (Behaviors.is_empty()) || not (Properties.is_empty())
then get_kfs ()
else Fct_none
let iter_kf f = iter_fct f (get_fct ())
let wp_model = add_group "Model Selection"
let () = Parameter_customize.set_group wp_model
module Model =
String_list
(struct
let option_name = "-wp-model"
let arg_name = "model+..."
let help = "Memory model selection. Available selectors:\n\
* 'Hoare' logic variables only\n\
* 'Typed' typed pointers only\n\
* '+nocast' no pointer cast\n\
* '+cast' unsafe pointer casts\n\
* '+raw' no logic variable\n\
* '+ref' by-reference-style pointers detection\n\
* '+nat/+int' natural / machine-integers arithmetics\n\
* '+real/+float' real / IEEE floating point arithmetics\n\
* 'Eva' (experimental) based on the results from Eva plugin"
end)
let () = Parameter_customize.set_group wp_model
module ByValue =
String_set
(struct
let option_name = "-wp-unalias-vars"
let arg_name = "var,..."
let help = "Consider variable names non-aliased."
end)
let () = Parameter_customize.set_group wp_model
module ByRef =
String_set
(struct
let option_name = "-wp-ref-vars"
let arg_name = "var,..."
let help = "Consider variable names by reference."
end)
let () = Parameter_customize.set_group wp_model
module InHeap =
String_set
(struct
let option_name = "-wp-alias-vars"
let arg_name = "var,..."
let help = "Consider variable names aliased."
end)
let () = Parameter_customize.set_group wp_model
module AliasInit =
False(struct
let option_name = "-wp-alias-init"
let help = "Use initializers for aliasing propagation."
end)
let () = Parameter_customize.set_group wp_model
module InCtxt =
String_set
(struct
let option_name = "-wp-context-vars"
let arg_name = "var,..."
let help = "Consider variable names in isolated context."
end)
let () = Parameter_customize.set_group wp_model
module ExternArrays =
False(struct
let option_name = "-wp-extern-arrays"
let help = "Put some default size for extern arrays."
end)
let () = Parameter_customize.set_group wp_model
module WeakIntModel =
False(struct
let option_name = "-wp-weak-int-model"
let help = "Suppress integral type side conditions within lemmas\n\
(possibly unsound)"
end)
let () = Parameter_customize.set_group wp_model
module Literals =
False(struct
let option_name = "-wp-literals"
let help = "Export content of string literals."
end)
let () = Parameter_customize.set_group wp_model
module Volatile =
True(struct
let option_name = "-wp-volatile"
let help = "Sound modeling of volatile access.\n\
Use -wp-no-volatile to ignore volatile attributes."
end)
let wp_strategy = add_group "Computation Strategies"
let () = Parameter_customize.set_group wp_strategy
module Init =
True(struct
let option_name = "-wp-init-const"
let help = "Use initializers for global const variables."
end)
let () = Parameter_customize.set_group wp_strategy
module CalleePreCond =
True(struct
let option_name = "-wp-callee-precond"
let help = "Use pre-conditions of callee."
end)
let () = Parameter_customize.set_group wp_strategy
module RTE =
False(struct
let option_name = "-wp-rte"
let help = "Generate RTE guards before WP."
end)
let () = Parameter_customize.set_group wp_strategy
module SmokeTests =
False(struct
let option_name = "-wp-smoke-tests"
let help = "Smoke-tests : look for inconsistent contracts (best effort)"
end)
let () = Parameter_customize.set_group wp_strategy
module SmokeDeadassumes =
True(struct
let option_name = "-wp-smoke-dead-assumes"
let help = "When generating smoke tests, look for dead assumes"
end)
let () = Parameter_customize.set_group wp_strategy
module SmokeDeadcode =
True(struct
let option_name = "-wp-smoke-dead-code"
let help = "When generating smoke tests, look for unreachable code"
end)
let () = Parameter_customize.set_group wp_strategy
module SmokeDeadcall =
True(struct
let option_name = "-wp-smoke-dead-call"
let help = "When generating smoke tests, look for non-terminating calls"
end)
let () = Parameter_customize.set_group wp_strategy
module SmokeDeadlocalinit =
False(struct
let option_name = "-wp-smoke-dead-local-init"
let help = "When generating smoke tests, look for dead local variables \
initialization"
end)
let () = Parameter_customize.set_group wp_strategy
module SmokeDeadloop =
True(struct
let option_name = "-wp-smoke-dead-loop"
let help = "When generating smoke tests, look for inconsistent loop invariants"
end)
let () = Parameter_customize.set_group wp_strategy
module SplitBranch =
False(struct
let option_name = "-wp-split"
let help = "Split if-then-else into sub-goals (see also -wp-max-split)"
end)
let () = Parameter_customize.set_group wp_strategy
module SplitSwitch =
True(struct
let option_name = "-wp-split-switch"
let help = "Split switch-cases into sub-goals (see also -wp-max-split)."
end)
let () = Parameter_customize.set_group wp_strategy
module SplitConj =
False(struct
let option_name = "-wp-split-conj"
let help = "Split conjunctive goals into sub-goals"
end)
let () = Parameter_customize.set_group wp_strategy
module SplitCNF =
Int(struct
let option_name = "-wp-split-cnf"
let default = 0
let arg_name = "N"
let help =
"Apply CNF transformation on goals at depth N (default 0, -1 unlimited)"
end)
let () = Parameter_customize.set_group wp_strategy
module SplitMax =
Int(struct
let option_name = "-wp-max-split"
let default = 1000
let arg_name = "n"
let help = "Set maximum number of splitted sub-goals (default 1000)"
end)
let () = Parameter_customize.set_group wp_strategy
module UnfoldAssigns =
Int(struct
let option_name = "-wp-unfold-assigns"
let default = 0
let arg_name = "n"
let help = "Unfold up to <n> levels of aggregates and arrays in assigns.\n\
Value -1 means unlimited depth (default 0)"
end)
let () = Parameter_customize.set_group wp_strategy
let () = Parameter_customize.is_invisible ()
module DynCall =
True(struct
let option_name = "-wp-dynamic"
let help = "Handle dynamic calls with specific annotations."
end)
let () =
Cmdline.run_after_configuring_stage
(fun () ->
if DynCall.is_set () then
warning ~current:false
"Option -wp-dynamic is obsolete and will be removed \
at some point in the future. @@calls annotations are now handled \
directly in the kernel")
let () = Parameter_customize.set_group wp_strategy
module PrecondWeakening =
False(struct
let option_name = "-wp-precond-weakening"
let help = "Discard pre-conditions of side behaviours (sound but incomplete optimisation)."
end)
let () = Parameter_customize.set_group wp_strategy
module TerminatesVariantHyp =
False(struct
let option_name = "-wp-variant-with-terminates"
let help = "Prove loop variant under the termination hypothesis."
end)
let wp_simplifier = add_group "Qed Simplifications"
let () = Parameter_customize.set_group wp_simplifier
module Simpl =
True(struct
let option_name = "-wp-simpl"
let help = "Enable Qed Simplifications."
end)
let () = Parameter_customize.set_group wp_simplifier
module Let =
True(struct
let option_name = "-wp-let"
let help = "Use variable elimination."
end)
let () = Parameter_customize.set_group wp_simplifier
module Core =
True(struct
let option_name = "-wp-core"
let help = "Lift core facts through branches."
end)
let () = Parameter_customize.set_group wp_simplifier
module Prune =
True(struct
let option_name = "-wp-pruning"
let help = "Prune trivial branches."
end)
let () = Parameter_customize.set_group wp_simplifier
module FilterInit =
True(struct
let option_name = "-wp-filter-init"
let help = "Use aggressive filtering of initialization hypotheses."
end)
let () = Parameter_customize.set_group wp_simplifier
module Clean =
True(struct
let option_name = "-wp-clean"
let help = "Use a simple cleaning in case of -wp-no-let."
end)
let () = Parameter_customize.set_group wp_simplifier
module Ground =
True(struct
let option_name = "-wp-ground"
let help = "Use aggressive ground simplifications."
end)
let () = Parameter_customize.set_group wp_simplifier
module Reduce =
True(struct
let option_name = "-wp-reduce"
let help = "Reduce function equalities with precedence to constructors."
end)
let () = Parameter_customize.set_group wp_simplifier
module ExtEqual =
True(struct
let option_name = "-wp-extensional"
let help = "Use extensional equality on compounds (hypotheses only)."
end)
let () = Parameter_customize.set_group wp_simplifier
module Filter =
True(struct
let option_name = "-wp-filter"
let help = "Filter non-used variables and related hypotheses."
end)
let () = Parameter_customize.set_group wp_simplifier
module Parasite =
True(struct
let option_name = "-wp-parasite"
let help = "Use singleton-variable filtering."
end)
let () = Parameter_customize.set_group wp_simplifier
module Prenex =
False(struct
let option_name = "-wp-prenex"
let help = "Normalize nested foralls into prenex-form"
end)
let () = Parameter_customize.set_group wp_simplifier
module SimplifyIsCint =
True(struct
let option_name = "-wp-simplify-is-cint"
let help = "Remove redundant machine integer range hypothesis."
end)
let () = Parameter_customize.set_group wp_simplifier
module SimplifyLandMask =
True(struct
let option_name = "-wp-simplify-land-mask"
let help = "Tight logical masks on unsigned integers."
end)
let () = Parameter_customize.set_group wp_simplifier
module SimplifyForall =
False(struct
let option_name = "-wp-simplify-forall"
let help = "Remove machine integer ranges in quantifiers."
end)
let () = Parameter_customize.set_group wp_simplifier
module SimplifyType =
False(struct
let option_name = "-wp-simplify-type"
let help = "Remove all `Type` constraints."
end)
let () = Parameter_customize.set_group wp_simplifier
module InitWithForall =
True(struct
let option_name = "-wp-init-summarize-array"
let help = "Summarize contiguous initializers with quantifiers."
end)
let () = Parameter_customize.set_group wp_simplifier
module BoundForallUnfolding =
Int(struct
let option_name = "-wp-bound-forall-unfolding"
let help = "Instantiate up to <n> forall-integers hypotheses."
let arg_name="n"
let default = 1000
end)
let wp_prover = add_group "Prover Interface"
let () = Parameter_customize.set_group wp_prover
module Provers = String_list
(struct
let option_name = "-wp-prover"
let arg_name = "dp,..."
let help =
"Submit proof obligations to prover(s):\n\
- 'none' (no prover run)\n\
- 'script' (replay all session scripts)\n\
- 'tip' (replay or init scripts for failed goals)\n\
- '<why3-prover>' (any Why-3 prover, see -wp-detect)\n\
"
end)
let () = Parameter_customize.set_group wp_prover
module Interactive = String
(struct
let option_name = "-wp-interactive"
let arg_name = "mode"
let default = "batch"
let help =
"WP mode for interactive Why-3 provers (eg: Coq):\n\
- 'batch': check current proof (default)\n\
- 'update': check updated proof\n\
- 'edit': edit current proof\n\
- 'fix': check current proof and edit if needed\n\
- 'fixup': update proof, check it and edit if needed\n\
"
end)
let () = Parameter_customize.set_group wp_prover
module ScriptMode = String
(struct
let option_name = "-wp-script"
let arg_name = "mode"
let default = ""
let help =
"WP mode for managing scripts and proof strategies:\n\
- 'batch': proof scripts are reused but not updated (default for script prover)\n\
- 'update': proof scripts are reused and updated (default for tip prover)\n\
- 'init': proof scripts are generated from scratch and saved\n\
- 'dry': proof scripts are explored from scratch and not saved\n\
See also option -wp-cache-env."
end)
let () = Parameter_customize.set_group wp_prover
module StrategyEngine = True
(struct
let option_name = "-wp-strategy-engine"
let help = "Activate @strategy and @proof annotations. (default: yes)"
end)
let () = Parameter_customize.set_group wp_prover
module DefaultStrategies = String_list
(struct
let option_name = "-wp-strategy"
let arg_name = "s,..."
let help = "Use the specified strategies as default."
end)
let () = Parameter_customize.set_group wp_prover
module RunAllProvers =
False(struct
let option_name = "-wp-run-all-provers"
let help = "Run all specified provers on each goal not proved by Qed. \
Do not stop when a prover succeeds. (default: no)"
end)
let () = Parameter_customize.set_group wp_prover
module Cache = String
(struct
let option_name = "-wp-cache"
let arg_name = "mode"
let default = ""
let help =
"WP cache mode:\n\
- 'none': no cache, run provers (default)\n\
- 'update': use cache or run provers and update cache\n\
- 'cleanup': update mode with garbage collection\n\
- 'replay': update mode with no cache update\n\
- 'rebuild': always run provers and update cache\n\
- 'offline': use cache but never run provers\n\
See also option -wp-cache-env."
end)
let () = Parameter_customize.set_group wp_prover
module CacheDir = String
(struct
let option_name = "-wp-cache-dir"
let arg_name = "dir"
let default = ""
let help =
"Specify global cache directory (no cleanup mode).\n\
By default, cache entries are stored in the WP session directory.\n\
See also option -wp-cache-env."
end)
let () = Parameter_customize.set_group wp_prover
module CacheEnv = False
(struct
let option_name = "-wp-cache-env"
let help = "Gives environment variables precedence over command line\n\
for cache management:\n\
- FRAMAC_WP_SCRIPT overrides -wp-script\n\
- FRAMAC_WP_CACHE overrides -wp-cache\n\
- FRAMAC_WP_CACHEDIR overrides -wp-cache-dir\n\
Disabled by default."
end)
let () = Parameter_customize.set_group wp_prover
module CachePrint = False
(struct
let option_name = "-wp-cache-print"
let help = "Show cache directory"
end)
let () = Parameter_customize.set_group wp_prover
module Generate = False
(struct
let option_name = "-wp-gen"
let help = "Only generate prover files (default: no)."
end)
let () = on_reset Generate.clear
let () = Parameter_customize.set_group wp_prover
module ScriptOnStdout = False
(struct
let option_name = "-wp-script-on-stdout"
let help = "When enabled (default: no), display scripts on stdout \
instead of writing them on disk."
end)
let () = Parameter_customize.set_group wp_prover
module PrepareScripts = Action
(struct
let option_name = "-wp-prepare-scripts"
let help = "Initialize a script tracking directory in the session \
directory."
end)
let () = Parameter_customize.set_group wp_prover
module FinalizeScripts = Action
(struct
let option_name = "-wp-finalize-scripts"
let help = "Remove untracked scripts according to the tracking directory \
if it does exist (does not remove anything otherwise)."
end)
let () = Parameter_customize.set_group wp_prover
module DryFinalizeScripts = False
(struct
let option_name = "-wp-dry-finalize-scripts"
let help = "Scripts that might be removed by -wp-finalize-scripts are \
kept, a message is printed instead for each file. The marks \
directory is kept."
end)
let () = Parameter_customize.set_group wp_prover
module Detect = Action
(struct
let option_name = "-wp-detect"
let help = "List installed provers."
end)
let () = on_reset Detect.clear
module Tactics = String_list
(struct
let option_name = "-wp-tactic"
let arg_name = "id,..."
let help = "Describe tactic. Use '?' for listing tactic names."
end)
let () = on_reset Tactics.clear
let () = Parameter_customize.set_group wp_prover
module Library =
Filepath_list
(struct
let option_name = "-wp-library"
let arg_name = "dir,..."
let file_kind = "Why3 load path"
let existence = Fc_Filepath.Must_exist
let help = "Load path for importing why3 theories"
end)
let () = Parameter_customize.set_group wp_prover
module Drivers =
Filepath_list
(struct
let option_name = "-wp-driver"
let arg_name = "file,..."
let file_kind = "WP library"
let existence = Fc_Filepath.Must_exist
let help = "Load drivers for linking to external libraries"
end)
let () = Parameter_customize.set_group wp_prover
module Steps =
Int(struct
let option_name = "-wp-steps"
let default = 0
let arg_name = "n"
let help = "Set number of steps for provers."
end)
let () = Parameter_customize.set_group wp_prover
module Timeout =
Int(struct
let option_name = "-wp-timeout"
let default = 2
let arg_name = "t"
let help =
Printf.sprintf
"Set the timeout (in seconds) for provers (default: %d)." default
end)
let () = Parameter_customize.set_group wp_prover
module Memlimit =
Int(struct
let option_name = "-wp-memlimit"
let default = 1000
let arg_name = "m"
let help =
Printf.sprintf
"Set the memory limit (in Mb) for provers (default: %d)." default
end)
let () = Parameter_customize.set_group wp_prover
module FctTimeout =
Kernel_function_map
(struct
include Datatype.Int
type key = Cil_types.kernel_function
let of_string ~key:_ ~prev:_ s =
Option.map
(fun s ->
try int_of_string s
with Failure _ ->
raise (Cannot_build ("'" ^ s ^ "' is not an integer")))
s
let to_string ~key:_ = Option.map string_of_int
end)
(struct
let option_name = "-wp-fct-timeout"
let arg_name = "f1:t1,...,fn:tn"
let help = "Customize the WP timeout (in secondes) for each specified \
function (t1 seconds for f1, t2 for f2, etc)."
let default = Kernel_function.Map.empty
end)
let () = Parameter_customize.set_group wp_prover
module SmokeTimeout =
Int(struct
let option_name = "-wp-smoke-timeout"
let default = 2
let arg_name = "n"
let help =
Printf.sprintf
"Set the timeout (in seconds) for provers (default: %d)." default
end)
let () = Parameter_customize.set_group wp_prover
module InteractiveTimeout =
Int(struct
let option_name = "-wp-interactive-timeout"
let default = 30
let arg_name = "time"
let help =
Printf.sprintf
"Set the timeout (in seconds) for checking scripts\n\
of interactive provers (default: %d)." default
end)
let () = Parameter_customize.set_group wp_prover
let () = Parameter_customize.set_group wp_prover
module TimeMargin =
String(struct
let option_name = "-wp-time-margin"
let default = "0.5"
let arg_name = "n"
let help =
Printf.sprintf
"Set margin-time (in seconds) for considering a proof automatic.\n\
When using the 'tip' prover, scripts are created or cancelled\n\
if the proof time is greater or lower than (timeout - margin).\n\
(default: %s)." default
end)
external cores : unit -> int = "caml_cores"
let () = Parameter_customize.set_group wp_prover
module Procs =
Int(struct
let option_name = "-wp-par"
let arg_name = "p"
let default = cores ()
let help =
Printf.sprintf
"Number of parallel proof process (default: %d)" default
end)
let () = Parameter_customize.set_group wp_prover
module ProofTrace =
False
(struct
let option_name = "-wp-proof-trace"
let help = "Keeps output of provers for valid POs (default: no)"
end)
let wp_prover_options = add_group "Prover Options"
let () = Parameter_customize.set_group wp_prover
module Auto = String_list
(struct
let option_name = "-wp-auto"
let arg_name = "s"
let help =
"Activate auto-search with strategy <s>.\n\
Use '-wp-auto <?>' for available strategies."
end)
let () = Parameter_customize.set_group wp_prover
module AutoDepth = Int
(struct
let option_name = "-wp-auto-depth"
let arg_name = "n"
let default = 5
let help =
"Depth of auto-search (-wp-auto only, default 5).\n\
Limits the number of nested level in strategies."
end)
let () = Parameter_customize.set_group wp_prover
module AutoWidth = Int
(struct
let option_name = "-wp-auto-width"
let arg_name = "n"
let default = 10
let help =
"Width of auto-search (-wp-auto only, default 10).\n\
Limits the number of pending goals in strategies."
end)
let () = Parameter_customize.set_group wp_prover
module BackTrack = Int
(struct
let option_name = "-wp-auto-backtrack"
let arg_name = "n"
let default = 0
let help =
"Backtracking limit (-wp-auto only, de-activated by default).\n\
Limits backtracking when applying strategies."
end)
let () = Parameter_customize.set_group wp_prover_options
let () = Parameter_customize.no_category ()
module Why3Flags =
String_list
(struct
let option_name = "-wp-why3-opt"
let arg_name = "option,..."
let help = "Additional options for Why3"
end)
let () = Parameter_customize.set_group wp_prover_options
let () = Parameter_customize.no_category ()
let wp_po = add_group "Proof Obligations"
let () = Parameter_customize.set_group wp_po
module TruncPropIdFileName =
Int(struct
let option_name = "-wp-filename-truncation"
let default = 60
let arg_name = "n"
let help =
"Truncate basename of proof obligation files after <n> characters.\n\
Since numbers can be added as suffixes to make theses names unique,\n\
filename lengths can be highter to <n>. No truncation is performed\n\
when the value equals to zero (default: 60)."
end)
let () = Parameter_customize.set_group wp_po
let () = Parameter_customize.do_not_save ()
module Print =
Action(struct
let option_name = "-wp-print"
let help = "Pretty-prints proof obligations on standard output."
end)
let () = on_reset Print.clear
let () = Parameter_customize.set_group wp_po
let () = Parameter_customize.do_not_save ()
module Status =
Action(struct
let option_name = "-wp-status"
let help = "Pretty-prints pending proof obligations on standard output."
end)
let () = on_reset Print.clear
let () = Parameter_customize.set_group wp_po
let () = Parameter_customize.do_not_save ()
module Report =
String_list
(struct
let option_name = "-wp-report"
let arg_name = "report,..."
let help = "Report specification file(s)"
end)
let () = Parameter_customize.set_group wp_po
let () = Parameter_customize.do_not_save ()
module ReportJson =
Filepath(struct
let option_name = "-wp-report-json"
let arg_name ="file.json"
let file_kind = "JSON report"
let existence = Fc_Filepath.Indifferent
let help = "Output proof results in JSON format."
end)
let () = on_reset ReportJson.clear
let () = Parameter_customize.set_group wp_po
let () = Parameter_customize.do_not_save ()
module OldReportJson =
String
(struct
let option_name = "-wp-deprecated-report-json"
let arg_name = "file.json"
let default = ""
let help =
"Output report in json format into given file.\n\
If the file already exists, it is used for\n\
stabilizing range of steps in other reports."
end)
let () = Parameter_customize.set_group wp_po
let () = Parameter_customize.do_not_save ()
module ReportName =
String(struct
let option_name = "-wp-report-basename"
let arg_name = "file"
let default = "wp-report"
let help = Printf.sprintf
"Basename of generated reports (default %S)" default
end)
let () = Parameter_customize.set_group wp_po
let () = Parameter_customize.do_not_save ()
module MemoryContext =
True
(struct
let option_name = "-wp-warn-memory-model"
let help = "Warn Against Memory Model Hypotheses"
end)
let () = Parameter_customize.set_group wp_po
let () = Parameter_customize.do_not_save ()
module CheckMemoryContext =
False
(struct
let option_name = "-wp-check-memory-model"
let help = "Insert memory model hypotheses in function contracts and \
check them on call. (experimental)"
end)
let () = Parameter_customize.set_group wp_po
module OutputDir =
Filepath(struct
let existence = Fc_Filepath.Indifferent
let option_name = "-wp-out"
let arg_name = "dir"
let file_kind = "directory"
let help = "Set working directory for generated files.\n\
Defaults to some temporary directory."
end)
module Probes =
True
(struct
let option_name = "-wp-probes"
let help = "Activate user-defines probes (@probe) (default: yes)"
end)
module CounterExamples =
False
(struct
let option_name = "-wp-counter-examples"
let help = "Ask for counter examples when supported by provers"
end)
let dkey = register_category "output"
let has_out () = not @@ Fc_Filepath.Normalized.is_empty (OutputDir.get ())
let make_output_dir dir =
try
if Extlib.mkdir ~parents:true dir 0o770 then
debug ~dkey "Created output directory '%a'" Fc_Filepath.Normalized.pretty dir
with Unix.Unix_error (err,_,_) ->
let msg = Unix.error_message err in
abort
"System Error (%s)@\nCan not create output directory '%a'"
msg Fc_Filepath.Normalized.pretty dir
let unique_tmp : Fc_Filepath.Normalized.t option ref = ref None
let make_tmp_dir () : Fc_Filepath.Normalized.t =
match !unique_tmp with
| None ->
let tmp =
try Extlib.temp_dir_cleanup_at_exit "wp"
with Extlib.Temp_file_error s ->
abort "Cannot create temporary file: %s" s
in
unique_tmp := Some tmp ;
debug ~dkey "Created temporary directory '%a'" Fc_Filepath.Normalized.pretty tmp ;
tmp
| Some tmp -> tmp
let make_gui_dir () =
try
let home =
try Sys.getenv "USERPROFILE" with Not_found ->
try Sys.getenv "HOME" with Not_found ->
"." in
let dir = Fc_Filepath.Normalized.of_string (home ^ "/" ^ ".frama-c-wp") in
if Fc_Filepath.exists dir && Fc_Filepath.is_dir dir then
Extlib.safe_remove_dir (dir:>string);
make_output_dir dir ; dir
with _ ->
make_tmp_dir ()
(** call the construction of the directory only once *)
let base_output = ref None
let base_output () =
match !base_output with
| None ->
let output =
let dir = OutputDir.get () in
if Fc_Filepath.Normalized.is_empty dir then
if is_interactive ()
then make_gui_dir ()
else make_tmp_dir ()
else
( make_output_dir dir ; dir ) in
base_output := Some output;
Fc_Filepath.add_symbolic_dir "WPOUT" output ; output
| Some output -> output
let get_output () =
let base = base_output () in
let project = Project.current () in
let name = Project.get_unique_name project in
if name = "default" then base
else
let dir = Datatype.Filepath.concat base name in
make_output_dir dir ; dir
let get_output_dir d =
let base = get_output () in
let path = Datatype.Filepath.concat base d in
make_output_dir path ; path
let default = Fc_Filepath.(Normalized.concat (pwd ()) "/.frama-c")
let has_session () =
Session.is_set () ||
( Fc_Filepath.exists default && Fc_Filepath.is_dir default )
let get_session ~force () =
if force then
Session.get_dir "."
else
if Session.is_set () then
Session.get ()
else
Session.get_dir "."
let get_session_dir ~force d =
let base = get_session ~force () in
let path = Datatype.Filepath.concat base d in
if force then make_output_dir path ; path
let cat_print_generated = register_category "print-generated"
let has_print_generated () = has_dkey cat_print_generated
let print_generated ? file =
let = match header with
| None -> Fc_Filepath.Normalized.to_pretty_string file
| Some head -> head in
debug ~dkey:cat_print_generated "%S@\n%t@." header
begin fun fmt ->
if not (Fc_Filepath.exists file) then
Format.pp_print_string fmt "<missing file>"
else
Command.read_lines file (fun s ->
Format.pp_print_string fmt s;
Format.pp_print_newline fmt ())
end
let protect e =
if debug_atleast 1 then false else
match e with
| Sys.Break | Async.Cancel | Log.AbortError _ | Log.AbortFatal _ -> false
| _ -> true