forked from sven--/Software-Foundations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LibTactics.html
5989 lines (4973 loc) · 775 KB
/
LibTactics.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="coqdoc.css" rel="stylesheet" type="text/css"/>
<title>LibTactics: A Collection of Handy General-Purpose Tactics</title>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<div id="page">
<div id="header">
</div>
<div id="main">
<h1 class="libtitle">LibTactics<span class="subtitle">A Collection of Handy General-Purpose Tactics</span></h1>
<div class="code code-tight">
</div>
<div class="doc">
</div>
<div class="code code-tight">
<br/>
<span class="comment">(* $Date: 2013-01-16 22:29:57 -0500 (Wed, 16 Jan 2013) $ *)</span><br/>
<span class="comment">(* Chapter maintained by Arthur Chargueraud *)</span><br/>
<br/>
</div>
<div class="doc">
This file contains a set of tactics that extends the set of builtin
tactics provided with the standard distribution of Coq. It intends
to overcome a number of limitations of the standard set of tactics,
and thereby to help user to write shorter and more robust scripts.
<div class="paragraph"> </div>
Hopefully, Coq tactics will be improved as time goes by, and this
file should ultimately be useless. In the meanwhile, serious Coq
users will probably find it very useful.
<div class="paragraph"> </div>
The present file contains the implementation and the detailed
documentation of those tactics. The SF reader need not read this
file; instead, he/she is encouraged to read the chapter named
UseTactics.v, which is gentle introduction to the most useful
tactics from the LibTactic library.
<div class="paragraph"> </div>
The main features offered are:
<div class="paragraph"> </div>
<ul class="doclist">
<li> More convenient syntax for naming hypotheses, with tactics for
introduction and inversion that take as input only the name of
hypotheses of type <span class="inlinecode"><span class="id" type="keyword">Prop</span></span>, rather than the name of all variables.
</li>
<li> Tactics providing true support for manipulating N-ary conjunctions,
disjunctions and existentials, hidding the fact that the underlying
implementation is based on binary predicates.
</li>
<li> Convenient support for automation: tactic followed with the symbol
"~" or "*" will call automation on the generated subgoals.
Symbol "~" stands for <span class="inlinecode"><span class="id" type="tactic">auto</span></span> and "*" for <span class="inlinecode"><span class="id" type="tactic">intuition</span></span> <span class="inlinecode"><span class="id" type="tactic">eauto</span></span>.
These bindings can be customized.
</li>
<li> Forward-chaining tactics are provided to instantiate lemmas
either with variable or hypotheses or a mix of both.
</li>
<li> A more powerful implementation of <span class="inlinecode"><span class="id" type="tactic">apply</span></span> is provided (it is based
on <span class="inlinecode"><span class="id" type="tactic">refine</span></span> and thus behaves better with respect to conversion).
</li>
<li> An improved inversion tactic which substitutes equalities on variables
generated by the standard inversion mecanism. Moreover, it supports
the elimination of dependently-typed equalities (requires axiom <span class="inlinecode"><span class="id" type="var">K</span></span>,
which is a weak form of Proof Irrelevance).
</li>
<li> Tactics for saving time when writing proofs, with tactics to
asserts hypotheses or sub-goals, and improved tactics for
clearing, renaming, and sorting hypotheses.
</li>
</ul>
<div class="paragraph"> </div>
External credits:
<div class="paragraph"> </div>
<ul class="doclist">
<li> thanks to Xavier Leroy for providing the idea of tactic <span class="inlinecode"><span class="id" type="var">forward</span></span>,
</li>
<li> thanks to Georges Gonthier for the implementation trick in <span class="inlinecode"><span class="id" type="var">rapply</span></span>,
</li>
</ul>
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Set</span> <span class="id" type="keyword">Implicit</span> <span class="id" type="var">Arguments</span>.<br/>
<br/>
<span class="comment">(* ********************************************************************** *)</span><br/>
</div>
<div class="doc">
<a name="lab906"></a><h1 class="section">Additional notations for Coq</h1>
</div>
<div class="code code-space">
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab907"></a><h2 class="section">N-ary Existentials</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span style="font-family: arial;">∃</span></span> <span class="inlinecode"><span class="id" type="var">T<sub>1</sub></span></span> <span class="inlinecode">...</span> <span class="inlinecode"><span class="id" type="var">TN</span>,</span> <span class="inlinecode"><span class="id" type="var">P</span></span> is a shorthand for
<span class="inlinecode"><span style="font-family: arial;">∃</span></span> <span class="inlinecode"><span class="id" type="var">T<sub>1</sub></span>,</span> <span class="inlinecode">...,</span> <span class="inlinecode"><span style="font-family: arial;">∃</span></span> <span class="inlinecode"><span class="id" type="var">TN</span>,</span> <span class="inlinecode"><span class="id" type="var">P</span></span>. Note that
<span class="inlinecode"><span class="id" type="var">Coq.Program.Syntax</span></span> already defines exists
for arity up to 4.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 x2 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x2</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x2</span> <span class="id" type="var">ident</span>, <br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 x2 x3 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x2</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x3</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x2</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x3</span> <span class="id" type="var">ident</span>, <br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 x2 x3 x4 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x2</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x3</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x4</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x2</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x3</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x4</span> <span class="id" type="var">ident</span>, <br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 x2 x3 x4 x5 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x2</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x3</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x4</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x5</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x2</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x3</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x4</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x5</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 x2 x3 x4 x5 x6 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x2</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x3</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x4</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x5</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x6</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x2</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x3</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x4</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x5</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">x6</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 x2 x3 x4 x5 x6 x7 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x2</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x3</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x4</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x5</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x6</span>, <br/>
<span style="font-family: arial;">∃</span><span class="id" type="var">x7</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x2</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x3</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x4</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x5</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">x6</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x7</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 x2 x3 x4 x5 x6 x7 x8 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x2</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x3</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x4</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x5</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x6</span>, <br/>
<span style="font-family: arial;">∃</span><span class="id" type="var">x7</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x8</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x2</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x3</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x4</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x5</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">x6</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x7</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x8</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 x2 x3 x4 x5 x6 x7 x8 x9 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x2</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x3</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x4</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x5</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x6</span>, <br/>
<span style="font-family: arial;">∃</span><span class="id" type="var">x7</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x8</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x9</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x2</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x3</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x4</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x5</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">x6</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x7</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x8</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x9</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'exists' x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 ',' P" :=<br/>
(<span style="font-family: arial;">∃</span><span class="id" type="var">x1</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x2</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x3</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x4</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x5</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x6</span>, <br/>
<span style="font-family: arial;">∃</span><span class="id" type="var">x7</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x8</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x9</span>, <span style="font-family: arial;">∃</span><span class="id" type="var">x10</span>, <span class="id" type="var">P</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 200, <span class="id" type="var">x1</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x2</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x3</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x4</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x5</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">x6</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x7</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x8</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x9</span> <span class="id" type="var">ident</span>, <span class="id" type="var">x10</span> <span class="id" type="var">ident</span>,<br/>
<span class="id" type="var">right</span> <span class="id" type="var">associativity</span>) : <span class="id" type="var">type_scope</span>.<br/>
<br/>
<span class="comment">(* ********************************************************************** *)</span><br/>
</div>
<div class="doc">
<a name="lab908"></a><h1 class="section">Tools for programming with Ltac</h1>
</div>
<div class="code code-space">
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab909"></a><h2 class="section">Identity continuation</h2>
</div>
<div class="code code-space">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">idcont</span> <span class="id" type="var">tt</span> := <br/>
<span class="id" type="var">idtac</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab910"></a><h2 class="section">Untyped arguments for tactics</h2>
<div class="paragraph"> </div>
Any Coq value can be boxed into the type <span class="inlinecode"><span class="id" type="var">Boxer</span></span>. This is
useful to use Coq computations for implementing tactics.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Inductive</span> <span class="id" type="var">Boxer</span> : <span class="id" type="keyword">Type</span> :=<br/>
| <span class="id" type="var">boxer</span> : <span style="font-family: arial;">∀</span>(<span class="id" type="var">A</span>:<span class="id" type="keyword">Type</span>), <span class="id" type="var">A</span> <span style="font-family: arial;">→</span> <span class="id" type="var">Boxer</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab911"></a><h2 class="section">Optional arguments for tactics</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">ltac_no_arg</span></span> is a constant that can be used to simulate
optional arguments in tactic definitions.
Use <span class="inlinecode"><span class="id" type="var">mytactic</span></span> <span class="inlinecode"><span class="id" type="var">ltac_no_arg</span></span> on the tactic invokation,
and use <span class="inlinecode"><span class="id" type="keyword">match</span></span> <span class="inlinecode"><span class="id" type="var">arg</span></span> <span class="inlinecode"><span class="id" type="keyword">with</span></span> <span class="inlinecode"><span class="id" type="var">ltac_no_arg</span></span> <span class="inlinecode">⇒</span> <span class="inlinecode">..</span> or
<span class="inlinecode"><span class="id" type="keyword">match</span></span> <span class="inlinecode"><span class="id" type="var">type</span></span> <span class="inlinecode"><span class="id" type="var">of</span></span> <span class="inlinecode"><span class="id" type="var">arg</span></span> <span class="inlinecode"><span class="id" type="keyword">with</span></span> <span class="inlinecode"><span class="id" type="var">ltac_No_arg</span></span> <span class="inlinecode">⇒</span> <span class="inlinecode">..</span> to
test whether an argument was provided.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Inductive</span> <span class="id" type="var">ltac_No_arg</span> : <span class="id" type="keyword">Set</span> := <br/>
| <span class="id" type="var">ltac_no_arg</span> : <span class="id" type="var">ltac_No_arg</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab912"></a><h2 class="section">Wildcard arguments for tactics</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">ltac_wild</span></span> is a constant that can be used to simulate
wildcard arguments in tactic definitions. Notation is <span class="inlinecode"><span class="id" type="var">__</span></span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Inductive</span> <span class="id" type="var">ltac_Wild</span> : <span class="id" type="keyword">Set</span> := <br/>
| <span class="id" type="var">ltac_wild</span> : <span class="id" type="var">ltac_Wild</span>.<br/>
<br/>
<span class="id" type="keyword">Notation</span> "'__'" := <span class="id" type="var">ltac_wild</span> : <span class="id" type="var">ltac_scope</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">ltac_wilds</span></span> is another constant that is typically used to
simulate a sequence of <span class="inlinecode"><span class="id" type="var">N</span></span> wildcards, with <span class="inlinecode"><span class="id" type="var">N</span></span> chosen
appropriately depending on the context. Notation is <span class="inlinecode"><span class="id" type="var">___</span></span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Inductive</span> <span class="id" type="var">ltac_Wilds</span> : <span class="id" type="keyword">Set</span> := <br/>
| <span class="id" type="var">ltac_wilds</span> : <span class="id" type="var">ltac_Wilds</span>.<br/>
<br/>
<span class="id" type="keyword">Notation</span> "'___'" := <span class="id" type="var">ltac_wilds</span> : <span class="id" type="var">ltac_scope</span>.<br/>
<br/>
<span class="id" type="keyword">Open</span> <span class="id" type="keyword">Scope</span> <span class="id" type="var">ltac_scope</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab913"></a><h2 class="section">Position markers</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">ltac_Mark</span></span> and <span class="inlinecode"><span class="id" type="var">ltac_mark</span></span> are dummy definitions used as sentinel
by tactics, to mark a certain position in the context or in the goal.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Inductive</span> <span class="id" type="var">ltac_Mark</span> : <span class="id" type="keyword">Type</span> :=<br/>
| <span class="id" type="var">ltac_mark</span> : <span class="id" type="var">ltac_Mark</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">gen_until_mark</span></span> repeats <span class="inlinecode"><span class="id" type="tactic">generalize</span></span> on hypotheses from the
context, starting from the bottom and stopping as soon as reaching
an hypothesis of type <span class="inlinecode"><span class="id" type="var">Mark</span></span>. If fails if <span class="inlinecode"><span class="id" type="var">Mark</span></span> does not
appear in the context.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">gen_until_mark</span> :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">goal</span> <span class="id" type="keyword">with</span> <span class="id" type="var">H</span>: ?<span class="id" type="var">T</span> <span style="font-family: arial;">⊢</span> <span class="id" type="var">_</span> ⇒<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">T</span> <span class="id" type="keyword">with</span> <br/>
| <span class="id" type="var">ltac_Mark</span> ⇒ <span class="id" type="tactic">clear</span> <span class="id" type="var">H</span><br/>
| <span class="id" type="var">_</span> ⇒ <span class="id" type="tactic">generalize</span> <span class="id" type="var">H</span>; <span class="id" type="tactic">clear</span> <span class="id" type="var">H</span>; <span class="id" type="var">gen_until_mark</span><br/>
<span class="id" type="keyword">end</span> <span class="id" type="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">intro_until_mark</span></span> repeats <span class="inlinecode"><span class="id" type="tactic">intro</span></span> until reaching an hypothesis of
type <span class="inlinecode"><span class="id" type="var">Mark</span></span>. It throws away the hypothesis <span class="inlinecode"><span class="id" type="var">Mark</span></span>.
It fails if <span class="inlinecode"><span class="id" type="var">Mark</span></span> does not appear as an hypothesis in the
goal.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">intro_until_mark</span> :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">goal</span> <span class="id" type="keyword">with</span> <br/>
| <span style="font-family: arial;">⊢</span> (<span class="id" type="var">ltac_Mark</span> <span style="font-family: arial;">→</span> <span class="id" type="var">_</span>) ⇒ <span class="id" type="tactic">intros</span> <span class="id" type="var">_</span><br/>
| <span class="id" type="var">_</span> ⇒ <span class="id" type="tactic">intro</span>; <span class="id" type="var">intro_until_mark</span><br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab914"></a><h2 class="section">List of arguments for tactics</h2>
<div class="paragraph"> </div>
A datatype of type <span class="inlinecode"><span class="id" type="var">list</span></span> <span class="inlinecode"><span class="id" type="var">Boxer</span></span> is used to manipulate list of
Coq values in ltac. Notation is <span class="inlinecode">>></span> <span class="inlinecode"><span class="id" type="var">v<sub>1</sub></span></span> <span class="inlinecode"><span class="id" type="var">v<sub>2</sub></span></span> <span class="inlinecode">...</span> <span class="inlinecode"><span class="id" type="var">vN</span></span> for building
a list containing the values <span class="inlinecode"><span class="id" type="var">v<sub>1</sub></span></span> through <span class="inlinecode"><span class="id" type="var">vN</span></span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Require</span> <span class="id" type="keyword">Import</span> <span class="id" type="var">List</span>.<br/>
<br/>
<span class="id" type="keyword">Notation</span> "'>>'" :=<br/>
(@<span class="id" type="var">nil</span> <span class="id" type="var">Boxer</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub>" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub>" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub>" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4 v5" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v5</span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v5</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4 v5 v6" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v5</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v6</span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v5</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v6</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4 v5 v6 v7" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v5</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v6</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v7</span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v5</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v6</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v7</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4 v5 v6 v7 v8" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v5</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v6</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v7</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v8</span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v5</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v6</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v7</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v8</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4 v5 v6 v7 v8 v9" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v5</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v6</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v7</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v8</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v9</span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v5</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v6</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v7</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v8</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v9</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4 v5 v6 v7 v8 v9 v10" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v5</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v6</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v7</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v8</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v9</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v10</span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v5</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v6</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v7</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v8</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v9</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v10</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4 v5 v6 v7 v8 v9 v10 v<sub>11</sub>" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v5</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v6</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v7</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v8</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v9</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v10</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>11</sub></span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v5</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v6</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v7</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v8</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v9</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v10</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>11</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4 v5 v6 v7 v8 v9 v10 v<sub>11</sub> v<sub>12</sub>" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v5</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v6</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v7</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v8</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v9</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v10</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>11</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>12</sub></span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v5</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v6</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v7</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v8</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v9</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v10</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>11</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v<sub>12</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<span class="id" type="keyword">Notation</span> "'>>' v<sub>1</sub> v<sub>2</sub> v<sub>3</sub> v4 v5 v6 v7 v8 v9 v10 v<sub>11</sub> v<sub>12</sub> v13" :=<br/>
((<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>1</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>2</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>3</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v4</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v5</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v6</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v7</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v8</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v9</span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v10</span>)<br/>
::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>11</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v<sub>12</sub></span>)::(<span class="id" type="var">boxer</span> <span class="id" type="var">v13</span>)::<span class="id" type="var">nil</span>)<br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>1</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>2</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>3</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v4</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v5</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v6</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v7</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v8</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v9</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v10</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v<sub>11</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0,<br/>
<span class="id" type="var">v<sub>12</sub></span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">v13</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0)<br/>
: <span class="id" type="var">ltac_scope</span>.<br/>
<br/>
</div>
<div class="doc">
The tactic <span class="inlinecode"><span class="id" type="var">list_boxer_of</span></span> inputs a term <span class="inlinecode"><span class="id" type="var">E</span></span> and returns a term
of type "list boxer", according to the following rules:
<div class="paragraph"> </div>
<ul class="doclist">
<li> if <span class="inlinecode"><span class="id" type="var">E</span></span> is already of type "list Boxer", then it returns <span class="inlinecode"><span class="id" type="var">E</span></span>;
</li>
<li> otherwise, it returns the list <span class="inlinecode">(<span class="id" type="var">boxer</span></span> <span class="inlinecode"><span class="id" type="var">E</span>)::<span class="id" type="var">nil</span></span>.
</li>
</ul>
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">list_boxer_of</span> <span class="id" type="var">E</span> := <br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">type</span> <span class="id" type="var">of</span> <span class="id" type="var">E</span> <span class="id" type="keyword">with</span> <br/>
| <span class="id" type="var">List.list</span> <span class="id" type="var">Boxer</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">E</span>)<br/>
| <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:((<span class="id" type="var">boxer</span> <span class="id" type="var">E</span>)::<span class="id" type="var">nil</span>)<br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab915"></a><h2 class="section">Databases of lemmas</h2>
<div class="paragraph"> </div>
Use the hint facility to implement a database mapping
terms to terms. To declare a new database, use a definition:
<span class="inlinecode"><span class="id" type="keyword">Definition</span></span> <span class="inlinecode"><span class="id" type="var">mydatabase</span></span> <span class="inlinecode">:=</span> <span class="inlinecode"><span class="id" type="var">True</span>.</span>
<div class="paragraph"> </div>
Then, to map <span class="inlinecode"><span class="id" type="var">mykey</span></span> to <span class="inlinecode"><span class="id" type="var">myvalue</span></span>, write the hint:
<span class="inlinecode"><span class="id" type="keyword">Hint</span></span> <span class="inlinecode"><span class="id" type="keyword">Extern</span></span> <span class="inlinecode">1</span> <span class="inlinecode">(<span class="id" type="var">Register</span></span> <span class="inlinecode"><span class="id" type="var">mydatabase</span></span> <span class="inlinecode"><span class="id" type="var">mykey</span>)</span> <span class="inlinecode">⇒</span> <span class="inlinecode"><span class="id" type="var">Provide</span></span> <span class="inlinecode"><span class="id" type="var">myvalue</span>.</span>
<div class="paragraph"> </div>
Finally, to query the value associated with a key, run the
tactic <span class="inlinecode"><span class="id" type="var">ltac_database_get</span></span> <span class="inlinecode"><span class="id" type="var">mydatabase</span></span> <span class="inlinecode"><span class="id" type="var">mykey</span></span>. This will leave
at the head of the goal the term <span class="inlinecode"><span class="id" type="var">myvalue</span></span>. It can then be
named and exploited using <span class="inlinecode"><span class="id" type="tactic">intro</span></span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Definition</span> <span class="id" type="var">ltac_database</span> (<span class="id" type="var">D</span>:<span class="id" type="var">Boxer</span>) (<span class="id" type="var">T</span>:<span class="id" type="var">Boxer</span>) (<span class="id" type="var">A</span>:<span class="id" type="var">Boxer</span>) := <span class="id" type="var">True</span>.<br/>
<br/>
<span class="id" type="keyword">Notation</span> "'Register' D T" := (<span class="id" type="var">ltac_database</span> (<span class="id" type="var">boxer</span> <span class="id" type="var">D</span>) (<span class="id" type="var">boxer</span> <span class="id" type="var">T</span>) <span class="id" type="var">_</span>) <br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 69, <span class="id" type="var">D</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0, <span class="id" type="var">T</span> <span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 0).<br/>
<br/>
<span class="id" type="keyword">Lemma</span> <span class="id" type="var">ltac_database_provide</span> : <span style="font-family: arial;">∀</span>(<span class="id" type="var">A</span>:<span class="id" type="var">Boxer</span>) (<span class="id" type="var">D</span>:<span class="id" type="var">Boxer</span>) (<span class="id" type="var">T</span>:<span class="id" type="var">Boxer</span>),<br/>
<span class="id" type="var">ltac_database</span> <span class="id" type="var">D</span> <span class="id" type="var">T</span> <span class="id" type="var">A</span>.<br/>
<span class="id" type="keyword">Proof</span>. <span class="id" type="tactic">split</span>. <span class="id" type="keyword">Qed</span>.<br/>
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">Provide</span> <span class="id" type="var">T</span> := <span class="id" type="tactic">apply</span> (@<span class="id" type="var">ltac_database_provide</span> (<span class="id" type="var">boxer</span> <span class="id" type="var">T</span>)).<br/>
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">ltac_database_get</span> <span class="id" type="var">D</span> <span class="id" type="var">T</span> :=<br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">A</span> := <span class="id" type="tactic">fresh</span> "TEMP" <span class="id" type="keyword">in</span> <span class="id" type="var">evar</span> (<span class="id" type="var">A</span>:<span class="id" type="var">Boxer</span>);<br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">H</span> := <span class="id" type="tactic">fresh</span> "TEMP" <span class="id" type="keyword">in</span><br/>
<span class="id" type="tactic">assert</span> (<span class="id" type="var">H</span> : <span class="id" type="var">ltac_database</span> (<span class="id" type="var">boxer</span> <span class="id" type="var">D</span>) (<span class="id" type="var">boxer</span> <span class="id" type="var">T</span>) <span class="id" type="var">A</span>); <br/>
[ <span class="id" type="tactic">subst</span> <span class="id" type="var">A</span>; <span class="id" type="tactic">auto</span> <br/>
| <span class="id" type="tactic">subst</span> <span class="id" type="var">A</span>; <span class="id" type="keyword">match</span> <span class="id" type="var">type</span> <span class="id" type="var">of</span> <span class="id" type="var">H</span> <span class="id" type="keyword">with</span> <span class="id" type="var">ltac_database</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> (<span class="id" type="var">boxer</span> ?<span class="id" type="var">L</span>) ⇒<br/>
<span class="id" type="tactic">generalize</span> <span class="id" type="var">L</span> <span class="id" type="keyword">end</span>; <span class="id" type="tactic">clear</span> <span class="id" type="var">H</span> ].<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab916"></a><h2 class="section">On-the-fly removal of hypotheses</h2>
<div class="paragraph"> </div>
In a list of arguments <span class="inlinecode">>></span> <span class="inlinecode"><span class="id" type="var">H1</span></span> <span class="inlinecode"><span class="id" type="var">H2</span></span> <span class="inlinecode">..</span> <span class="inlinecode"><span class="id" type="var">HN</span></span> passed to a tactic
such as <span class="inlinecode"><span class="id" type="var">lets</span></span> or <span class="inlinecode"><span class="id" type="var">applys</span></span> or <span class="inlinecode"><span class="id" type="var">forwards</span></span> or <span class="inlinecode"><span class="id" type="var">specializes</span></span>,
the term <span class="inlinecode"><span class="id" type="var">rm</span></span>, an identity function, can be placed in front
of the name of an hypothesis to be deleted.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Definition</span> <span class="id" type="var">rm</span> (<span class="id" type="var">A</span>:<span class="id" type="keyword">Type</span>) (<span class="id" type="var">X</span>:<span class="id" type="var">A</span>) := <span class="id" type="var">X</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">rm_term</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> removes one hypothesis that admits the same
type as <span class="inlinecode"><span class="id" type="var">E</span></span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">rm_term</span> <span class="id" type="var">E</span> :=<br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">T</span> := <span class="id" type="var">type</span> <span class="id" type="var">of</span> <span class="id" type="var">E</span> <span class="id" type="keyword">in</span><br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">goal</span> <span class="id" type="keyword">with</span> <span class="id" type="var">H</span>: <span class="id" type="var">T</span> <span style="font-family: arial;">⊢</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="tactic">try</span> <span class="id" type="tactic">clear</span> <span class="id" type="var">H</span> <span class="id" type="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">rm_inside</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> calls <span class="inlinecode"><span class="id" type="var">rm_term</span></span> <span class="inlinecode"><span class="id" type="var">Ei</span></span> for any subterm
of the form <span class="inlinecode"><span class="id" type="var">rm</span></span> <span class="inlinecode"><span class="id" type="var">Ei</span></span> found in E
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">rm_inside</span> <span class="id" type="var">E</span> :=<br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">go</span> <span class="id" type="var">E</span> := <span class="id" type="var">rm_inside</span> <span class="id" type="var">E</span> <span class="id" type="keyword">in</span><br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">E</span> <span class="id" type="keyword">with</span><br/>
| <span class="id" type="var">rm</span> ?<span class="id" type="var">X</span> ⇒ <span class="id" type="var">rm_term</span> <span class="id" type="var">X</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ⇒ <br/>
<span class="id" type="var">go</span> <span class="id" type="var">X1</span>; <span class="id" type="var">go</span> <span class="id" type="var">X2</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ⇒ <br/>
<span class="id" type="var">go</span> <span class="id" type="var">X1</span>; <span class="id" type="var">go</span> <span class="id" type="var">X2</span>; <span class="id" type="var">go</span> <span class="id" type="var">X3</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ⇒ <br/>
<span class="id" type="var">go</span> <span class="id" type="var">X1</span>; <span class="id" type="var">go</span> <span class="id" type="var">X2</span>; <span class="id" type="var">go</span> <span class="id" type="var">X3</span>; <span class="id" type="var">go</span> <span class="id" type="var">X4</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X5</span> ⇒ <br/>
<span class="id" type="var">go</span> <span class="id" type="var">X1</span>; <span class="id" type="var">go</span> <span class="id" type="var">X2</span>; <span class="id" type="var">go</span> <span class="id" type="var">X3</span>; <span class="id" type="var">go</span> <span class="id" type="var">X4</span>; <span class="id" type="var">go</span> <span class="id" type="var">X5</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X5</span> ?<span class="id" type="var">X6</span> ⇒ <br/>
<span class="id" type="var">go</span> <span class="id" type="var">X1</span>; <span class="id" type="var">go</span> <span class="id" type="var">X2</span>; <span class="id" type="var">go</span> <span class="id" type="var">X3</span>; <span class="id" type="var">go</span> <span class="id" type="var">X4</span>; <span class="id" type="var">go</span> <span class="id" type="var">X5</span>; <span class="id" type="var">go</span> <span class="id" type="var">X6</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X5</span> ?<span class="id" type="var">X6</span> ?<span class="id" type="var">X7</span> ⇒ <br/>
<span class="id" type="var">go</span> <span class="id" type="var">X1</span>; <span class="id" type="var">go</span> <span class="id" type="var">X2</span>; <span class="id" type="var">go</span> <span class="id" type="var">X3</span>; <span class="id" type="var">go</span> <span class="id" type="var">X4</span>; <span class="id" type="var">go</span> <span class="id" type="var">X5</span>; <span class="id" type="var">go</span> <span class="id" type="var">X6</span>; <span class="id" type="var">go</span> <span class="id" type="var">X7</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X5</span> ?<span class="id" type="var">X6</span> ?<span class="id" type="var">X7</span> ?<span class="id" type="var">X8</span> ⇒ <br/>
<span class="id" type="var">go</span> <span class="id" type="var">X1</span>; <span class="id" type="var">go</span> <span class="id" type="var">X2</span>; <span class="id" type="var">go</span> <span class="id" type="var">X3</span>; <span class="id" type="var">go</span> <span class="id" type="var">X4</span>; <span class="id" type="var">go</span> <span class="id" type="var">X5</span>; <span class="id" type="var">go</span> <span class="id" type="var">X6</span>; <span class="id" type="var">go</span> <span class="id" type="var">X7</span>; <span class="id" type="var">go</span> <span class="id" type="var">X8</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X5</span> ?<span class="id" type="var">X6</span> ?<span class="id" type="var">X7</span> ?<span class="id" type="var">X8</span> ?<span class="id" type="var">X9</span> ⇒ <br/>
<span class="id" type="var">go</span> <span class="id" type="var">X1</span>; <span class="id" type="var">go</span> <span class="id" type="var">X2</span>; <span class="id" type="var">go</span> <span class="id" type="var">X3</span>; <span class="id" type="var">go</span> <span class="id" type="var">X4</span>; <span class="id" type="var">go</span> <span class="id" type="var">X5</span>; <span class="id" type="var">go</span> <span class="id" type="var">X6</span>; <span class="id" type="var">go</span> <span class="id" type="var">X7</span>; <span class="id" type="var">go</span> <span class="id" type="var">X8</span>; <span class="id" type="var">go</span> <span class="id" type="var">X9</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X5</span> ?<span class="id" type="var">X6</span> ?<span class="id" type="var">X7</span> ?<span class="id" type="var">X8</span> ?<span class="id" type="var">X9</span> ?<span class="id" type="var">X10</span> ⇒ <br/>
<span class="id" type="var">go</span> <span class="id" type="var">X1</span>; <span class="id" type="var">go</span> <span class="id" type="var">X2</span>; <span class="id" type="var">go</span> <span class="id" type="var">X3</span>; <span class="id" type="var">go</span> <span class="id" type="var">X4</span>; <span class="id" type="var">go</span> <span class="id" type="var">X5</span>; <span class="id" type="var">go</span> <span class="id" type="var">X6</span>; <span class="id" type="var">go</span> <span class="id" type="var">X7</span>; <span class="id" type="var">go</span> <span class="id" type="var">X8</span>; <span class="id" type="var">go</span> <span class="id" type="var">X9</span>; <span class="id" type="var">go</span> <span class="id" type="var">X10</span><br/>
| <span class="id" type="var">_</span> ⇒ <span class="id" type="var">idtac</span><br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
For faster performance, one may deactivate <span class="inlinecode"><span class="id" type="var">rm_inside</span></span> by
replacing the body of this definition with <span class="inlinecode"><span class="id" type="var">idtac</span></span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">fast_rm_inside</span> <span class="id" type="var">E</span> :=<br/>
<span class="id" type="var">rm_inside</span> <span class="id" type="var">E</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab917"></a><h2 class="section">Numbers as arguments</h2>
<div class="paragraph"> </div>
When tactic takes a natural number as argument, it may be
parsed either as a natural number or as a relative number.
In order for tactics to convert their arguments into natural numbers,
we provide a conversion tactic.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Require</span> <span class="id" type="var">BinPos</span> <span class="id" type="var">Coq.ZArith.BinInt</span>.<br/>
<br/>
<span class="id" type="keyword">Definition</span> <span class="id" type="var">ltac_nat_from_int</span> (<span class="id" type="var">x</span>:<span class="id" type="var">BinInt.Z</span>) : <span class="id" type="var">nat</span> :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">x</span> <span class="id" type="keyword">with</span><br/>
| <span class="id" type="var">BinInt.Z0</span> ⇒ 0%<span class="id" type="var">nat</span><br/>
| <span class="id" type="var">BinInt.Zpos</span> <span class="id" type="var">p</span> ⇒ <span class="id" type="var">BinPos.nat_of_P</span> <span class="id" type="var">p</span><br/>
| <span class="id" type="var">BinInt.Zneg</span> <span class="id" type="var">p</span> ⇒ 0%<span class="id" type="var">nat</span><br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">nat_from_number</span> <span class="id" type="var">N</span> :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">type</span> <span class="id" type="var">of</span> <span class="id" type="var">N</span> <span class="id" type="keyword">with</span><br/>
| <span class="id" type="var">nat</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">N</span>)<br/>
| <span class="id" type="var">BinInt.Z</span> ⇒ <span class="id" type="keyword">let</span> <span class="id" type="var">N'</span> := <span class="id" type="var">constr</span>:(<span class="id" type="var">ltac_nat_from_int</span> <span class="id" type="var">N</span>) <span class="id" type="keyword">in</span> <span class="id" type="var">eval</span> <span class="id" type="tactic">compute</span> <span class="id" type="keyword">in</span> <span class="id" type="var">N'</span><br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">ltac_pattern</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> <span class="inlinecode"><span class="id" type="tactic">at</span></span> <span class="inlinecode"><span class="id" type="var">K</span></span> is the same as <span class="inlinecode"><span class="id" type="tactic">pattern</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> <span class="inlinecode"><span class="id" type="tactic">at</span></span> <span class="inlinecode"><span class="id" type="var">K</span></span> except that
<span class="inlinecode"><span class="id" type="var">K</span></span> is a Coq natural rather than a Ltac integer. Syntax
<span class="inlinecode"><span class="id" type="var">ltac_pattern</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> <span class="inlinecode"><span class="id" type="keyword">as</span></span> <span class="inlinecode"><span class="id" type="var">K</span></span> <span class="inlinecode"><span class="id" type="keyword">in</span></span> <span class="inlinecode"><span class="id" type="var">H</span></span> is also available.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Tactic Notation</span> "ltac_pattern" <span class="id" type="var">constr</span>(<span class="id" type="var">E</span>) "at" <span class="id" type="var">constr</span>(<span class="id" type="var">K</span>) :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">nat_from_number</span> <span class="id" type="var">K</span> <span class="id" type="keyword">with</span><br/>
| 1 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 1<br/>
| 2 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 2<br/>
| 3 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 3<br/>
| 4 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 4<br/>
| 5 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 5<br/>
| 6 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 6<br/>
| 7 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 7<br/>
| 8 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 8<br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="id" type="keyword">Tactic Notation</span> "ltac_pattern" <span class="id" type="var">constr</span>(<span class="id" type="var">E</span>) "at" <span class="id" type="var">constr</span>(<span class="id" type="var">K</span>) "in" <span class="id" type="var">hyp</span>(<span class="id" type="var">H</span>) :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">nat_from_number</span> <span class="id" type="var">K</span> <span class="id" type="keyword">with</span><br/>
| 1 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 1 <span class="id" type="keyword">in</span> <span class="id" type="var">H</span><br/>
| 2 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 2 <span class="id" type="keyword">in</span> <span class="id" type="var">H</span><br/>
| 3 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 3 <span class="id" type="keyword">in</span> <span class="id" type="var">H</span><br/>
| 4 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 4 <span class="id" type="keyword">in</span> <span class="id" type="var">H</span><br/>
| 5 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 5 <span class="id" type="keyword">in</span> <span class="id" type="var">H</span><br/>
| 6 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 6 <span class="id" type="keyword">in</span> <span class="id" type="var">H</span><br/>
| 7 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 7 <span class="id" type="keyword">in</span> <span class="id" type="var">H</span><br/>
| 8 ⇒ <span class="id" type="tactic">pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> 8 <span class="id" type="keyword">in</span> <span class="id" type="var">H</span><br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab918"></a><h2 class="section">Testing tactics</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">show</span></span> <span class="inlinecode"><span class="id" type="var">tac</span></span> executes a tactic <span class="inlinecode"><span class="id" type="var">tac</span></span> that produces a result,
and then display its result.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Tactic Notation</span> "show" <span class="id" type="var">tactic</span>(<span class="id" type="var">tac</span>) :=<br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">R</span> := <span class="id" type="var">tac</span> <span class="id" type="keyword">in</span> <span class="id" type="var">pose</span> <span class="id" type="var">R</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">dup</span></span> <span class="inlinecode"><span class="id" type="var">N</span></span> produces <span class="inlinecode"><span class="id" type="var">N</span></span> copies of the current goal. It is useful
for building examples on which to illustrate behaviour of tactics.
<span class="inlinecode"><span class="id" type="var">dup</span></span> is short for <span class="inlinecode"><span class="id" type="var">dup</span></span> <span class="inlinecode">2</span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Lemma</span> <span class="id" type="var">dup_lemma</span> : <span style="font-family: arial;">∀</span><span class="id" type="var">P</span>, <span class="id" type="var">P</span> <span style="font-family: arial;">→</span> <span class="id" type="var">P</span> <span style="font-family: arial;">→</span> <span class="id" type="var">P</span>.<br/>
<span class="id" type="keyword">Proof</span>. <span class="id" type="tactic">auto</span>. <span class="id" type="keyword">Qed</span>.<br/>
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">dup_tactic</span> <span class="id" type="var">N</span> :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">nat_from_number</span> <span class="id" type="var">N</span> <span class="id" type="keyword">with</span><br/>
| 0 ⇒ <span class="id" type="var">idtac</span><br/>
| <span class="id" type="var">S</span> 0 ⇒ <span class="id" type="var">idtac</span><br/>
| <span class="id" type="var">S</span> ?<span class="id" type="var">N'</span> ⇒ <span class="id" type="tactic">apply</span> <span class="id" type="var">dup_lemma</span>; [ | <span class="id" type="var">dup_tactic</span> <span class="id" type="var">N'</span> ]<br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="id" type="keyword">Tactic Notation</span> "dup" <span class="id" type="var">constr</span>(<span class="id" type="var">N</span>) := <br/>
<span class="id" type="var">dup_tactic</span> <span class="id" type="var">N</span>.<br/>
<span class="id" type="keyword">Tactic Notation</span> "dup" := <br/>
<span class="id" type="var">dup</span> 2.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab919"></a><h2 class="section">Check no evar in goal</h2>
</div>
<div class="code code-space">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">check_noevar</span> <span class="id" type="var">M</span> :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">M</span> <span class="id" type="keyword">with</span> <span class="id" type="var">M</span> ⇒ <span class="id" type="var">idtac</span> <span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">check_noevar_hyp</span> <span class="id" type="var">H</span> := <span class="comment">(* todo: imlement using check_noevar *)</span><br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">T</span> := <span class="id" type="var">type</span> <span class="id" type="var">of</span> <span class="id" type="var">H</span> <span class="id" type="keyword">in</span><br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">type</span> <span class="id" type="var">of</span> <span class="id" type="var">H</span> <span class="id" type="keyword">with</span> <span class="id" type="var">T</span> ⇒ <span class="id" type="var">idtac</span> <span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">check_noevar_goal</span> := <span class="comment">(* todo: imlement using check_noevar *)</span><br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">goal</span> <span class="id" type="keyword">with</span> <span style="font-family: arial;">⊢</span> ?<span class="id" type="var">G</span> ⇒ <span class="id" type="keyword">match</span> <span class="id" type="var">G</span> <span class="id" type="keyword">with</span> <span class="id" type="var">G</span> ⇒ <span class="id" type="var">idtac</span> <span class="id" type="keyword">end</span> <span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab920"></a><h2 class="section">Tagging of hypotheses</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">get_last_hyp</span></span> <span class="inlinecode"><span class="id" type="var">tt</span></span> is a function that returns the last hypothesis
at the bottom of the context. It is useful to obtain the default
name associated with the hypothesis, e.g.
<span class="inlinecode"><span class="id" type="tactic">intro</span>;</span> <span class="inlinecode"><span class="id" type="keyword">let</span></span> <span class="inlinecode"><span class="id" type="var">H</span></span> <span class="inlinecode">:=</span> <span class="inlinecode"><span class="id" type="var">get_last_hyp</span></span> <span class="inlinecode"><span class="id" type="var">tt</span></span> <span class="inlinecode"><span class="id" type="keyword">in</span></span> <span class="inlinecode"><span class="id" type="keyword">let</span></span> <span class="inlinecode"><span class="id" type="var">H'</span></span> <span class="inlinecode">:=</span> <span class="inlinecode"><span class="id" type="tactic">fresh</span></span> <span class="inlinecode">"<span class="id" type="var">P</span>"</span> <span class="inlinecode"><span class="id" type="var">H</span></span> <span class="inlinecode"><span class="id" type="keyword">in</span></span> <span class="inlinecode">...</span>
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">get_last_hyp</span> <span class="id" type="var">tt</span> :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">goal</span> <span class="id" type="keyword">with</span> <span class="id" type="var">H</span>: <span class="id" type="var">_</span> <span style="font-family: arial;">⊢</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">H</span>) <span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab921"></a><h2 class="section">Tagging of hypotheses</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">ltac_tag_subst</span></span> is a specific marker for hypotheses
which is used to tag hypotheses that are equalities to
be substituted.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Definition</span> <span class="id" type="var">ltac_tag_subst</span> (<span class="id" type="var">A</span>:<span class="id" type="keyword">Type</span>) (<span class="id" type="var">x</span>:<span class="id" type="var">A</span>) := <span class="id" type="var">x</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">ltac_to_generalize</span></span> is a specific marker for hypotheses
to be generalized.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Definition</span> <span class="id" type="var">ltac_to_generalize</span> (<span class="id" type="var">A</span>:<span class="id" type="keyword">Type</span>) (<span class="id" type="var">x</span>:<span class="id" type="var">A</span>) := <span class="id" type="var">x</span>.<br/>
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">gen_to_generalize</span> :=<br/>
<span class="id" type="tactic">repeat</span> <span class="id" type="keyword">match</span> <span class="id" type="var">goal</span> <span class="id" type="keyword">with</span> <br/>
<span class="id" type="var">H</span>: <span class="id" type="var">ltac_to_generalize</span> <span class="id" type="var">_</span> <span style="font-family: arial;">⊢</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="tactic">generalize</span> <span class="id" type="var">H</span>; <span class="id" type="tactic">clear</span> <span class="id" type="var">H</span> <span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">mark_to_generalize</span> <span class="id" type="var">H</span> :=<br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">T</span> := <span class="id" type="var">type</span> <span class="id" type="var">of</span> <span class="id" type="var">H</span> <span class="id" type="keyword">in</span><br/>
<span class="id" type="var">change</span> <span class="id" type="var">T</span> <span class="id" type="keyword">with</span> (<span class="id" type="var">ltac_to_generalize</span> <span class="id" type="var">T</span>) <span class="id" type="keyword">in</span> <span class="id" type="var">H</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab922"></a><h2 class="section">Deconstructing terms</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">get_head</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> is a tactic that returns the head constant of the
term <span class="inlinecode"><span class="id" type="var">E</span></span>, ie, when applied to a term of the form <span class="inlinecode"><span class="id" type="var">P</span></span> <span class="inlinecode"><span class="id" type="var">x1</span></span> <span class="inlinecode">...</span> <span class="inlinecode"><span class="id" type="var">xN</span></span>
it returns <span class="inlinecode"><span class="id" type="var">P</span></span>. If <span class="inlinecode"><span class="id" type="var">E</span></span> is not an application, it returns <span class="inlinecode"><span class="id" type="var">E</span></span>.
Warning: the tactic seems to loop in some cases when the goal is
a product and one uses the result of this function.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">get_head</span> <span class="id" type="var">E</span> :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">E</span> <span class="id" type="keyword">with</span><br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>)<br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>)<br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>)<br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>)<br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>) <br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>)<br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>)<br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>) <br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>) <br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>) <br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>) <br/>
| ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>)<br/>
| ?<span class="id" type="var">P</span> ⇒ <span class="id" type="var">constr</span>:(<span class="id" type="var">P</span>)<br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">get_fun_arg</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> is a tactic that decomposes an application
term <span class="inlinecode"><span class="id" type="var">E</span></span>, ie, when applied to a term of the form <span class="inlinecode"><span class="id" type="var">X1</span></span> <span class="inlinecode">...</span> <span class="inlinecode"><span class="id" type="var">XN</span></span>
it returns a pair made of <span class="inlinecode"><span class="id" type="var">X1</span></span> <span class="inlinecode">..</span> <span class="inlinecode"><span class="id" type="var">X</span>(<span class="id" type="var">N</span>-1)</span> and <span class="inlinecode"><span class="id" type="var">XN</span></span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Ltac</span> <span class="id" type="var">get_fun_arg</span> <span class="id" type="var">E</span> :=<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">E</span> <span class="id" type="keyword">with</span><br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X5</span> ?<span class="id" type="var">X6</span> ?<span class="id" type="var">X7</span> ?<span class="id" type="var">X</span> ⇒ <span class="id" type="var">constr</span>:((<span class="id" type="var">X1</span> <span class="id" type="var">X2</span> <span class="id" type="var">X3</span> <span class="id" type="var">X4</span> <span class="id" type="var">X5</span> <span class="id" type="var">X6</span>,<span class="id" type="var">X</span>))<br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X5</span> ?<span class="id" type="var">X6</span> ?<span class="id" type="var">X</span> ⇒ <span class="id" type="var">constr</span>:((<span class="id" type="var">X1</span> <span class="id" type="var">X2</span> <span class="id" type="var">X3</span> <span class="id" type="var">X4</span> <span class="id" type="var">X5</span>,<span class="id" type="var">X</span>))<br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X5</span> ?<span class="id" type="var">X</span> ⇒ <span class="id" type="var">constr</span>:((<span class="id" type="var">X1</span> <span class="id" type="var">X2</span> <span class="id" type="var">X3</span> <span class="id" type="var">X4</span>,<span class="id" type="var">X</span>)) <br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X4</span> ?<span class="id" type="var">X</span> ⇒ <span class="id" type="var">constr</span>:((<span class="id" type="var">X1</span> <span class="id" type="var">X2</span> <span class="id" type="var">X3</span>,<span class="id" type="var">X</span>))<br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X3</span> ?<span class="id" type="var">X</span> ⇒ <span class="id" type="var">constr</span>:((<span class="id" type="var">X1</span> <span class="id" type="var">X2</span>,<span class="id" type="var">X</span>)) <br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X2</span> ?<span class="id" type="var">X</span> ⇒ <span class="id" type="var">constr</span>:((<span class="id" type="var">X1</span>,<span class="id" type="var">X</span>))<br/>
| ?<span class="id" type="var">X1</span> ?<span class="id" type="var">X</span> ⇒ <span class="id" type="var">constr</span>:((<span class="id" type="var">X1</span>,<span class="id" type="var">X</span>))<br/>
<span class="id" type="keyword">end</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab923"></a><h2 class="section">Action at occurence and action not at occurence</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">ltac_action_at</span></span> <span class="inlinecode"><span class="id" type="var">K</span></span> <span class="inlinecode"><span class="id" type="var">of</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> <span class="inlinecode"><span class="id" type="tactic">do</span></span> <span class="inlinecode"><span class="id" type="var">Tac</span></span> isolates the <span class="inlinecode"><span class="id" type="var">K</span></span>-th occurence of <span class="inlinecode"><span class="id" type="var">E</span></span> in the
goal, setting it in the form <span class="inlinecode"><span class="id" type="var">P</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> for some named pattern <span class="inlinecode"><span class="id" type="var">P</span></span>,
then calls tactic <span class="inlinecode"><span class="id" type="var">Tac</span></span>, and finally unfolds <span class="inlinecode"><span class="id" type="var">P</span></span>. Syntax
<span class="inlinecode"><span class="id" type="var">ltac_action_at</span></span> <span class="inlinecode"><span class="id" type="var">K</span></span> <span class="inlinecode"><span class="id" type="var">of</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> <span class="inlinecode"><span class="id" type="keyword">in</span></span> <span class="inlinecode"><span class="id" type="var">H</span></span> <span class="inlinecode"><span class="id" type="tactic">do</span></span> <span class="inlinecode"><span class="id" type="var">Tac</span></span> is also available.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Tactic Notation</span> "ltac_action_at" <span class="id" type="var">constr</span>(<span class="id" type="var">K</span>) "of" <span class="id" type="var">constr</span>(<span class="id" type="var">E</span>) "do" <span class="id" type="var">tactic</span>(<span class="id" type="var">Tac</span>) :=<br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">p</span> := <span class="id" type="tactic">fresh</span> <span class="id" type="keyword">in</span> <span class="id" type="var">ltac_pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> <span class="id" type="var">K</span>;<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">goal</span> <span class="id" type="keyword">with</span> <span style="font-family: arial;">⊢</span> ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="tactic">set</span> (<span class="id" type="var">p</span>:=<span class="id" type="var">P</span>) <span class="id" type="keyword">end</span>;<br/>
<span class="id" type="var">Tac</span>; <span class="id" type="tactic">unfold</span> <span class="id" type="var">p</span>; <span class="id" type="tactic">clear</span> <span class="id" type="var">p</span>.<br/>
<br/>
<span class="id" type="keyword">Tactic Notation</span> "ltac_action_at" <span class="id" type="var">constr</span>(<span class="id" type="var">K</span>) "of" <span class="id" type="var">constr</span>(<span class="id" type="var">E</span>) "in" <span class="id" type="var">hyp</span>(<span class="id" type="var">H</span>) "do" <span class="id" type="var">tactic</span>(<span class="id" type="var">Tac</span>) :=<br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">p</span> := <span class="id" type="tactic">fresh</span> <span class="id" type="keyword">in</span> <span class="id" type="var">ltac_pattern</span> <span class="id" type="var">E</span> <span class="id" type="tactic">at</span> <span class="id" type="var">K</span> <span class="id" type="keyword">in</span> <span class="id" type="var">H</span>;<br/>
<span class="id" type="keyword">match</span> <span class="id" type="var">type</span> <span class="id" type="var">of</span> <span class="id" type="var">H</span> <span class="id" type="keyword">with</span> ?<span class="id" type="var">P</span> <span class="id" type="var">_</span> ⇒ <span class="id" type="tactic">set</span> (<span class="id" type="var">p</span>:=<span class="id" type="var">P</span>) <span class="id" type="keyword">in</span> <span class="id" type="var">H</span> <span class="id" type="keyword">end</span>;<br/>
<span class="id" type="var">Tac</span>; <span class="id" type="tactic">unfold</span> <span class="id" type="var">p</span> <span class="id" type="keyword">in</span> <span class="id" type="var">H</span>; <span class="id" type="tactic">clear</span> <span class="id" type="var">p</span>.<br/>
<br/>
</div>
<div class="doc">
<span class="inlinecode"><span class="id" type="var">protects</span></span> <span class="inlinecode"><span class="id" type="var">E</span></span> <span class="inlinecode"><span class="id" type="tactic">do</span></span> <span class="inlinecode"><span class="id" type="var">Tac</span></span> temporarily assigns a name to the expression <span class="inlinecode"><span class="id" type="var">E</span></span>
so that the execution of tactic <span class="inlinecode"><span class="id" type="var">Tac</span></span> will not modify <span class="inlinecode"><span class="id" type="var">E</span></span>. This is
useful for instance to restrict the action of <span class="inlinecode"><span class="id" type="tactic">simpl</span></span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Tactic Notation</span> "protects" <span class="id" type="var">constr</span>(<span class="id" type="var">E</span>) "do" <span class="id" type="var">tactic</span>(<span class="id" type="var">Tac</span>) :=<br/>
<span class="comment">(* let x := fresh "TEMP" in sets_eq x: E; T; subst x. *)</span><br/>
<span class="id" type="keyword">let</span> <span class="id" type="var">x</span> := <span class="id" type="tactic">fresh</span> "TEMP" <span class="id" type="keyword">in</span> <span class="id" type="keyword">let</span> <span class="id" type="var">H</span> := <span class="id" type="tactic">fresh</span> "TEMP" <span class="id" type="keyword">in</span><br/>
<span class="id" type="tactic">set</span> (<span class="id" type="var">X</span> := <span class="id" type="var">E</span>) <span class="id" type="keyword">in</span> ×; <span class="id" type="tactic">assert</span> (<span class="id" type="var">H</span> : <span class="id" type="var">X</span> = <span class="id" type="var">E</span>) <span class="id" type="tactic">by</span> <span class="id" type="tactic">reflexivity</span>; <br/>
<span class="id" type="var">clearbody</span> <span class="id" type="var">X</span>; <span class="id" type="var">Tac</span>; <span class="id" type="tactic">subst</span> <span class="id" type="var">x</span>.<br/>
<br/>
<span class="id" type="keyword">Tactic Notation</span> "protects" <span class="id" type="var">constr</span>(<span class="id" type="var">E</span>) "do" <span class="id" type="var">tactic</span>(<span class="id" type="var">Tac</span>) "/" :=<br/>
<span class="id" type="var">protects</span> <span class="id" type="var">E</span> <span class="id" type="tactic">do</span> <span class="id" type="var">Tac</span>.<br/>
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab924"></a><h2 class="section">An alias for <span class="inlinecode"><span class="id" type="var">eq</span></span></h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">eq'</span></span> is an alias for <span class="inlinecode"><span class="id" type="var">eq</span></span> to be used for equalities in
inductive definitions, so that they don't get mixed with
equalities generated by <span class="inlinecode"><span class="id" type="tactic">inversion</span></span>.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Definition</span> <span class="id" type="var">eq'</span> := @<span class="id" type="var">eq</span>.<br/>
<br/>
<span class="id" type="keyword">Hint</span> <span class="id" type="keyword">Unfold</span> <span class="id" type="var">eq'</span>.<br/>
<br/>
<span class="id" type="keyword">Notation</span> "x '='' y" := (@<span class="id" type="var">eq'</span> <span class="id" type="var">_</span> <span class="id" type="var">x</span> <span class="id" type="var">y</span>) <br/>
(<span class="id" type="tactic">at</span> <span class="id" type="var">level</span> 70, <span class="id" type="var">arguments</span> <span class="id" type="tactic">at</span> <span class="id" type="var">next</span> <span class="id" type="var">level</span>).<br/>
<br/>
<span class="comment">(* ********************************************************************** *)</span><br/>
</div>
<div class="doc">
<a name="lab925"></a><h1 class="section">Backward and forward chaining</h1>
</div>
<div class="code code-space">
<br/>
<span class="comment">(* ---------------------------------------------------------------------- *)</span><br/>
</div>
<div class="doc">
<a name="lab926"></a><h2 class="section">Application</h2>
<div class="paragraph"> </div>
<span class="inlinecode"><span class="id" type="var">rapply</span></span> is a tactic similar to <span class="inlinecode"><span class="id" type="tactic">eapply</span></span> except that it is
based on the <span class="inlinecode"><span class="id" type="tactic">refine</span></span> tactics, and thus is strictly more
powerful (at least in theory :). In short, it is able to perform
on-the-fly conversions when required for arguments to match,
and it is able to instantiate existentials when required.
</div>
<div class="code code-tight">
<br/>
<span class="id" type="keyword">Tactic Notation</span> "rapply" <span class="id" type="var">constr</span>(<span class="id" type="var">t</span>) :=<br/>
<span class="id" type="var">first</span> <span class="comment">(* todo: les @ sont inutiles *)</span><br/>
[ <span class="id" type="var">eexact</span> (@<span class="id" type="var">t</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span>) <br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>) <br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
| <span class="id" type="tactic">refine</span> (@<span class="id" type="var">t</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span> <span class="id" type="var">_</span>)<br/>
].<br/>