-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoqrel.RelDefinitions.html
856 lines (673 loc) · 136 KB
/
coqrel.RelDefinitions.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
<!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>coqrel.RelDefinitions</title>
</head>
<body>
<div id="page">
<div id="header">
</div>
<div id="main">
<h1 class="libtitle">Library coqrel.RelDefinitions</h1>
<div class="code">
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Export</span> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#"><span class="id" title="library">Coq.Program.Basics</span></a>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Export</span> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Relations.Relation_Definitions.html#"><span class="id" title="library">Coq.Relations.Relation_Definitions</span></a>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Export</span> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Classes.Morphisms.html#"><span class="id" title="library">Coq.Classes.Morphisms</span></a>.<br/>
<span class="id" title="keyword">Require</span> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Setoids.Setoid.html#"><span class="id" title="library">Setoid</span></a>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Export</span> <a class="idref" href="coqrel.Delay.html#"><span class="id" title="library">Delay</span></a>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab222"></a><h1 class="section">Prerequisites</h1>
<div class="paragraph"> </div>
Some instances that would normally cause loops can be used
nontheless if we insist that some parameters cannot be existential
variables. One way to do this is to use this guard class, similar in
spirit to <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#Unconvertible"><span class="id" title="record">Unconvertible</span></a></span>.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="NotEvar"><span class="id" title="record">NotEvar</span></a> {<span class="id" title="var">A</span>} (<span class="id" title="var">x</span>: <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a>).<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#NotEvar"><span class="id" title="class">NotEvar</span></a> ?<span class="id" title="var">x</span>) ⇒<br/>
<span class="id" title="var">not_evar</span> <span class="id" title="var">x</span>; <span class="id" title="tactic">constructor</span> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
</div>
<div class="doc">
This version of <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#Unconvertible"><span class="id" title="record">Unconvertible</span></a></span> does not assume that <span class="inlinecode"><a class="idref" href="compcert.lib.Intv.html#FOLD.a"><span class="id" title="variable">a</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#WITHIN_BOUNDS.b"><span class="id" title="variable">b</span></a></span>
have convertible types.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="Unconvertible"><span class="id" title="record">Unconvertible</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">a</span>: <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a>) (<span class="id" title="var">b</span>: <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) := <a name="unconvertible"><span class="id" title="projection">unconvertible</span></a> : <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Datatypes.html#unit"><span class="id" title="inductive">unit</span></a>.<br/>
<br/>
<span class="id" title="keyword">Ltac</span> <span class="id" title="var">unconvertible</span> <span class="id" title="var">a</span> <span class="id" title="var">b</span> :=<br/>
<span class="id" title="tactic">first</span><br/>
[ <span class="id" title="var">unify</span> <span class="id" title="var">a</span> <span class="id" title="var">b</span> <span class="id" title="keyword">with</span> <span class="id" title="var">typeclass_instances</span>; <span class="id" title="tactic">fail</span> 1<br/>
| <span class="id" title="tactic">exact</span> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Datatypes.html#tt"><span class="id" title="constructor">tt</span></a> ].<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#Unconvertible"><span class="id" title="class">Unconvertible</span></a> ?<span class="id" title="var">a</span> ?<span class="id" title="var">b</span>) ⇒<br/>
<span class="id" title="var">unconvertible</span> <span class="id" title="var">a</span> <span class="id" title="var">b</span> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
</div>
<div class="doc">
Sometimes we may want to introduce an auxiliary variable to help
with unification.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="Convertible"><span class="id" title="record">Convertible</span></a> {<span class="id" title="var">A</span>} (<span class="id" title="var">x</span> <span class="id" title="var">y</span>: <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a>) :=<br/>
<a name="convertible"><span class="id" title="projection">convertible</span></a>: <a class="idref" href="coqrel.RelDefinitions.html#x"><span class="id" title="variable">x</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#1c39bf18749e5cc609e83c0a0ba5a372"><span class="id" title="notation">=</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y"><span class="id" title="variable">y</span></a>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#Convertible"><span class="id" title="class">Convertible</span></a> ?<span class="id" title="var">x</span> ?<span class="id" title="var">y</span>) ⇒<br/>
<span class="id" title="tactic">eapply</span> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#eq_refl"><span class="id" title="constructor">eq_refl</span></a> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
</div>
<div class="doc">
The following class can be used to inhibit backtracking.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="Once"><span class="id" title="record">Once</span></a> <span class="id" title="var">P</span> := <a name="once"><span class="id" title="projection">once</span></a> : <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#Once"><span class="id" title="class">Once</span></a> ?<span class="id" title="var">P</span>) ⇒<br/>
<span class="id" title="tactic">red</span>; <span class="id" title="var">once</span> <span class="id" title="var">typeclasses</span> <span class="id" title="tactic">eauto</span> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab223"></a><h1 class="section">Relations</h1>
<div class="paragraph"> </div>
The constructions in <span class="inlinecode"><span class="id" title="library">Coq.Relations.Relation_Definitions</span></span> are only
concerned with relations within a single type, so that <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Relations.Relation_Definitions.html#relation"><span class="id" title="definition">relation</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span>
is defined as <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><span class="id" title="keyword">Prop</span></span>. We will need more general
relations, and so I define <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.common.AST.html#TRANSF_PARTIAL_FUNDEF.B"><span class="id" title="variable">B</span></a></span> as <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><a class="idref" href="compcert.common.AST.html#TRANSF_PARTIAL_FUNDEF.B"><span class="id" title="variable">B</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><span class="id" title="keyword">Prop</span></span>.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <a name="rel"><span class="id" title="definition">rel</span></a> (<span class="id" title="var">A1</span> <span class="id" title="var">A2</span>: <span class="id" title="keyword">Type</span>) := <a class="idref" href="coqrel.RelDefinitions.html#A1"><span class="id" title="variable">A1</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A2"><span class="id" title="variable">A2</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <span class="id" title="keyword">Prop</span>.<br/>
<br/>
<span class="id" title="keyword">Delimit</span> <span class="id" title="keyword">Scope</span> <span class="id" title="var">rel_scope</span> <span class="id" title="keyword">with</span> <span class="id" title="var">rel</span>.<br/>
<span class="id" title="keyword">Bind</span> <span class="id" title="keyword">Scope</span> <span class="id" title="var">rel_scope</span> <span class="id" title="keyword">with</span> <span class="id" title="var">rel</span>.<br/>
<br/>
</div>
<div class="doc">
Make sure that the existing definitions based on
<span class="inlinecode"><span class="id" title="var">Relation_Definitions.relation</span></span> use our <span class="inlinecode"><span class="id" title="var">rel_scope</span></span> as well.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Bind</span> <span class="id" title="keyword">Scope</span> <span class="id" title="var">rel_scope</span> <span class="id" title="keyword">with</span> <span class="id" title="var">Relation_Definitions.relation</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab224"></a><h2 class="section">Proof step</h2>
<div class="paragraph"> </div>
This is a catch-all class for any applicable strategy allowing us
to make progress towards solving a relational goal. The proposition
<span class="inlinecode"><a class="idref" href="compcert.common.Globalenvs.html#Genv.GENV.GLOBALENV_PRINCIPLES.P"><span class="id" title="variable">P</span></a></span> should encode the new subgoals, in the format expected by
<span class="inlinecode"><span class="id" title="var">Delay.split_conjunction</span></span>, and is decomposed accordingly in the
<span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rstep"><span class="id" title="projection">rstep</span></a></span> tactic.
<div class="paragraph"> </div>
At the moment, the following priorities are used for our different
<span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="record">RStep</span></a></span> instances. Generally speaking, the most specific, quick
tactics should be registered with higher priority (lower numbers),
and the more general, slow tactics that are likely to instantiate
evars incorrectly or spawn them too early should have lower priority
(higher numbers):
<div class="paragraph"> </div>
<ul class="doclist">
<li> 10 <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="record">RIntro</span></a></span>
</li>
<li> 30 <span class="inlinecode"><span class="id" title="var">preorder</span></span>
</li>
<li> 40 <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RDestruct"><span class="id" title="record">RDestruct</span></a></span>
</li>
<li> 50 <span class="inlinecode"><a class="idref" href="coqrel.Monotonicity.html#Monotonicity"><span class="id" title="record">Monotonicity</span></a></span> (includes <span class="inlinecode"><span class="id" title="var">Reflexivity</span></span> -- we may want to split)
</li>
<li> 70 <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RExists"><span class="id" title="record">RExists</span></a></span>
</li>
</ul>
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="RStep"><span class="id" title="record">RStep</span></a> (<span class="id" title="var">P</span> <span class="id" title="var">Q</span>: <span class="id" title="keyword">Prop</span>) :=<br/>
<a name="rstep"><span class="id" title="projection">rstep</span></a>: <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a>.<br/>
<br/>
<span class="id" title="keyword">Ltac</span> <span class="id" title="var">rstep</span> :=<br/>
<span class="id" title="keyword">lazymatch</span> <span class="id" title="keyword">goal</span> <span class="id" title="keyword">with</span><br/>
| |- ?<span class="id" title="var">Q</span> ⇒<br/>
<span class="id" title="tactic">apply</span> (<a class="idref" href="coqrel.RelDefinitions.html#rstep"><span class="id" title="definition">rstep</span></a> (<span class="id" title="var">Q</span> := <span class="id" title="var">Q</span>));<br/>
<span class="id" title="var">Delay.split_conjunction</span><br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab225"></a><h2 class="section">Proof automation</h2>
<div class="paragraph"> </div>
The following class solves the goal <span class="inlinecode"><a class="idref" href="compcert.lib.Intv.html#FORALL.Q"><span class="id" title="variable">Q</span></a></span> automatically. The
typeclass resolution process allows for backtracking, trying every
possible <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="record">RStep</span></a></span> at a given time.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="RAuto"><span class="id" title="record">RAuto</span></a> (<span class="id" title="var">Q</span>: <span class="id" title="keyword">Prop</span>) :=<br/>
<a name="rauto"><span class="id" title="projection">rauto</span></a> : <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a>.<br/>
<br/>
<span class="id" title="keyword">Ltac</span> <span class="id" title="var">rauto</span> :=<br/>
<span class="id" title="keyword">lazymatch</span> <span class="id" title="keyword">goal</span> <span class="id" title="keyword">with</span><br/>
| |- ?<span class="id" title="var">Q</span> ⇒<br/>
<span class="id" title="tactic">apply</span> (<a class="idref" href="coqrel.RelDefinitions.html#rauto"><span class="id" title="definition">rauto</span></a> (<span class="id" title="var">Q</span> := <span class="id" title="var">Q</span>));<br/>
<span class="id" title="var">Delay.split_conjunction</span><br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
After applying each step, we need to decompose the premise into
individual subgoals, wrapping each one into a new <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RAuto"><span class="id" title="record">RAuto</span></a></span> goal so
that the process continues.
<div class="paragraph"> </div>
Note the use of <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#Once"><span class="id" title="record">Once</span></a></span> below: while choosing a step to apply next
can involve some backtracking, once a step has been chosen <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RAuto"><span class="id" title="record">RAuto</span></a></span>
never backtracks. This avoids exponential blow up in the search
space, so that <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RAuto"><span class="id" title="record">RAuto</span></a></span> remains efficient even in case of failure.
From a usability perspective, it also encourages proper hygiene when
declaring instances, since extraneous or too broadly applicable
instance will cause failures (rather than silently add weight to the
system).
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="RAutoSubgoals"><span class="id" title="record">RAutoSubgoals</span></a> (<span class="id" title="var">P</span>: <span class="id" title="keyword">Prop</span>) :=<br/>
<a name="rauto_subgoals"><span class="id" title="projection">rauto_subgoals</span></a> : <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a>.<br/>
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="rauto_rstep"><span class="id" title="instance">rauto_rstep</span></a> <span class="id" title="var">P</span> <span class="id" title="var">Q</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#Once"><span class="id" title="class">Once</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="class">RStep</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a>) <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.RelDefinitions.html#RAutoSubgoals"><span class="id" title="class">RAutoSubgoals</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.RelDefinitions.html#RAuto"><span class="id" title="class">RAuto</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Ltac</span> <span class="id" title="var">rauto_split</span> :=<br/>
<span class="id" title="tactic">red</span>;<br/>
<span class="id" title="var">Delay.split_conjunction</span>;<br/>
<span class="id" title="keyword">lazymatch</span> <span class="id" title="keyword">goal</span> <span class="id" title="keyword">with</span><br/>
| |- ?<span class="id" title="var">Q</span> ⇒ <span class="id" title="tactic">change</span> (<a class="idref" href="coqrel.RelDefinitions.html#RAuto"><span class="id" title="class">RAuto</span></a> <span class="id" title="var">Q</span>)<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#RAutoSubgoals"><span class="id" title="class">RAutoSubgoals</span></a> <span class="id" title="var">_</span>) ⇒<br/>
<span class="id" title="var">rauto_split</span> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
</div>
<div class="doc">
If <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rauto"><span class="id" title="projection">rauto</span></a></span> is run under the <span class="inlinecode"><span class="id" title="var">delayed</span></span> tactical and we don't know
how to make progress, bail out. Note that this will inhibit
backtracking.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Hint Extern</span> 1000 (<a class="idref" href="coqrel.RelDefinitions.html#RAuto"><span class="id" title="class">RAuto</span></a> <span class="id" title="var">_</span>) ⇒<br/>
<span class="id" title="tactic">red</span>; <span class="id" title="tactic">solve</span> [ <span class="id" title="var">delay</span> ] : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab226"></a><h2 class="section">Introduction rules</h2>
<div class="paragraph"> </div>
In effect, <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="record">RIntro</span></a></span> is pretty much identical to <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="record">RStep</span></a></span>, but we
like to separate introduction rules and the <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rintro"><span class="id" title="projection">rintro</span></a></span> tactic.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="RIntro"><span class="id" title="record">RIntro</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">P</span>: <span class="id" title="keyword">Prop</span>) (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) (<span class="id" title="var">m</span>: <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a>) (<span class="id" title="var">n</span>: <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>): <span class="id" title="keyword">Prop</span> :=<br/>
<a name="rintro"><span class="id" title="projection">rintro</span></a>: <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a>.<br/>
<br/>
<span class="id" title="var">Arguments</span> <a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="class">RIntro</span></a> {<span class="id" title="var">A</span>%<span class="id" title="var">type</span> <span class="id" title="var">B</span>%<span class="id" title="var">type</span>} <span class="id" title="var">P</span>%<span class="id" title="var">type</span> <span class="id" title="var">R</span>%<span class="id" title="var">rel</span> <span class="id" title="var">m</span> <span class="id" title="var">n</span>.<br/>
<br/>
<span class="id" title="keyword">Ltac</span> <span class="id" title="var">rintro</span> :=<br/>
<span class="id" title="keyword">lazymatch</span> <span class="id" title="keyword">goal</span> <span class="id" title="keyword">with</span><br/>
| |- ?<span class="id" title="var">R</span> ?<span class="id" title="var">m</span> ?<span class="id" title="var">n</span> ⇒<br/>
<span class="id" title="tactic">apply</span> (<a class="idref" href="coqrel.RelDefinitions.html#rintro"><span class="id" title="definition">rintro</span></a> (<span class="id" title="var">R</span>:=<span class="id" title="var">R</span>) (<span class="id" title="var">m</span>:=<span class="id" title="var">m</span>) (<span class="id" title="var">n</span>:=<span class="id" title="var">n</span>));<br/>
<span class="id" title="var">Delay.split_conjunction</span><br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="rintro_rstep"><span class="id" title="instance">rintro_rstep</span></a>:<br/>
<span class="id" title="keyword">∀</span> `(<a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="class">RIntro</span></a>), <a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="class">RStep</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a>) | 10.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
Most introduction rules are entierly reversible. For instance,
suppose we use the introduction rule for <span class="inlinecode">++></span> on a goal of the form
<span class="inlinecode">(<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Reals.Rdefinitions.html#R1"><span class="id" title="axiom">R1</span></a></span> <span class="inlinecode">++></span> <span class="inlinecode"><a class="idref" href="compcert.common.Linking.html#R2"><span class="id" title="variable">R2</span></a>)</span> <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span>, to obtain <span class="inlinecode"><span class="id" title="var">Hxy</span>:</span> <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Reals.Rdefinitions.html#R1"><span class="id" title="axiom">R1</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.flocq.Appli.Fappli_rnd_odd.html#Odd_prop_aux.x"><span class="id" title="variable">x</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#y"><span class="id" title="variable">y</span></a></span> <span class="inlinecode">|-</span> <span class="inlinecode"><a class="idref" href="compcert.common.Linking.html#R2"><span class="id" title="variable">R2</span></a></span> <span class="inlinecode">(<a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.flocq.Appli.Fappli_rnd_odd.html#Odd_prop_aux.x"><span class="id" title="variable">x</span></a>)</span> <span class="inlinecode">(<a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#y"><span class="id" title="variable">y</span></a>)</span>. If at
a later stage we manage to prove our old goal <span class="inlinecode"><span class="id" title="var">Hfg</span>:</span> <span class="inlinecode">(<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Reals.Rdefinitions.html#R1"><span class="id" title="axiom">R1</span></a></span> <span class="inlinecode">++></span> <span class="inlinecode"><a class="idref" href="compcert.common.Linking.html#R2"><span class="id" title="variable">R2</span></a>)</span> <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span>,
we can always use the elimination rule for <span class="inlinecode">++></span> in conjunction with
the two hypotheses to prove <span class="inlinecode"><a class="idref" href="compcert.common.Linking.html#R2"><span class="id" title="variable">R2</span></a></span> <span class="inlinecode">(<a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.flocq.Appli.Fappli_rnd_odd.html#Odd_prop_aux.x"><span class="id" title="variable">x</span></a>)</span> <span class="inlinecode">(<a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#y"><span class="id" title="variable">y</span></a>)</span>.
<div class="paragraph"> </div>
On the other hand, whenever a new existential variable is involved,
this reversibility is lost: the time of introduction of the evar
determines what a valid instantiation is, and there is no way to go
back if we want to use components introduced later, say by
destructing one of the hypotheses.
<div class="paragraph"> </div>
For this reason, we want such introduction rules to be used only as
a last resort, and segregate them as instances of the following
class rather than <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="record">RIntro</span></a></span>. Moreover, to make sure that we don't
leave the user in a dead-end, we only use it if we can immediately
solve the resulting subgoal.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="RExists"><span class="id" title="record">RExists</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">P</span>: <span class="id" title="keyword">Prop</span>) (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) (<span class="id" title="var">m</span>: <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a>) (<span class="id" title="var">n</span>: <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>): <span class="id" title="keyword">Prop</span> :=<br/>
<a name="rexists"><span class="id" title="projection">rexists</span></a>: <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a>.<br/>
<br/>
<span class="id" title="var">Arguments</span> <a class="idref" href="coqrel.RelDefinitions.html#RExists"><span class="id" title="class">RExists</span></a> {<span class="id" title="var">A</span>%<span class="id" title="var">type</span> <span class="id" title="var">B</span>%<span class="id" title="var">type</span>} <span class="id" title="var">P</span>%<span class="id" title="var">type</span> <span class="id" title="var">R</span>%<span class="id" title="var">rel</span> <span class="id" title="var">m</span> <span class="id" title="var">n</span>.<br/>
<br/>
<span class="id" title="keyword">Ltac</span> <span class="id" title="var">reexists</span> :=<br/>
<span class="id" title="keyword">lazymatch</span> <span class="id" title="keyword">goal</span> <span class="id" title="keyword">with</span><br/>
| |- ?<span class="id" title="var">R</span> ?<span class="id" title="var">m</span> ?<span class="id" title="var">n</span> ⇒<br/>
<span class="id" title="tactic">apply</span> (<a class="idref" href="coqrel.RelDefinitions.html#rexists"><span class="id" title="definition">rexists</span></a> (<span class="id" title="var">R</span>:=<span class="id" title="var">R</span>) (<span class="id" title="var">m</span>:=<span class="id" title="var">m</span>) (<span class="id" title="var">n</span>:=<span class="id" title="var">n</span>));<br/>
<span class="id" title="var">Delay.split_conjunction</span><br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="rexists_rstep"><span class="id" title="instance">rexists_rstep</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} <span class="id" title="var">P</span> <span class="id" title="var">R</span> (<span class="id" title="var">m</span>:<a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a>) (<span class="id" title="var">n</span>:<a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>):<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RExists"><span class="id" title="class">RExists</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.Delay.html#NonDelayed"><span class="id" title="class">NonDelayed</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#RAutoSubgoals"><span class="id" title="class">RAutoSubgoals</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a>) <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="class">RStep</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#True"><span class="id" title="inductive">True</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a>) | 70.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab227"></a><h2 class="section">Using relations</h2>
<div class="paragraph"> </div>
As we extend our relations language with new relators, we need to
be able to extend the ways in which corresponding relational
properties can be applied to a given goal. The following type class
expresses that the relational property <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.x86.SelectLongproof.html#CMCONSTR.m"><span class="id" title="variable">m</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#n"><span class="id" title="variable">n</span></a></span> can be applied to a
goal of type <span class="inlinecode"><a class="idref" href="compcert.lib.Intv.html#FORALL.Q"><span class="id" title="variable">Q</span></a></span>, generating the subgoal <span class="inlinecode"><a class="idref" href="compcert.common.Globalenvs.html#Genv.GENV.GLOBALENV_PRINCIPLES.P"><span class="id" title="variable">P</span></a></span>.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="RElim"><span class="id" title="record">RElim</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) (<span class="id" title="var">m</span>: <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a>) (<span class="id" title="var">n</span>: <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) (<span class="id" title="var">P</span> <span class="id" title="var">Q</span>: <span class="id" title="keyword">Prop</span>): <span class="id" title="keyword">Prop</span> :=<br/>
<a name="relim"><span class="id" title="projection">relim</span></a>: <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a>.<br/>
<br/>
<span class="id" title="var">Arguments</span> <a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> {<span class="id" title="var">A</span>%<span class="id" title="var">type</span> <span class="id" title="var">B</span>%<span class="id" title="var">type</span>} <span class="id" title="var">R</span>%<span class="id" title="var">rel</span> <span class="id" title="var">m</span> <span class="id" title="var">n</span> <span class="id" title="var">P</span>%<span class="id" title="var">type</span> <span class="id" title="var">Q</span>%<span class="id" title="var">type</span>.<br/>
<br/>
<span class="id" title="keyword">Ltac</span> <span class="id" title="var">relim</span> <span class="id" title="var">H</span> :=<br/>
<span class="id" title="keyword">lazymatch</span> <span class="id" title="keyword">goal</span> <span class="id" title="keyword">with</span><br/>
| |- ?<span class="id" title="var">Q</span> ⇒<br/>
<span class="id" title="tactic">apply</span> (<a class="idref" href="coqrel.RelDefinitions.html#relim"><span class="id" title="definition">relim</span></a> (<span class="id" title="var">Q</span>:=<span class="id" title="var">Q</span>) <span class="id" title="var">H</span>)<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
The resolution process is directed by the syntax of <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span>. We define
an instance for each function relator. The base case simply uses the
relational property as-is.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="relim_base"><span class="id" title="instance">relim_base</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) <span class="id" title="var">m</span> <span class="id" title="var">n</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#True"><span class="id" title="inductive">True</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a>) | 10.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab228"></a><h2 class="section">Destructing relational hypotheses</h2>
<div class="paragraph"> </div>
To make progress when the goal relates two pattern matching
constructions, we need to show that the two matched terms are
related, then destruct that hypothesis in a such a way that the two
terms reduce to constructors.
<div class="paragraph"> </div>
For most relators of inductive types, the constructors of the
relator will simply follow the constructors of the corresponding
type, so that destructing the relational hypothesis in the usual way
will produce the desired outcome. However, sometimes it is more
convenient to define such relators in a different way (see for
instance <span class="inlinecode"><a class="idref" href="coqrel.Relators.html#prod_rel"><span class="id" title="definition">prod_rel</span></a></span>). In that case, we can use the following
typeclass to specify an alternative way to destruct corresponding
hypotheses.
<div class="paragraph"> </div>
An instance of <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RDestruct"><span class="id" title="record">RDestruct</span></a></span> is somewhat similar to a stylized
induction principle. <span class="inlinecode"><a class="idref" href="compcert.flocq.Appli.Fappli_IEEE.html#T"><span class="id" title="variable">T</span></a></span> expands to a conjunction of subgoals in the
format expected by <span class="inlinecode"><span class="id" title="var">Delay.split_conjunction</span></span>. For instance, the
induction principle for <span class="inlinecode"><a class="idref" href="coqrel.Relators.html#sum_rel"><span class="id" title="inductive">sum_rel</span></a></span> is:
<pre>
sum_rel_ind:
forall ...,
(forall a1 a2, RA a1 a2 -> P (inl a1) (inl a2)) ->
(forall b1 b2, RB b1 b2 -> P (inr b1) (inr b2)) ->
(forall p1 p2, (RA + RB) p1 p2 -> P p1 p2)
</pre>
A corresponding instance of <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RDestruct"><span class="id" title="record">RDestruct</span></a></span> would be:
<pre>
sum_rdestruct:
RDestruct
(sum_rel RA RB)
(fun P =>
(forall a1 a2, RA a1 a2 -> P (inl a1) (inl a2)) /\
(forall b1 b2, RB b1 b2 -> P (inr b1) (inr b2)))
</pre>
In the case of <span class="inlinecode"><a class="idref" href="coqrel.Relators.html#sum_rel"><span class="id" title="inductive">sum_rel</span></a></span> however, which is defined as an inductive
type with similar structure to <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Datatypes.html#sum"><span class="id" title="inductive">sum</span></a></span>, we can rely on the default
instance of <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RDestruct"><span class="id" title="record">RDestruct</span></a></span>, which simply uses the <span class="inlinecode"><span class="id" title="tactic">destruct</span></span> tactic.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="RDestruct"><span class="id" title="record">RDestruct</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>: <span class="id" title="keyword">Type</span>} (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) (<span class="id" title="var">T</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <span class="id" title="keyword">Prop</span>) :=<br/>
<a name="rdestruct"><span class="id" title="projection">rdestruct</span></a> <span class="id" title="var">m</span> <span class="id" title="var">n</span>: <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <span class="id" title="keyword">∀</span> <span class="id" title="var">P</span>, <a class="idref" href="coqrel.RelDefinitions.html#T"><span class="id" title="variable">T</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a>.<br/>
<br/>
<span class="id" title="keyword">Ltac</span> <span class="id" title="var">rdestruct</span> <span class="id" title="var">H</span> :=<br/>
<span class="id" title="keyword">lazymatch</span> <span class="id" title="var">type</span> <span class="id" title="var">of</span> <span class="id" title="var">H</span> <span class="id" title="keyword">with</span><br/>
| ?<span class="id" title="var">R</span> ?<span class="id" title="var">m</span> ?<span class="id" title="var">n</span> ⇒<br/>
<span class="id" title="var">not_evar</span> <span class="id" title="var">R</span>;<br/>
<span class="id" title="tactic">pattern</span> <span class="id" title="var">m</span>, <span class="id" title="var">n</span>;<br/>
<span class="id" title="tactic">apply</span> (<a class="idref" href="coqrel.RelDefinitions.html#rdestruct"><span class="id" title="definition">rdestruct</span></a> (<span class="id" title="var">R</span>:=<span class="id" title="var">R</span>) <span class="id" title="var">m</span> <span class="id" title="var">n</span> <span class="id" title="var">H</span>);<br/>
<span class="id" title="tactic">clear</span> <span class="id" title="var">H</span>;<br/>
<span class="id" title="var">Delay.split_conjunction</span><br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
See the <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RDestruct"><span class="id" title="record">RDestruct</span></a></span> library for the corresponding instance of
<span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="record">RStep</span></a></span>, the default instance of <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RDestruct"><span class="id" title="record">RDestruct</span></a></span>, and a way to control
whether or not we should keep equations for the destructed terms.
<div class="paragraph"> </div>
<a name="lab229"></a><h2 class="section">Monotonicity properties</h2>
<div class="paragraph"> </div>
We use the class <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#Related"><span class="id" title="record">Related</span></a></span> for the user to declare monotonicity
properties. This is a generalization of <span class="inlinecode"><span class="id" title="var">Morphisms.Proper</span></span> from the
Coq standard library: although we expect that most of the time the
left- and right-hand side terms will be identical, they could be
slightly different partial applications of the same function.
<div class="paragraph"> </div>
Usually the differing arguments will be implicit, so that the user
can still rely on the <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#Monotonic"><span class="id" title="abbreviation">Monotonic</span></a></span> notation below. Occasionally, you
may need to spell out the two different terms and use the actual
class instead.
<div class="paragraph"> </div>
Note that the argument order below eschews the precedent of <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Classes.Morphisms.html#Proper"><span class="id" title="class">Proper</span></a></span>,
which has the relation first, followed by the proper element. This is
deliberate: we want the type parameters <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.common.AST.html#TRANSF_PARTIAL_FUNDEF.B"><span class="id" title="variable">B</span></a></span> to be unified in
priority against the type of <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span>, rather than that of <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span>.
In particular, the relator <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a></span> yields an eta-expanded type
of the form <span class="inlinecode">(<span class="id" title="keyword">fun</span></span> <span class="inlinecode"><a class="idref" href="compcert.flocq.Appli.Fappli_rnd_odd.html#Odd_prop_aux.x"><span class="id" title="variable">x</span></a></span> <span class="inlinecode">⇒</span> <span class="inlinecode"><a class="idref" href="compcert.flocq.Appli.Fappli_IEEE.html#T"><span class="id" title="variable">T</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.flocq.Appli.Fappli_rnd_odd.html#Odd_prop_aux.x"><span class="id" title="variable">x</span></a>)</span> <span class="inlinecode"><a class="idref" href="compcert.flocq.Appli.Fappli_rnd_odd.html#Odd_prop_aux.x"><span class="id" title="variable">x</span></a></span> for its arguments. When <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.common.AST.html#TRANSF_PARTIAL_FUNDEF.B"><span class="id" title="variable">B</span></a></span>
take this peculiar form, instances declared using <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a></span>
become unusable (I assume because no second-order unification is
performed when looking up the typeclass instance database). By
contrast the type of <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span> is much more likely to be in a
"reasonable" form.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Class</span> <a name="Related"><span class="id" title="record">Related</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">f</span>: <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a>) (<span class="id" title="var">g</span>: <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) :=<br/>
<a name="related"><span class="id" title="projection">related</span></a>: <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a>.<br/>
<br/>
<span class="id" title="var">Arguments</span> <a class="idref" href="coqrel.RelDefinitions.html#Related"><span class="id" title="class">Related</span></a> {<span class="id" title="var">A</span>%<span class="id" title="var">type</span> <span class="id" title="var">B</span>%<span class="id" title="var">type</span>} <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">R</span>%<span class="id" title="var">rel</span>.<br/>
<br/>
<span class="id" title="keyword">Notation</span> <a name="93ca6021ff0ea9f2bfbe13a21e6ae42d"><span class="id" title="notation">"</span></a>'@' 'Monotonic' T m R" := (@<a class="idref" href="coqrel.RelDefinitions.html#Related"><span class="id" title="class">Related</span></a> <span class="id" title="var">T</span> <span class="id" title="var">T</span> <span class="id" title="var">m</span> <span class="id" title="var">m</span> <span class="id" title="var">R</span>%<span class="id" title="var">rel</span>)<br/>
(<span class="id" title="tactic">at</span> <span class="id" title="keyword">level</span> 10, <span class="id" title="var">T</span> <span class="id" title="tactic">at</span> <span class="id" title="var">next</span> <span class="id" title="keyword">level</span>, <span class="id" title="var">R</span> <span class="id" title="tactic">at</span> <span class="id" title="var">next</span> <span class="id" title="keyword">level</span>, <span class="id" title="var">m</span> <span class="id" title="tactic">at</span> <span class="id" title="var">next</span> <span class="id" title="keyword">level</span>).<br/>
<br/>
<span class="id" title="keyword">Notation</span> <a name="Monotonic"><span class="id" title="abbreviation">Monotonic</span></a> <span class="id" title="var">m</span> <span class="id" title="var">R</span> := (<a class="idref" href="coqrel.RelDefinitions.html#Related"><span class="id" title="class">Related</span></a> <span class="id" title="var">m</span> <span class="id" title="var">m</span> <span class="id" title="var">R</span>%<span class="id" title="var">rel</span>).<br/>
<br/>
</div>
<div class="doc">
We provide a <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="record">RStep</span></a></span> instance for unfolding <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#Related"><span class="id" title="record">Related</span></a></span>.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <a name="unfold_monotonic_rstep"><span class="id" title="lemma">unfold_monotonic_rstep</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) <span class="id" title="var">m</span> <span class="id" title="var">n</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="class">RStep</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#Related"><span class="id" title="class">Related</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#RStep"><span class="id" title="class">RStep</span></a> <span class="id" title="var">_</span> (<a class="idref" href="coqrel.RelDefinitions.html#Related"><span class="id" title="class">Related</span></a> <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span>)) ⇒<br/>
<span class="id" title="tactic">eapply</span> <a class="idref" href="coqrel.RelDefinitions.html#unfold_monotonic_rstep"><span class="id" title="lemma">unfold_monotonic_rstep</span></a> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab230"></a><h2 class="section">Order on relations</h2>
<div class="paragraph"> </div>
This is our generalization of <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Classes.RelationClasses.html#subrelation"><span class="id" title="class">subrelation</span></a></span>. Like the original it
constitutes a preorder, and the union and intersection of relations
are the corresponding join and meet.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <a name="subrel"><span class="id" title="definition">subrel</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>}: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) :=<br/>
<span class="id" title="keyword">fun</span> <span class="id" title="var">R1</span> <span class="id" title="var">R2</span> ⇒ <span class="id" title="keyword">∀</span> <span class="id" title="var">x</span> <span class="id" title="var">y</span>, <a class="idref" href="coqrel.RelDefinitions.html#R1"><span class="id" title="variable">R1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#x"><span class="id" title="variable">x</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y"><span class="id" title="variable">y</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R2"><span class="id" title="variable">R2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#x"><span class="id" title="variable">x</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y"><span class="id" title="variable">y</span></a>.<br/>
<br/>
<span class="id" title="var">Arguments</span> <a class="idref" href="coqrel.RelDefinitions.html#subrel"><span class="id" title="definition">subrel</span></a> {<span class="id" title="var">A</span>%<span class="id" title="var">type</span> <span class="id" title="var">B</span>%<span class="id" title="var">type</span>} <span class="id" title="var">R1</span>%<span class="id" title="var">rel</span> <span class="id" title="var">R2</span>%<span class="id" title="var">rel</span>.<br/>
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="subrel_preorder"><span class="id" title="instance">subrel_preorder</span></a> <span class="id" title="var">A</span> <span class="id" title="var">B</span>:<br/>
@<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Classes.RelationClasses.html#PreOrder"><span class="id" title="class">PreOrder</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#subrel"><span class="id" title="definition">subrel</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">split</span>; <span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="eq_subrel"><span class="id" title="instance">eq_subrel</span></a> {<span class="id" title="var">A</span>} (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a>):<br/>
<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Classes.RelationClasses.html#Reflexive"><span class="id" title="class">Reflexive</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.RelDefinitions.html#Related"><span class="id" title="class">Related</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#eq"><span class="id" title="inductive">eq</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#subrel"><span class="id" title="definition">subrel</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">HR</span> <span class="id" title="var">x</span> <span class="id" title="var">y</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">subst</span>.<br/>
<span class="id" title="tactic">reflexivity</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Instance</span> <a name="subrel_impl_relim"><span class="id" title="instance">subrel_impl_relim</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">R1</span> <span class="id" title="var">R2</span> : <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) <span class="id" title="var">x1</span> <span class="id" title="var">x2</span> <span class="id" title="var">y1</span> <span class="id" title="var">y2</span> <span class="id" title="var">P</span> <span class="id" title="var">Q</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#impl"><span class="id" title="definition">impl</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#R1"><span class="id" title="variable">R1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#x1"><span class="id" title="variable">x1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y1"><span class="id" title="variable">y1</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#R2"><span class="id" title="variable">R2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#x2"><span class="id" title="variable">x2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y2"><span class="id" title="variable">y2</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> <a class="idref" href="coqrel.RelDefinitions.html#subrel"><span class="id" title="definition">subrel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R1"><span class="id" title="variable">R1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R2"><span class="id" title="variable">R2</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#x1"><span class="id" title="variable">x1</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#1c39bf18749e5cc609e83c0a0ba5a372"><span class="id" title="notation">=</span></a> <a class="idref" href="coqrel.RelDefinitions.html#x2"><span class="id" title="variable">x2</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d82a7d96d3659d805ffe732283716822"><span class="id" title="notation">∧</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y1"><span class="id" title="variable">y1</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#1c39bf18749e5cc609e83c0a0ba5a372"><span class="id" title="notation">=</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y2"><span class="id" title="variable">y2</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d82a7d96d3659d805ffe732283716822"><span class="id" title="notation">∧</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">cbv</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="tactic">subst</span>.<br/>
<span class="id" title="tactic">eauto</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab231"></a><h1 class="section">Core relators</h1>
<div class="paragraph"> </div>
First, we introduce the core relators necessary for everything
else, namely those for function types. The next section provides a
more comprehensive library which covers many of the basic inductive
type constructors as well.
<div class="paragraph"> </div>
<a name="lab232"></a><h3 class="section">Non-dependent function types</h3>
<div class="paragraph"> </div>
First, I define relators for non-dependent functions. This
generalizes <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Classes.Morphisms.html#respectful"><span class="id" title="definition">respectful</span></a></span>.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <a name="arrow_rel"><span class="id" title="definition">arrow_rel</span></a> {<span class="id" title="var">A1</span> <span class="id" title="var">A2</span> <span class="id" title="var">B1</span> <span class="id" title="var">B2</span>}:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A1"><span class="id" title="variable">A1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A2"><span class="id" title="variable">A2</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B1"><span class="id" title="variable">B1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B2"><span class="id" title="variable">B2</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#A1"><span class="id" title="variable">A1</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B1"><span class="id" title="variable">B1</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#A2"><span class="id" title="variable">A2</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B2"><span class="id" title="variable">B2</span></a>) :=<br/>
<span class="id" title="keyword">fun</span> <span class="id" title="var">RA</span> <span class="id" title="var">RB</span> <span class="id" title="var">f</span> <span class="id" title="var">g</span> ⇒ <span class="id" title="keyword">∀</span> <span class="id" title="var">x</span> <span class="id" title="var">y</span>, <a class="idref" href="coqrel.RelDefinitions.html#RA"><span class="id" title="variable">RA</span></a> <a class="idref" href="coqrel.RelDefinitions.html#x"><span class="id" title="variable">x</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y"><span class="id" title="variable">y</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#RB"><span class="id" title="variable">RB</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#x"><span class="id" title="variable">x</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y"><span class="id" title="variable">y</span></a>).<br/>
<br/>
<span class="id" title="var">Arguments</span> <a class="idref" href="coqrel.RelDefinitions.html#arrow_rel"><span class="id" title="definition">arrow_rel</span></a> {<span class="id" title="var">A1</span>%<span class="id" title="var">type</span> <span class="id" title="var">A2</span>%<span class="id" title="var">type</span> <span class="id" title="var">B1</span>%<span class="id" title="var">type</span> <span class="id" title="var">B2</span>%<span class="id" title="var">type</span>} <span class="id" title="var">RA</span>%<span class="id" title="var">rel</span> <span class="id" title="var">RB</span>%<span class="id" title="var">rel</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span>.<br/>
<br/>
<span class="id" title="keyword">Notation</span> <a name="e7acdf91669d82873f44a60e56ad44ff"><span class="id" title="notation">"</span></a>RA ==> RB" := (<a class="idref" href="coqrel.RelDefinitions.html#arrow_rel"><span class="id" title="definition">arrow_rel</span></a> <span class="id" title="var">RA</span> <span class="id" title="var">RB</span>)<br/>
(<span class="id" title="tactic">at</span> <span class="id" title="keyword">level</span> 55, <span class="id" title="tactic">right</span> <span class="id" title="keyword">associativity</span>) : <span class="id" title="var">rel_scope</span>.<br/>
<br/>
<span class="id" title="keyword">Notation</span> <a name="d5d0ad6beccd25d5224442d64ed307d5"><span class="id" title="notation">"</span></a>RA ++> RB" := (<a class="idref" href="coqrel.RelDefinitions.html#arrow_rel"><span class="id" title="definition">arrow_rel</span></a> <span class="id" title="var">RA</span> <span class="id" title="var">RB</span>)<br/>
(<span class="id" title="tactic">at</span> <span class="id" title="keyword">level</span> 55, <span class="id" title="tactic">right</span> <span class="id" title="keyword">associativity</span>) : <span class="id" title="var">rel_scope</span>.<br/>
<br/>
<span class="id" title="keyword">Notation</span> <a name="28fb2fb3952fac7e01eb907871e1ea99"><span class="id" title="notation">"</span></a>RA --> RB" := (<a class="idref" href="coqrel.RelDefinitions.html#arrow_rel"><span class="id" title="definition">arrow_rel</span></a> (<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a> <span class="id" title="var">RA</span>) <span class="id" title="var">RB</span>)<br/>
(<span class="id" title="tactic">at</span> <span class="id" title="keyword">level</span> 55, <span class="id" title="tactic">right</span> <span class="id" title="keyword">associativity</span>) : <span class="id" title="var">rel_scope</span>.<br/>
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="arrow_subrel"><span class="id" title="instance">arrow_subrel</span></a> {<span class="id" title="var">A1</span> <span class="id" title="var">A2</span> <span class="id" title="var">B1</span> <span class="id" title="var">B2</span>}:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#Monotonic"><span class="id" title="abbreviation">Monotonic</span></a> (@<a class="idref" href="coqrel.RelDefinitions.html#arrow_rel"><span class="id" title="definition">arrow_rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A1"><span class="id" title="variable">A1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A2"><span class="id" title="variable">A2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B1"><span class="id" title="variable">B1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B2"><span class="id" title="variable">B2</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#subrel"><span class="id" title="definition">subrel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#28fb2fb3952fac7e01eb907871e1ea99"><span class="id" title="notation">--></span></a> <a class="idref" href="coqrel.RelDefinitions.html#subrel"><span class="id" title="definition">subrel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#d5d0ad6beccd25d5224442d64ed307d5"><span class="id" title="notation">++></span></a> <a class="idref" href="coqrel.RelDefinitions.html#subrel"><span class="id" title="definition">subrel</span></a>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="arrow_subrel_params"><span class="id" title="instance">arrow_subrel_params</span></a>:<br/>
<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Classes.Morphisms.html#Params"><span class="id" title="class">Params</span></a> (@<a class="idref" href="coqrel.RelDefinitions.html#arrow_rel"><span class="id" title="definition">arrow_rel</span></a>) 4.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <a name="arrow_rintro"><span class="id" title="lemma">arrow_rintro</span></a> {<span class="id" title="var">A1</span> <span class="id" title="var">A2</span> <span class="id" title="var">B1</span> <span class="id" title="var">B2</span>} (<span class="id" title="var">RA</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A1"><span class="id" title="variable">A1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A2"><span class="id" title="variable">A2</span></a>) (<span class="id" title="var">RB</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B1"><span class="id" title="variable">B1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B2"><span class="id" title="variable">B2</span></a>) <span class="id" title="var">f</span> <span class="id" title="var">g</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="class">RIntro</span></a> (<span class="id" title="keyword">∀</span> <span class="id" title="var">x</span> <span class="id" title="var">y</span>, <a class="idref" href="coqrel.RelDefinitions.html#RA"><span class="id" title="variable">RA</span></a> <a class="idref" href="coqrel.RelDefinitions.html#x"><span class="id" title="variable">x</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y"><span class="id" title="variable">y</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#RB"><span class="id" title="variable">RB</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#x"><span class="id" title="variable">x</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a> <a class="idref" href="coqrel.RelDefinitions.html#y"><span class="id" title="variable">y</span></a>)) (<a class="idref" href="coqrel.RelDefinitions.html#RA"><span class="id" title="variable">RA</span></a> <a class="idref" href="coqrel.RelDefinitions.html#d5d0ad6beccd25d5224442d64ed307d5"><span class="id" title="notation">++></span></a> <a class="idref" href="coqrel.RelDefinitions.html#RB"><span class="id" title="variable">RB</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 0 (<a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="class">RIntro</span></a> <span class="id" title="var">_</span> (<span class="id" title="var">_</span> <a class="idref" href="coqrel.RelDefinitions.html#d5d0ad6beccd25d5224442d64ed307d5"><span class="id" title="notation">++></span></a> <span class="id" title="var">_</span>) <span class="id" title="var">_</span> <span class="id" title="var">_</span>) ⇒<br/>
<span class="id" title="tactic">eapply</span> <a class="idref" href="coqrel.RelDefinitions.html#arrow_rintro"><span class="id" title="lemma">arrow_rintro</span></a> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <a name="arrow_relim"><span class="id" title="lemma">arrow_relim</span></a> {<span class="id" title="var">A1</span> <span class="id" title="var">A2</span> <span class="id" title="var">B1</span> <span class="id" title="var">B2</span>} <span class="id" title="var">RA</span> <span class="id" title="var">RB</span> <span class="id" title="var">f</span> <span class="id" title="var">g</span> <span class="id" title="var">m</span> <span class="id" title="var">n</span> <span class="id" title="var">P</span> <span class="id" title="var">Q</span>:<br/>
@<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B1"><span class="id" title="variable">B1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B2"><span class="id" title="variable">B2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#RB"><span class="id" title="variable">RB</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
@<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#A1"><span class="id" title="variable">A1</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B1"><span class="id" title="variable">B1</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#A2"><span class="id" title="variable">A2</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B2"><span class="id" title="variable">B2</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#RA"><span class="id" title="variable">RA</span></a> <a class="idref" href="coqrel.RelDefinitions.html#d5d0ad6beccd25d5224442d64ed307d5"><span class="id" title="notation">++></span></a> <a class="idref" href="coqrel.RelDefinitions.html#RB"><span class="id" title="variable">RB</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#RA"><span class="id" title="variable">RA</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d82a7d96d3659d805ffe732283716822"><span class="id" title="notation">∧</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> (<span class="id" title="var">_</span> <a class="idref" href="coqrel.RelDefinitions.html#d5d0ad6beccd25d5224442d64ed307d5"><span class="id" title="notation">++></span></a> <span class="id" title="var">_</span>) <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span>) ⇒<br/>
<span class="id" title="tactic">eapply</span> <a class="idref" href="coqrel.RelDefinitions.html#arrow_relim"><span class="id" title="lemma">arrow_relim</span></a> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab233"></a><h3 class="section">Dependent products</h3>
<div class="paragraph"> </div>
Now we consider the dependent case. The definition of <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a></span>
is somewhat involved, but you can think of relating <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span> in
the context of a structure-preserving transformation from a quiver
(<span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#EVAL_INJECT.V"><span class="id" title="variable">V</span></a></span>, <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#E"><span class="id" title="variable">E</span></a></span>) to the quiver (<span class="inlinecode"><span class="id" title="keyword">Type</span></span>, <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a></span>). Like a functor, it has two
components: <span class="inlinecode"><span class="id" title="var">FV</span></span> maps nodes to types, and <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#FE"><span class="id" title="variable">FE</span></a></span> maps edges to
relations. Then, <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a></span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#FE"><span class="id" title="variable">FE</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span> states that given an edge
<span class="inlinecode">(<a class="idref" href="compcert.x86.SelectLongproof.html#CMCONSTR.e"><span class="id" title="variable">e</span></a></span> <span class="inlinecode">:</span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#E"><span class="id" title="variable">E</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#POSITIVE_ITERATION.v1"><span class="id" title="variable">v1</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#v2"><span class="id" title="variable">v2</span></a>)</span>, the images <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#POSITIVE_ITERATION.v1"><span class="id" title="variable">v1</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#v2"><span class="id" title="variable">v2</span></a></span> are related by the
corresponding relation <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#FE"><span class="id" title="variable">FE</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#POSITIVE_ITERATION.v1"><span class="id" title="variable">v1</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#v2"><span class="id" title="variable">v2</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.x86.SelectLongproof.html#CMCONSTR.e"><span class="id" title="variable">e</span></a></span>. We will write <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a></span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#FE"><span class="id" title="variable">FE</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span>
as <span class="inlinecode">(<span class="id" title="var">forallr</span></span> <span class="inlinecode"><a class="idref" href="compcert.x86.SelectLongproof.html#CMCONSTR.e"><span class="id" title="variable">e</span></a></span> <span class="inlinecode">@</span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#POSITIVE_ITERATION.v1"><span class="id" title="variable">v1</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#v2"><span class="id" title="variable">v2</span></a></span> <span class="inlinecode">:</span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#E"><span class="id" title="variable">E</span></a>,</span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#FE"><span class="id" title="variable">FE</span></a>[<a class="idref" href="compcert.lib.Coqlib.html#POSITIVE_ITERATION.v1"><span class="id" title="variable">v1</span></a>,<a class="idref" href="compcert.lib.Coqlib.html#v2"><span class="id" title="variable">v2</span></a>,<a class="idref" href="compcert.x86.SelectLongproof.html#CMCONSTR.e"><span class="id" title="variable">e</span></a>])</span> <span class="inlinecode"><a class="idref" href="compcert.backend.Bounds.html#BOUNDS.f"><span class="id" title="variable">f</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#g"><span class="id" title="variable">g</span></a></span>. Notice that this notation
binds <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#POSITIVE_ITERATION.v1"><span class="id" title="variable">v1</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#v2"><span class="id" title="variable">v2</span></a></span> as well as <span class="inlinecode"><a class="idref" href="compcert.x86.SelectLongproof.html#CMCONSTR.e"><span class="id" title="variable">e</span></a></span>.
<div class="paragraph"> </div>
If that makes no sense, you can think of specific source quivers. So
for instance, oftentimes we will want to use (<span class="inlinecode"><span class="id" title="keyword">Type</span></span>, <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a></span>) as the
source quiver too. This corresponds to parametric polymorphism. The
type of <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Datatypes.html#Some"><span class="id" title="constructor">Some</span></a></span> is <span class="inlinecode"><span class="id" title="keyword">∀</span></span> <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span> <span class="inlinecode">:</span> <span class="inlinecode"><span class="id" title="keyword">Type</span>,</span> <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Datatypes.html#option"><span class="id" title="inductive">option</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.x86.Op.html#SOUNDNESS.A"><span class="id" title="variable">A</span></a></span>; the corresponding
logical relation is <span class="inlinecode"><span class="id" title="var">forallr</span></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> <span class="inlinecode">@</span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#A1"><span class="id" title="variable">A1</span></a></span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#A2"><span class="id" title="variable">A2</span></a></span> <span class="inlinecode">:</span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a>,</span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> <span class="inlinecode">++></span> <span class="inlinecode"><a class="idref" href="coqrel.Relators.html#option_rel"><span class="id" title="inductive">option_rel</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span>. Stating
that <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#Monotonic"><span class="id" title="abbreviation">Monotonic</span></a></span> <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Datatypes.html#Some"><span class="id" title="constructor">Some</span></a></span> <span class="inlinecode">(<span class="id" title="var">foralr</span></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> <span class="inlinecode">@</span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#A1"><span class="id" title="variable">A1</span></a></span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#A2"><span class="id" title="variable">A2</span></a></span> <span class="inlinecode">:</span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a>,</span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> <span class="inlinecode">++></span> <span class="inlinecode"><a class="idref" href="coqrel.Relators.html#option_rel"><span class="id" title="inductive">option_rel</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a>)</span> means that,
given any relation <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> and elements <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#x1"><span class="id" title="variable">x1</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#x2"><span class="id" title="variable">x2</span></a></span>, if <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> relates
<span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#x1"><span class="id" title="variable">x1</span></a></span> and <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#x2"><span class="id" title="variable">x2</span></a></span>, then <span class="inlinecode"><a class="idref" href="coqrel.Relators.html#option_rel"><span class="id" title="inductive">option_rel</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> will relate <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Datatypes.html#Some"><span class="id" title="constructor">Some</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#x1"><span class="id" title="variable">x1</span></a></span> and <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Datatypes.html#Some"><span class="id" title="constructor">Some</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.lib.Coqlib.html#x2"><span class="id" title="variable">x2</span></a></span>.
<div class="paragraph"> </div>
Another example from <span class="inlinecode"><span class="id" title="var">liblayers</span></span> is the quiver of our data-indexed
simulation relations <span class="inlinecode"><a class="idref" href="liblayers.simrel.SimrelDefinition.html#simrel"><span class="id" title="record">simrel</span></a></span> <span class="inlinecode">:</span> <span class="inlinecode"><a class="idref" href="liblayers.simrel.AbstractData.html#layerdata"><span class="id" title="record">layerdata</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><a class="idref" href="liblayers.simrel.AbstractData.html#layerdata"><span class="id" title="record">layerdata</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><span class="id" title="keyword">Type</span></span>.
Here the structure-preserving transformations are our simulation
relation diagrams, which have types such as
<span class="inlinecode"><span class="id" title="var">lsim</span></span> <span class="inlinecode">:</span> <span class="inlinecode"><span class="id" title="keyword">∀</span></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D1"><span class="id" title="variable">D1</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D2"><span class="id" title="variable">D2</span></a>,</span> <span class="inlinecode"><a class="idref" href="liblayers.simrel.SimrelDefinition.html#simrel"><span class="id" title="record">simrel</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D1"><span class="id" title="variable">D1</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D2"><span class="id" title="variable">D2</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a></span> <span class="inlinecode">(<a class="idref" href="liblayers.logic.Layers.html#layer"><span class="id" title="variable">layer</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D1"><span class="id" title="variable">D1</span></a>)</span> <span class="inlinecode">(<a class="idref" href="liblayers.logic.Layers.html#layer"><span class="id" title="variable">layer</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D2"><span class="id" title="variable">D2</span></a>)</span> or
<span class="inlinecode"><span class="id" title="var">psim</span></span> <span class="inlinecode">:</span> <span class="inlinecode"><span class="id" title="keyword">∀</span></span> <span class="inlinecode">{<a class="idref" href="liblayers.logic.Structures.html#D1"><span class="id" title="variable">D1</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D2"><span class="id" title="variable">D2</span></a>},</span> <span class="inlinecode"><a class="idref" href="liblayers.simrel.SimrelDefinition.html#simrel"><span class="id" title="record">simrel</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D1"><span class="id" title="variable">D1</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D2"><span class="id" title="variable">D2</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a></span> <span class="inlinecode">(<a class="idref" href="liblayers.logic.Primitives.html#primsem"><span class="id" title="variable">primsem</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D1"><span class="id" title="variable">D1</span></a>)</span> <span class="inlinecode">(<a class="idref" href="liblayers.logic.Primitives.html#primsem"><span class="id" title="variable">primsem</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D2"><span class="id" title="variable">D2</span></a>)</span>.
Then, the monotonicity of a data-indexed function —
say, <span class="inlinecode"><span class="id" title="var">foo</span>:</span> <span class="inlinecode"><span class="id" title="keyword">∀</span></span> <span class="inlinecode"><a class="idref" href="coqrel.RelOperators.html#D"><span class="id" title="variable">D</span></a></span> <span class="inlinecode">:</span> <span class="inlinecode"><a class="idref" href="liblayers.simrel.AbstractData.html#layerdata"><span class="id" title="record">layerdata</span></a>,</span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Layers.html#layer"><span class="id" title="variable">layer</span></a></span> <span class="inlinecode"><a class="idref" href="coqrel.RelOperators.html#D"><span class="id" title="variable">D</span></a></span> <span class="inlinecode">→</span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Primitives.html#primsem"><span class="id" title="variable">primsem</span></a></span> <span class="inlinecode"><a class="idref" href="coqrel.RelOperators.html#D"><span class="id" title="variable">D</span></a></span> —
can be expressed as
<span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#Monotonic"><span class="id" title="abbreviation">Monotonic</span></a></span> <span class="inlinecode"><span class="id" title="var">foo</span></span> <span class="inlinecode">(<span class="id" title="keyword">∀</span></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> <span class="inlinecode">@</span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D1"><span class="id" title="variable">D1</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D2"><span class="id" title="variable">D2</span></a></span> <span class="inlinecode">:</span> <span class="inlinecode"><a class="idref" href="liblayers.simrel.SimrelDefinition.html#simrel"><span class="id" title="record">simrel</span></a>,</span> <span class="inlinecode"><span class="id" title="var">siml</span></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D1"><span class="id" title="variable">D1</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D2"><span class="id" title="variable">D2</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a></span> <span class="inlinecode">++></span> <span class="inlinecode"><span class="id" title="var">simp</span></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D1"><span class="id" title="variable">D1</span></a></span> <span class="inlinecode"><a class="idref" href="liblayers.logic.Structures.html#D2"><span class="id" title="variable">D2</span></a></span> <span class="inlinecode"><a class="idref" href="compcert.backend.Locations.html#R"><span class="id" title="constructor">R</span></a>)</span> <span class="inlinecode"><span class="id" title="var">foo</span></span>.
<div class="paragraph"> </div>
This definition is the same as <span class="inlinecode"><span class="id" title="var">respectful_hetero</span></span>.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <a name="forall_rel"><span class="id" title="definition">forall_rel</span></a> {<span class="id" title="var">V1</span> <span class="id" title="var">V2</span>} {<span class="id" title="var">E</span>: <a class="idref" href="coqrel.RelDefinitions.html#V1"><span class="id" title="variable">V1</span></a><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><a class="idref" href="coqrel.RelDefinitions.html#V2"><span class="id" title="variable">V2</span></a><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><span class="id" title="keyword">Type</span>} {<span class="id" title="var">FV1</span>: <a class="idref" href="coqrel.RelDefinitions.html#V1"><span class="id" title="variable">V1</span></a><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><span class="id" title="keyword">Type</span>} {<span class="id" title="var">FV2</span>: <a class="idref" href="coqrel.RelDefinitions.html#V2"><span class="id" title="variable">V2</span></a><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><span class="id" title="keyword">Type</span>}:<br/>
<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">(</span></a><span class="id" title="keyword">∀</span> <span class="id" title="var">v1</span> <span class="id" title="var">v2</span>, <a class="idref" href="coqrel.RelDefinitions.html#E"><span class="id" title="variable">E</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v1"><span class="id" title="variable">v1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v2"><span class="id" title="variable">v2</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#FV1"><span class="id" title="variable">FV1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v1"><span class="id" title="variable">v1</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#FV2"><span class="id" title="variable">FV2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v2"><span class="id" title="variable">v2</span></a>)<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">)</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> (<span class="id" title="keyword">∀</span> <span class="id" title="var">v1</span>, <a class="idref" href="coqrel.RelDefinitions.html#FV1"><span class="id" title="variable">FV1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v1"><span class="id" title="variable">v1</span></a>) (<span class="id" title="keyword">∀</span> <span class="id" title="var">v2</span>, <a class="idref" href="coqrel.RelDefinitions.html#FV2"><span class="id" title="variable">FV2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v2"><span class="id" title="variable">v2</span></a>) :=<br/>
<span class="id" title="keyword">fun</span> <span class="id" title="var">FE</span> <span class="id" title="var">f</span> <span class="id" title="var">g</span> ⇒<br/>
<span class="id" title="keyword">∀</span> <span class="id" title="var">v1</span> <span class="id" title="var">v2</span> (<span class="id" title="var">e</span>: <a class="idref" href="coqrel.RelDefinitions.html#E"><span class="id" title="variable">E</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v1"><span class="id" title="variable">v1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v2"><span class="id" title="variable">v2</span></a>), <a class="idref" href="coqrel.RelDefinitions.html#FE"><span class="id" title="variable">FE</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v1"><span class="id" title="variable">v1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v2"><span class="id" title="variable">v2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#e"><span class="id" title="variable">e</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v1"><span class="id" title="variable">v1</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v2"><span class="id" title="variable">v2</span></a>).<br/>
<br/>
<span class="id" title="var">Arguments</span> <a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a> {<span class="id" title="var">V1</span>%<span class="id" title="var">type</span> <span class="id" title="var">V2</span>%<span class="id" title="var">type</span> <span class="id" title="var">E</span>%<span class="id" title="var">type</span> <span class="id" title="var">FV1</span>%<span class="id" title="var">type</span> <span class="id" title="var">FV2</span>%<span class="id" title="var">type</span>} <span class="id" title="var">FE</span>%<span class="id" title="var">rel</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span>.<br/>
<br/>
<span class="id" title="keyword">Notation</span> <a name="2f92680c001ef5f82af3e1bfcf843963"><span class="id" title="notation">"</span></a>'forallr' e @ v1 v2 : E , R" :=<br/>
(<a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a> (<span class="id" title="var">E</span> := <span class="id" title="var">E</span>) (<span class="id" title="keyword">fun</span> <span class="id" title="var">v1</span> <span class="id" title="var">v2</span> <span class="id" title="var">e</span> ⇒ <span class="id" title="var">R</span>))<br/>
(<span class="id" title="tactic">at</span> <span class="id" title="keyword">level</span> 200, <span class="id" title="var">e</span> <span class="id" title="var">ident</span>, <span class="id" title="var">v1</span> <span class="id" title="var">ident</span>, <span class="id" title="var">v2</span> <span class="id" title="var">ident</span>, <span class="id" title="tactic">right</span> <span class="id" title="keyword">associativity</span>) : <span class="id" title="var">rel_scope</span>.<br/>
<br/>
<span class="id" title="keyword">Notation</span> <a name="ab6dd54712ec60f35d1cc9e0f9f691be"><span class="id" title="notation">"</span></a>'forallr' e @ v1 v2 , R" :=<br/>
(<a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a> (<span class="id" title="keyword">fun</span> <span class="id" title="var">v1</span> <span class="id" title="var">v2</span> <span class="id" title="var">e</span> ⇒ <span class="id" title="var">R</span>))<br/>
(<span class="id" title="tactic">at</span> <span class="id" title="keyword">level</span> 200, <span class="id" title="var">e</span> <span class="id" title="var">ident</span>, <span class="id" title="var">v1</span> <span class="id" title="var">ident</span>, <span class="id" title="var">v2</span> <span class="id" title="var">ident</span>, <span class="id" title="tactic">right</span> <span class="id" title="keyword">associativity</span>) : <span class="id" title="var">rel_scope</span>.<br/>
<br/>
<span class="id" title="keyword">Notation</span> <a name="ef8a4fe55e608d2e85bfb8f534c6a41a"><span class="id" title="notation">"</span></a>'forallr' e : E , R" :=<br/>
(<a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a> (<span class="id" title="var">E</span> := <span class="id" title="var">E</span>) (<span class="id" title="keyword">fun</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">e</span> ⇒ <span class="id" title="var">R</span>))<br/>
(<span class="id" title="tactic">at</span> <span class="id" title="keyword">level</span> 200, <span class="id" title="var">e</span> <span class="id" title="var">ident</span>, <span class="id" title="tactic">right</span> <span class="id" title="keyword">associativity</span>) : <span class="id" title="var">rel_scope</span>.<br/>
<br/>
<span class="id" title="keyword">Notation</span> <a name="1bd22793714b33e291f1b6c3b141e214"><span class="id" title="notation">"</span></a>'forallr' e , R" :=<br/>
(<a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a> (<span class="id" title="keyword">fun</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">e</span> ⇒ <span class="id" title="var">R</span>))<br/>
(<span class="id" title="tactic">at</span> <span class="id" title="keyword">level</span> 200, <span class="id" title="var">e</span> <span class="id" title="var">ident</span>, <span class="id" title="tactic">right</span> <span class="id" title="keyword">associativity</span>) : <span class="id" title="var">rel_scope</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <a name="forall_rintro"><span class="id" title="lemma">forall_rintro</span></a> {<span class="id" title="var">V1</span> <span class="id" title="var">V2</span> <span class="id" title="var">E</span> <span class="id" title="var">F1</span> <span class="id" title="var">F2</span>} (<span class="id" title="var">FE</span>: <span class="id" title="keyword">∀</span> <span class="id" title="var">x</span> <span class="id" title="var">y</span>, <span class="id" title="var">_</span> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a> <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <span class="id" title="var">_</span> <span class="id" title="var">_</span>) <span class="id" title="var">f</span> <span class="id" title="var">g</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="class">RIntro</span></a><br/>
(<span class="id" title="keyword">∀</span> <span class="id" title="var">u</span> <span class="id" title="var">v</span> <span class="id" title="var">e</span>, <a class="idref" href="coqrel.RelDefinitions.html#FE"><span class="id" title="variable">FE</span></a> <a class="idref" href="coqrel.RelDefinitions.html#u"><span class="id" title="variable">u</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v"><span class="id" title="variable">v</span></a> <a class="idref" href="coqrel.RelDefinitions.html#e"><span class="id" title="variable">e</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#u"><span class="id" title="variable">u</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v"><span class="id" title="variable">v</span></a>))<br/>
(@<a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#V1"><span class="id" title="variable">V1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#V2"><span class="id" title="variable">V2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#E"><span class="id" title="variable">E</span></a> <a class="idref" href="coqrel.RelDefinitions.html#F1"><span class="id" title="variable">F1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#F2"><span class="id" title="variable">F2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#FE"><span class="id" title="variable">FE</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 0 (<a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="class">RIntro</span></a> <span class="id" title="var">_</span> (<a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a> <span class="id" title="var">_</span>) <span class="id" title="var">_</span> <span class="id" title="var">_</span>) ⇒<br/>
<span class="id" title="tactic">eapply</span> <a class="idref" href="coqrel.RelDefinitions.html#forall_rintro"><span class="id" title="lemma">forall_rintro</span></a> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <a name="forall_relim"><span class="id" title="lemma">forall_relim</span></a> {<span class="id" title="var">V1</span> <span class="id" title="var">V2</span> <span class="id" title="var">E</span> <span class="id" title="var">FV1</span> <span class="id" title="var">FV2</span>} <span class="id" title="var">R</span> <span class="id" title="var">f</span> <span class="id" title="var">g</span> <span class="id" title="var">v1</span> <span class="id" title="var">v2</span> <span class="id" title="var">e</span> <span class="id" title="var">P</span> <span class="id" title="var">Q</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v1"><span class="id" title="variable">v1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v2"><span class="id" title="variable">v2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#e"><span class="id" title="variable">e</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v1"><span class="id" title="variable">v1</span></a>) (<a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a> <a class="idref" href="coqrel.RelDefinitions.html#v2"><span class="id" title="variable">v2</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> (@<a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#V1"><span class="id" title="variable">V1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#V2"><span class="id" title="variable">V2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#E"><span class="id" title="variable">E</span></a> <a class="idref" href="coqrel.RelDefinitions.html#FV1"><span class="id" title="variable">FV1</span></a> <a class="idref" href="coqrel.RelDefinitions.html#FV2"><span class="id" title="variable">FV2</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#f"><span class="id" title="variable">f</span></a> <a class="idref" href="coqrel.RelDefinitions.html#g"><span class="id" title="variable">g</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#forall_rel"><span class="id" title="definition">forall_rel</span></a> <span class="id" title="var">_</span>) <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span>) ⇒<br/>
<span class="id" title="tactic">eapply</span> <a class="idref" href="coqrel.RelDefinitions.html#forall_relim"><span class="id" title="lemma">forall_relim</span></a> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
</div>
<div class="doc">
<a name="lab234"></a><h2 class="section">Inverse relation</h2>
<div class="paragraph"> </div>
We use <span class="inlinecode"><a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a></span> as our inversion relator. To this end we
characterize its variance and introduce an <span class="inlinecode"><a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="record">RElim</span></a></span> rule.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="flip_subrel"><span class="id" title="instance">flip_subrel</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>}:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#Monotonic"><span class="id" title="abbreviation">Monotonic</span></a> (@<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a> <span class="id" title="keyword">Prop</span>) (<a class="idref" href="coqrel.RelDefinitions.html#subrel"><span class="id" title="definition">subrel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#d5d0ad6beccd25d5224442d64ed307d5"><span class="id" title="notation">++></span></a> <a class="idref" href="coqrel.RelDefinitions.html#subrel"><span class="id" title="definition">subrel</span></a>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Global Instance</span> <a name="flip_subrel_params"><span class="id" title="instance">flip_subrel_params</span></a>:<br/>
<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Classes.Morphisms.html#Params"><span class="id" title="class">Params</span></a> (@<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a>) 3.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <a name="flip_rintro"><span class="id" title="lemma">flip_rintro</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) <span class="id" title="var">m</span> <span class="id" title="var">n</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="class">RIntro</span></a> (<a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a>) (<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#RIntro"><span class="id" title="class">RIntro</span></a> <span class="id" title="var">_</span> (<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a> <span class="id" title="var">_</span>) <span class="id" title="var">_</span> <span class="id" title="var">_</span>) ⇒<br/>
<span class="id" title="tactic">eapply</span> <a class="idref" href="coqrel.RelDefinitions.html#flip_rintro"><span class="id" title="lemma">flip_rintro</span></a> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <a name="flip_relim"><span class="id" title="lemma">flip_relim</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) <span class="id" title="var">m</span> <span class="id" title="var">n</span> <span class="id" title="var">P</span> <span class="id" title="var">Q</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a> <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> (<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a>) <a class="idref" href="coqrel.RelDefinitions.html#m"><span class="id" title="variable">m</span></a> <a class="idref" href="coqrel.RelDefinitions.html#n"><span class="id" title="variable">n</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a> <a class="idref" href="coqrel.RelDefinitions.html#Q"><span class="id" title="variable">Q</span></a>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#RElim"><span class="id" title="class">RElim</span></a> (<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a> <span class="id" title="var">_</span>) <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span> <span class="id" title="var">_</span>) ⇒<br/>
<span class="id" title="tactic">eapply</span> <a class="idref" href="coqrel.RelDefinitions.html#flip_relim"><span class="id" title="lemma">flip_relim</span></a> : <span class="id" title="var">typeclass_instances</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <a name="flip_rdestruct"><span class="id" title="lemma">flip_rdestruct</span></a> {<span class="id" title="var">A</span> <span class="id" title="var">B</span>} (<span class="id" title="var">R</span>: <a class="idref" href="coqrel.RelDefinitions.html#rel"><span class="id" title="definition">rel</span></a> <a class="idref" href="coqrel.RelDefinitions.html#A"><span class="id" title="variable">A</span></a> <a class="idref" href="coqrel.RelDefinitions.html#B"><span class="id" title="variable">B</span></a>) <span class="id" title="var">T</span>:<br/>
<a class="idref" href="coqrel.RelDefinitions.html#RDestruct"><span class="id" title="class">RDestruct</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a> <a class="idref" href="coqrel.RelDefinitions.html#T"><span class="id" title="variable">T</span></a> <a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Init.Logic.html#d43e996736952df71ebeeae74d10a287"><span class="id" title="notation">→</span></a><br/>
<a class="idref" href="coqrel.RelDefinitions.html#RDestruct"><span class="id" title="class">RDestruct</span></a> (<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a> <a class="idref" href="coqrel.RelDefinitions.html#R"><span class="id" title="variable">R</span></a>) (<span class="id" title="keyword">fun</span> <span class="id" title="var">P</span> ⇒ <a class="idref" href="coqrel.RelDefinitions.html#T"><span class="id" title="variable">T</span></a> (<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a> <a class="idref" href="coqrel.RelDefinitions.html#P"><span class="id" title="variable">P</span></a>)).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">firstorder</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Hint Extern</span> 1 (<a class="idref" href="coqrel.RelDefinitions.html#RDestruct"><span class="id" title="class">RDestruct</span></a> (<a class="idref" href="http://coq.inria.fr/distrib/8.6/stdlib/Coq.Program.Basics.html#flip"><span class="id" title="definition">flip</span></a> <span class="id" title="var">_</span>) <span class="id" title="var">_</span>) ⇒<br/>
<span class="id" title="tactic">eapply</span> <a class="idref" href="coqrel.RelDefinitions.html#flip_rdestruct"><span class="id" title="lemma">flip_rdestruct</span></a> : <span class="id" title="var">typeclass_instances</span>.<br/>
</div>
</div>
<div id="footer">
<hr/><a href="index.html">Index</a><hr/>This page has been generated by <a href="http://coq.inria.fr/">coqdoc</a>
</div>
</div>
</body>
</html>