-
Notifications
You must be signed in to change notification settings - Fork 0
/
06-reflection.html
845 lines (737 loc) · 40.5 KB
/
06-reflection.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<title>An Introduction to Refinement Types</title>
<link href="./css/bootstrap.css" rel="stylesheet">
<link href="./css/bootstrap-theme.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./css/rust-book-slides.css">
<link rel="stylesheet" type="text/css" href="./css/editor-slides.css">
<link rel="stylesheet" type="text/css" href="./css/code-format.css">
<link rel="stylesheet" type="text/css" href="./css/slideshow.css">
<style>
body {
text-align: center;
}
.mybreak {
line-height: 1em;
}
table {
margin-left: 150px;
margin-right: auto;
}
</style>
<!-- JQUERY MOBILE -->
<!-- Include jQuery Mobile stylesheets -->
<!-- Include the jQuery library -->
<!-- <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> -->
<script src="./js/jquery/jquery-1.11.3.min.js"></script>
<script src="./js/jquery/init-mobile.js"></script>
<!-- Include the jQuery Mobile library -->
<!-- <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> -->
<script src="./js/jquery/jquery.mobile-1.4.5.min.js"></script>
<!-- JQUERY LOCAL
<script type="text/javascript" src="./js/jquery/jquery-2.0.3.min.js"></script>
-->
<script type="text/javascript" src="./js/angular/angular.js"></script>
<script type="text/javascript" src="./js/bootstrap/bootstrap.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
extensions: ["color.js"],
Macros: {
True: "\\mathit{True}",
RR: "{\\bf R}",
Int: "\\mathtt{Int}",
Nat: "\\mathtt{Nat}",
Zero: "\\mathtt{Zero}",
foo: ["{\\bf Jhala FOO #1}", 1],
kvar: ["{\\color[rgb]{1,0,0}{K_{#1}({#2})}}", 2],
bindx: ["{{#1}\\!:\\!{#2}}", 2],
reft: ["\\{\\bindx{#1}{#2} \\mid {#3}\\}", 3],
ereft: ["\\bindx{#1}{\\{#2 \\mid #3\\}}", 3],
reftx: ["\\{{#1}\\mid{#2}\\}", 2],
inferrule: ["\\frac{#2}{#3}\\;{#1}", 3]
}
}
});
</script>
<!-- GITHUB
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
-->
<!-- LOCAL -->
<script src="js/MathJax-2.6.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
</head>
<body class="rustdoc" data-spy="scroll" data-target=".bs-docs-sidebar" ng-app="liquidDemo" ng-controller="LiquidDemoCtrl">
<div id="nav">
<button class="btn btn-xs btn-link actbutton firstbutton" type="button" style="font-size:15px; color:black; z-index:1">
<span class="glyphicon glyphicon-backward"></span>
</button>
<button class="btn btn-xs btn-link actbutton prevbutton" type="button" style="font-size:15px; color:black; z-index:1">
<span class="glyphicon glyphicon-chevron-left"></span>
</button>
<button id="toggle-nav" class="toggle-nav">
<span class="sr-only">Toggle navigation</span>
<span class="bar"></span>
<span class="bar"></span>
</button>
<button class="btn btn-xs btn-link actbutton nextbutton" type="button" style="font-size:15px; color:black; z-index:1">
<span class="glyphicon glyphicon-chevron-right"></span>
</button>
<button class="btn btn-xs btn-link actbutton lastbutton" type="button" style="font-size:15px; color:black; z-index:1">
<span class="glyphicon glyphicon-forward"></span>
</button>
</div>
<div id='toc' class='mobile-hidden'>
<ul class='chapter'>
<li><a href='01-intro.html'><b>1.</b>Whats this?</a></li>
<ul class='section'>
<li><a href='01-intro.html#the-first-bug'><b>1.1.</b> The First <em>Bug</em></a></li>
<li><a href='01-intro.html#fast-forward-to-present-day'><b>1.2.</b> Fast forward to Present Day</a></li>
<li><a href='01-intro.html#fast-forward-to-present-day-1'><b>1.3.</b> Fast forward to Present Day</a></li>
<li><a href='01-intro.html#fast-forward-to-present-day-2'><b>1.4.</b> Fast forward to Present Day</a></li>
<li><a href='01-intro.html#programming-languages-research'><b>1.5.</b> Programming Languages Research</a></li>
<li><a href='01-intro.html#modern-languages'><b>1.6.</b> Modern Languages</a></li>
<li><a href='01-intro.html#modern-languages-1'><b>1.7.</b> Modern Languages</a></li>
<li><a href='01-intro.html#modern-languages-2'><b>1.8.</b> Modern Languages</a></li>
<li><a href='01-intro.html#modern-languages-3'><b>1.9.</b> Modern Languages?</a></li>
<li><a href='01-intro.html#well-typed-programs-can-go-very-wrong'><b>1.10.</b> Well-typed programs can go very wrong!</a></li>
<li><a href='01-intro.html#well-typed-programs-can-go-very-wrong-1'><b>1.11.</b> Well-typed programs can go very wrong!</a></li>
<li><a href='01-intro.html#well-typed-programs-can-go-very-wrong-2'><b>1.12.</b> Well-typed programs can go very wrong!</a></li>
<li><a href='01-intro.html#goal-algorithmic-software-verification'><b>1.13.</b> Goal: Algorithmic Software Verification</a></li>
<li><a href='01-intro.html#goal-algorithmic-software-verification-1'><b>1.14.</b> Goal: Algorithmic Software Verification</a></li>
<li><a href='01-intro.html#outline'><b>1.15.</b> Outline</a></li>
<li><a href='01-intro.html#outline-1'><b>1.16.</b> Outline</a></li>
<li><a href='01-intro.html#outline-2'><b>1.17.</b> Outline</a></li>
<li><a href='01-intro.html#outline-3'><b>1.18.</b> Outline</a></li>
<li><a href='01-intro.html#outline-4'><b>1.19.</b> Outline</a></li>
</ul>
<li><a href='02-refinements.html'><b>2.</b>Simple Refinement Types</a></li>
<ul class='section'>
<li><a href='02-refinements.html#types'><b>2.1.</b> Types</a></li>
<li><a href='02-refinements.html#predicates'><b>2.2.</b> Predicates</a></li>
<li><a href='02-refinements.html#predicates-1'><b>2.3.</b> Predicates</a></li>
<li><a href='02-refinements.html#predicates-2'><b>2.4.</b> Predicates</a></li>
<li><a href='02-refinements.html#predicates-3'><b>2.5.</b> Predicates</a></li>
<li><a href='02-refinements.html#predicates-4'><b>2.6.</b> Predicates</a></li>
<li><a href='02-refinements.html#example-singletons'><b>2.7.</b> Example: Singletons</a></li>
<li><a href='02-refinements.html#example-natural-numbers'><b>2.8.</b> Example: Natural Numbers</a></li>
<li><a href='02-refinements.html#a-term-can-have-many-types'><b>2.9.</b> A Term Can Have <em>Many</em> Types</a></li>
<li><a href='02-refinements.html#predicate-subtyping-nuprl-pvs'><b>2.10.</b> 1. Predicate Subtyping <a href="http://pvs.csl.sri.com/papers/subtypes98/tse98.pdf">[NUPRL, PVS]</a></a></li>
<li><a href='02-refinements.html#predicate-subtyping-nuprl-pvs-1'><b>2.11.</b> 1. Predicate Subtyping <a href="http://pvs.csl.sri.com/papers/subtypes98/tse98.pdf">[NUPRL, PVS]</a></a></li>
<li><a href='02-refinements.html#predicate-subtyping-nuprl-pvs-2'><b>2.12.</b> 1. Predicate Subtyping <a href="http://pvs.csl.sri.com/papers/subtypes98/tse98.pdf">[NUPRL, PVS]</a></a></li>
<li><a href='02-refinements.html#example-natural-numbers-1'><b>2.13.</b> Example: Natural Numbers</a></li>
<li><a href='02-refinements.html#example-natural-numbers-2'><b>2.14.</b> Example: Natural Numbers</a></li>
<li><a href='02-refinements.html#typing-applications-function-calls'><b>2.15.</b> 2. Typing Applications (Function Calls)</a></li>
<li><a href='02-refinements.html#typing-applications-function-calls-1'><b>2.16.</b> 2. Typing Applications (Function Calls)</a></li>
<li><a href='02-refinements.html#typing-applications-function-calls-2'><b>2.17.</b> 2. Typing Applications (Function Calls)</a></li>
<li><a href='02-refinements.html#typing-applications-function-calls-3'><b>2.18.</b> 2. Typing Applications (Function Calls)</a></li>
<li><a href='02-refinements.html#recap-refinement-types-101'><b>2.19.</b> Recap: Refinement Types 101</a></li>
<li><a href='02-refinements.html#recap-refinement-types-101-1'><b>2.20.</b> Recap: Refinement Types 101</a></li>
<li><a href='02-refinements.html#recap-refinement-types-101-2'><b>2.21.</b> Recap: Refinement Types 101</a></li>
</ul>
<li><a href='03-examples.html'><b>3.</b>Refinement Types by Example</a></li>
<ul class='section'>
<li><a href='03-examples.html#refinement-types-by-example-1'><b>3.1.</b> Refinement Types by Example</a></li>
<li><a href='03-examples.html#refinement-types-by-example-2'><b>3.2.</b> Refinement Types by Example</a></li>
<li><a href='03-examples.html#refinement-types-by-example-3'><b>3.3.</b> Refinement Types by Example</a></li>
<li><a href='03-examples.html#specifications-pre-conditions'><b>3.4.</b> Specifications: Pre-Conditions</a></li>
<li><a href='03-examples.html#specifications-post-conditions'><b>3.5.</b> Specifications: Post-Conditions</a></li>
<li><a href='03-examples.html#refinement-types-by-example-4'><b>3.6.</b> Refinement Types by Example</a></li>
<li><a href='03-examples.html#verification-vector-sum'><b>3.7.</b> Verification: Vector Sum</a></li>
<li><a href='03-examples.html#verification-vector-sum-1'><b>3.8.</b> Verification: Vector Sum</a></li>
<li><a href='03-examples.html#verification-vector-sum-2'><b>3.9.</b> Verification: Vector Sum</a></li>
<li><a href='03-examples.html#refinement-types-by-example-5'><b>3.10.</b> Refinement Types by Example</a></li>
<li><a href='03-examples.html#inference'><b>3.11.</b> Inference</a></li>
<li><a href='03-examples.html#inference-vector-sum'><b>3.12.</b> Inference: Vector Sum</a></li>
<li><a href='03-examples.html#inference-vector-sum-1'><b>3.13.</b> Inference: Vector Sum</a></li>
<li><a href='03-examples.html#inference-vector-sum-2'><b>3.14.</b> Inference: Vector Sum</a></li>
<li><a href='03-examples.html#inference-vector-sum-3'><b>3.15.</b> Inference: Vector Sum</a></li>
<li><a href='03-examples.html#inference-vector-sum-4'><b>3.16.</b> Inference: Vector Sum</a></li>
<li><a href='03-examples.html#inference-vector-sum-5'><b>3.17.</b> Inference: Vector Sum</a></li>
<li><a href='03-examples.html#refinement-types-by-example-6'><b>3.18.</b> Refinement Types by Example</a></li>
<li><a href='03-examples.html#collections-higher-order-functions'><b>3.19.</b> Collections & Higher-Order Functions</a></li>
<li><a href='03-examples.html#collections-higher-order-functions-1'><b>3.20.</b> Collections & Higher-Order Functions</a></li>
<li><a href='03-examples.html#collections-higher-order-functions-2'><b>3.21.</b> Collections & Higher-Order Functions</a></li>
<li><a href='03-examples.html#collections-higher-order-functions-3'><b>3.22.</b> Collections & Higher-Order Functions</a></li>
<li><a href='03-examples.html#refinement-types-by-example-7'><b>3.23.</b> Refinement Types by Example</a></li>
<li><a href='03-examples.html#example-list-average'><b>3.24.</b> Example: List <code>average</code></a></li>
<li><a href='03-examples.html#refinements-for-datatypes'><b>3.25.</b> Refinements for Datatypes</a></li>
<li><a href='03-examples.html#measures-yield-refined-constructors'><b>3.26.</b> Measures Yield Refined Constructors</a></li>
<li><a href='03-examples.html#example-map-over-lists'><b>3.27.</b> Example: <code>map</code> over Lists</a></li>
<li><a href='03-examples.html#refinements-for-datatypes-1'><b>3.28.</b> Refinements for Datatypes</a></li>
<li><a href='03-examples.html#refinements-for-datatypes-2'><b>3.29.</b> Refinements for Datatypes</a></li>
<li><a href='03-examples.html#refinements-for-datatypes-3'><b>3.30.</b> Refinements for Datatypes</a></li>
<li><a href='03-examples.html#refinement-types-by-example-8'><b>3.31.</b> Refinement Types by Example</a></li>
</ul>
<li><a href='04-abstracting.html'><b>4.</b>Invariants In Constructors</a></li>
<ul class='section'>
<li><a href='04-abstracting.html#invariants-in-constructors-1'><b>4.1.</b> Invariants In Constructors</a></li>
<li><a href='04-abstracting.html#invariants-in-constructors-2'><b>4.2.</b> Invariants In Constructors</a></li>
<li><a href='04-abstracting.html#invariants-in-constructors-3'><b>4.3.</b> Invariants In Constructors</a></li>
<li><a href='04-abstracting.html#abstracting-refinements'><b>4.4.</b> Abstracting Refinements</a></li>
<li><a href='04-abstracting.html#abstracting-refinements-1'><b>4.5.</b> Abstracting Refinements</a></li>
<li><a href='04-abstracting.html#abstracting-refinements-2'><b>4.6.</b> Abstracting Refinements</a></li>
<li><a href='04-abstracting.html#using-abstract-refinements'><b>4.7.</b> Using Abstract Refinements</a></li>
<li><a href='04-abstracting.html#recap'><b>4.8.</b> Recap</a></li>
<li><a href='04-abstracting.html#recap-1'><b>4.9.</b> Recap</a></li>
<li><a href='04-abstracting.html#bounded-refinements-induction-as-a-type'><b>4.10.</b> Bounded Refinements: Induction as a Type</a></li>
<li><a href='04-abstracting.html#bounded-refinements-induction-as-a-type-1'><b>4.11.</b> Bounded Refinements: Induction as a Type</a></li>
<li><a href='04-abstracting.html#bounded-refinements-induction-as-a-type-2'><b>4.12.</b> Bounded Refinements: Induction as a Type</a></li>
<li><a href='04-abstracting.html#bounded-refinements-induction-as-a-type-3'><b>4.13.</b> Bounded Refinements: Induction as a Type</a></li>
</ul>
<li><a href='05-concl.html'><b>5.</b>LiquidHaskell</a></li>
<ul class='section'>
<li><a href='05-concl.html#liquidhaskell-1'><b>5.1.</b> LiquidHaskell</a></li>
<li><a href='05-concl.html#liquidhaskell-2'><b>5.2.</b> LiquidHaskell</a></li>
<li><a href='05-concl.html#evaluation'><b>5.3.</b> Evaluation</a></li>
<li><a href='05-concl.html#recap-refinement-types'><b>5.4.</b> Recap: Refinement Types</a></li>
<li><a href='05-concl.html#recap-refinement-types-1'><b>5.5.</b> Recap: Refinement Types</a></li>
<li><a href='05-concl.html#recap-refinement-types-2'><b>5.6.</b> Recap: Refinement Types</a></li>
<li><a href='05-concl.html#recap-refinement-types-3'><b>5.7.</b> Recap: Refinement Types</a></li>
<li><a href='05-concl.html#many-friends-many-directions'><b>5.8.</b> Many Friends, Many Directions</a></li>
<li><a href='05-concl.html#thank-you'><b>5.9.</b> Thank You!</a></li>
</ul>
<li><a href='05-termination.html'><b>6.</b>Avoiding Infinite Loops</a></li>
<ul class='section'>
<li><a href='05-termination.html#example-proving-termination-of-sum'><b>6.1.</b> Example: Proving Termination of <code>sum</code></a></li>
<li><a href='05-termination.html#proving-termination'><b>6.2.</b> Proving Termination</a></li>
<li><a href='05-termination.html#proving-termination-1'><b>6.3.</b> Proving Termination</a></li>
<li><a href='05-termination.html#proving-termination-2'><b>6.4.</b> Proving Termination</a></li>
<li><a href='05-termination.html#example-proving-termination-of-sum-1'><b>6.5.</b> Example: Proving Termination of <code>sum</code></a></li>
<li><a href='05-termination.html#proving-termination-3'><b>6.6.</b> Proving Termination</a></li>
<li><a href='05-termination.html#user-specified-termination-metrics'><b>6.7.</b> User Specified Termination Metrics</a></li>
<li><a href='05-termination.html#user-specified-termination-metrics-1'><b>6.8.</b> User Specified Termination Metrics</a></li>
<li><a href='05-termination.html#proving-termination-4'><b>6.9.</b> Proving Termination</a></li>
<li><a href='05-termination.html#lexicographic-termination'><b>6.10.</b> Lexicographic Termination</a></li>
<li><a href='05-termination.html#how-about-data-types'><b>6.11.</b> How About Data Types?</a></li>
<li><a href='05-termination.html#user-specified-metrics-on-adts'><b>6.12.</b> User specified metrics on ADTs</a></li>
<li><a href='05-termination.html#proving-termination-5'><b>6.13.</b> Proving Termination</a></li>
<li><a href='05-termination.html#termination-is-easy-in-practice'><b>6.14.</b> Termination is Easy in Practice</a></li>
<li><a href='05-termination.html#termination-is-easy-in-practice-1'><b>6.15.</b> Termination is Easy in Practice</a></li>
<li><a href='05-termination.html#recap'><b>6.16.</b> Recap</a></li>
<li><a href='05-termination.html#what-properties-can-be-expressed-in-the-logic'><b>6.17.</b> What properties can be expressed in the logic?</a></li>
</ul>
<li><a href='06-reflection.html'><b>7.</b>Refinement Reflection</a></li>
<ul class='section'>
<li><a href='06-reflection.html#theorems-about-haskell-functions'><b>7.1.</b> Theorems about Haskell functions</a></li>
<li><a href='06-reflection.html#theorems-about-haskell-functions-1'><b>7.2.</b> Theorems about Haskell functions</a></li>
<li><a href='06-reflection.html#types-as-theorems'><b>7.3.</b> Types As Theorems</a></li>
<li><a href='06-reflection.html#make-the-theorems-pretty'><b>7.4.</b> Make the theorems pretty!</a></li>
<li><a href='06-reflection.html#make-the-theorems-even-prettier'><b>7.5.</b> Make the theorems even prettier!</a></li>
<li><a href='06-reflection.html#use-more-smt-knowledge'><b>7.6.</b> Use more SMT knowledge</a></li>
<li><a href='06-reflection.html#theorems-about-haskell-functions-2'><b>7.7.</b> Theorems about Haskell functions</a></li>
<li><a href='06-reflection.html#refinement-reflection-1'><b>7.8.</b> Refinement Reflection</a></li>
<li><a href='06-reflection.html#fib-is-an-uninterpreted-function'><b>7.9.</b> <code>fib</code> is an uninterpreted function</a></li>
<li><a href='06-reflection.html#reflect-function-into-output-type'><b>7.10.</b> Reflect Function into Output Type</a></li>
<li><a href='06-reflection.html#reflection-at-result-type'><b>7.11.</b> Reflection at Result Type</a></li>
<li><a href='06-reflection.html#structuring-proofs'><b>7.12.</b> Structuring Proofs</a></li>
<li><a href='06-reflection.html#reusing-proofs-the-because-operator'><b>7.13.</b> Reusing Proofs: The "because" operator</a></li>
<li><a href='06-reflection.html#paper-pencil-style-proofs'><b>7.14.</b> Paper & Pencil style Proofs</a></li>
<li><a href='06-reflection.html#another-paper-pencil-proof'><b>7.15.</b> Another "Paper & Pencil" Proof</a></li>
<li><a href='06-reflection.html#generalizing-monotonicity-proof'><b>7.16.</b> Generalizing monotonicity proof</a></li>
<li><a href='06-reflection.html#reusing-theorems-by-application'><b>7.17.</b> Reusing Theorems by Application</a></li>
<li><a href='06-reflection.html#recap'><b>7.18.</b> Recap</a></li>
</ul>
<li><a href='07-structural-induction.html'><b>8.</b>Structural Induction</a></li>
<ul class='section'>
<li><a href='07-structural-induction.html#the-list-data-type'><b>8.1.</b> The list data type</a></li>
<li><a href='07-structural-induction.html#reflection-of-adts-into-the-logic'><b>8.2.</b> Reflection of ADTs into the logic</a></li>
<li><a href='07-structural-induction.html#reflection-of-structural-inductive-functions'><b>8.3.</b> Reflection of Structural Inductive Functions</a></li>
<li><a href='07-structural-induction.html#prove-fancy-lists-properties'><b>8.4.</b> Prove fancy lists properties</a></li>
<li><a href='07-structural-induction.html#recap'><b>8.5.</b> Recap</a></li>
<li><a href='07-structural-induction.html#appendix-reflection-of-non-recursive-functions'><b>8.6.</b> Appendix: Reflection of Non Recursive Functions</a></li>
<li><a href='07-structural-induction.html#proving-map-identity'><b>8.7.</b> Proving Map-Identity</a></li>
<li><a href='07-structural-induction.html#automation-proving-map-identity'><b>8.8.</b> Automation: Proving Map-Identity</a></li>
<li><a href='07-structural-induction.html#proving-map-fusion'><b>8.9.</b> Proving Map-Fusion</a></li>
<li><a href='07-structural-induction.html#onto-monoid-laws'><b>8.10.</b> Onto Monoid Laws</a></li>
<li><a href='07-structural-induction.html#monoid-laws-left-identity'><b>8.11.</b> Monoid Laws: Left Identity</a></li>
<li><a href='07-structural-induction.html#monoid-laws-right-identity'><b>8.12.</b> Monoid Laws: Right Identity</a></li>
<li><a href='07-structural-induction.html#monoid-laws-associativity'><b>8.13.</b> Monoid Laws: Associativity</a></li>
<li><a href='07-structural-induction.html#onto-monad-laws'><b>8.14.</b> Onto Monad Laws!</a></li>
<li><a href='07-structural-induction.html#monoid-laws-left-identity-1'><b>8.15.</b> Monoid Laws: Left Identity</a></li>
<li><a href='07-structural-induction.html#monoid-laws-right-identity-1'><b>8.16.</b> Monoid Laws: Right Identity</a></li>
<li><a href='07-structural-induction.html#monoid-laws-associativity-1'><b>8.17.</b> Monoid Laws: Associativity</a></li>
<li><a href='07-structural-induction.html#monoid-laws-associativity-2'><b>8.18.</b> Monoid Laws: Associativity</a></li>
</ul>
<li><a href='08-case-study-map-reduce.html'><b>9.</b>Case Study: MapReduce</a></li>
<ul class='section'>
<li><a href='08-case-study-map-reduce.html#mapreduce-library'><b>9.1.</b> MapReduce "Library"</a></li>
<li><a href='08-case-study-map-reduce.html#mapreduce-client-summing-list'><b>9.2.</b> MapReduce "Client": Summing List</a></li>
<li><a href='08-case-study-map-reduce.html#proving-code-equivalence'><b>9.3.</b> Proving Code Equivalence</a></li>
<li><a href='08-case-study-map-reduce.html#right-identity-of-plus'><b>9.4.</b> Right Identity of <code>plus</code></a></li>
<li><a href='08-case-study-map-reduce.html#distributivity-of-sum'><b>9.5.</b> Distributivity of <code>sum</code></a></li>
<li><a href='08-case-study-map-reduce.html#higher-order-map-reduce-theorem'><b>9.6.</b> Higher Order Map Reduce Theorem</a></li>
<li><a href='08-case-study-map-reduce.html#right-identity-of-plus-1'><b>9.7.</b> Right Identity of <code>plus</code></a></li>
<li><a href='08-case-study-map-reduce.html#warmup-associativity-of-append'><b>9.8.</b> Warmup: Associativity of Append</a></li>
<li><a href='08-case-study-map-reduce.html#proof-automation-associativity-of-append'><b>9.9.</b> Proof Automation: Associativity of Append</a></li>
<li><a href='08-case-study-map-reduce.html#distributivity-of-sum-1'><b>9.10.</b> Distributivity of <code>sum</code></a></li>
<li><a href='08-case-study-map-reduce.html#recap'><b>9.11.</b> Recap</a></li>
<li><a href='08-case-study-map-reduce.html#recap-1'><b>9.12.</b> Recap</a></li>
<li><a href='08-case-study-map-reduce.html#appendix-proof-of-mrtheorem'><b>9.13.</b> Appendix: Proof of <code>mRTheorem</code></a></li>
<li><a href='08-case-study-map-reduce.html#append-of-take-and-drop'><b>9.14.</b> Append of Take and Drop</a></li>
<li><a href='08-case-study-map-reduce.html#list-definition'><b>9.15.</b> List Definition</a></li>
<li><a href='08-case-study-map-reduce.html#list-manipulation'><b>9.16.</b> List Manipulation</a></li>
</ul>
</ul>
</div>
<div id="checker-status">
<!-- Verifying ... -->
<button class="btn btn-xs btn-link actbutton" type="button" style="font-size:30px; z-index:1"
ng-show="isChecking" ng-click="verifySource()">
<span class="glyphicon glyphicon-hourglass"></span>
</button>
<!-- Safe -->
<button class="btn btn-xs btn-link actbutton" type="button" style="font-size:30px; color:green; z-index:1"
ng-show="isSafe">
<span class="glyphicon glyphicon-ok"></span>
</button>
<div class="dropdown" ng-show="isBad">
<button class="btn btn-xs btn-link dropdown-toggle"
type="button"
id="errorblockdropdown"
data-toggle="dropdown"
style="font-size:30px; color:red; z-index:1">
<span class="glyphicon glyphicon-remove" style="vertical-align:middle"></span><font size="4">{{errorBlocks.length}}</font>
</span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li ng-repeat="err in errorBlocks">
<a tabindex="-1" ng-click="jumpToProgPane(err)">{{err.index}}</a>
</li>
</ul>
</div>
</div>
<div id='page-wrapper'>
<div id='page'>
<div class="hidden">
<div id="program-pane-0" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-0" class="programbox">{-# LANGUAGE TupleSections #-}
{-@ LIQUID "--no-warnings" @-}
{-@ LIQUID "--short-names" @-}
{-@ LIQUID "--diff" @-}
-- Hidden code
{-@ LIQUID "--higherorder" @-}
module RefinementReflection where
import Language.Haskell.Liquid.ProofCombinators
fib :: Int -> Int
propPlusAccum :: Int -> Int -> Proof
propOnePlusOne :: () -> Proof
onePlusOne :: () -> Proof
fibOne :: () -> Proof
fibTwo :: () -> Proof
fibEq :: () -> Proof
fibCongr :: Int -> Int -> Proof
fibUp :: Int -> Proof
fibThree :: () -> Proof
fMono :: (Int -> Int)
-> (Int -> Proof)
-> Int
-> Int
-> Proof
fibMono :: Int -> Int -> Proof
fibMonotonic :: Int -> Int -> Proof</div>
</div>
</div>
<p><br> <br> <br> <br> <br></p>
<div id="slide-0" class="slide">
<h2 id="refinement-reflection">Refinement Reflection</h2>
<p><br> <br> Allow terminating <strong>Haskell</strong> functions in refinements!</p>
</div>
<div id="slide-1" class="slide">
<h2 id="theorems-about-haskell-functions">Theorems about Haskell functions</h2>
<p><br></p>
<p>e.g. Parallelized Function Equivalent to Original</p>
<p><br></p>
<pre class="spec"><code>forall xs. sum xs == parallelSum xs
</code></pre>
<div class="hidden">
<br>
<p align="center">
A. Farmer <em>et al</em>: Reasoning with the HERMIT <br><br> <img src="http://goto.ucsd.edu/~nvazou/images/hermit_laws.png" alt="Hermit Laws" style="width: 350px;" align="middle" />
</p>
</div>
</div>
<div id="slide-2" class="slide">
<h2 id="theorems-about-haskell-functions-1">Theorems about Haskell functions</h2>
<p><br> <br> <br> Can we express the above theorems in Liquid Haskell? <br> <br></p>
<p>Express & Prove Theorems <strong>in</strong> Haskell ...</p>
<p>... <strong>for</strong> Haskell functions.</p>
</div>
<div id="slide-3" class="slide">
<h2 id="types-as-theorems">Types As Theorems</h2>
<p>Refined Types are <strong>theorems</strong></p>
<p>and</p>
<p>Haskell Functions are <strong>proofs</strong>.</p>
<div id="program-pane-1" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-1" class="programbox">{-@ onePlusOne :: () -> {v:() | 1 + 1 == 2 } @-}
onePlusOne _ = ()</div>
</div>
</div>
<div id="slide-4" class="slide">
<h2 id="make-the-theorems-pretty">Make the theorems pretty!</h2>
<p><br></p>
<p><a href="https://github.com/ucsd-progsys/liquidhaskell/blob/develop/include/Language/Haskell/Liquid/ProofCombinators.hs"><code>ProofCombinators</code></a> comes with Liquid Haskell and allows for pretty proofs!</p>
<br>
<div id="program-pane-2" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-2" class="programbox">-- import Language.Haskell.Liquid.ProofCombinators
{-@ propOnePlusOne :: () -> {v: Proof | 1 + 1 == 2} @-}
propOnePlusOne _ = trivial</div>
</div>
</div>
<div id="slide-5" class="slide">
<h2 id="make-the-theorems-even-prettier">Make the theorems even prettier!</h2>
<p><br></p>
<p><a href="https://github.com/ucsd-progsys/liquidhaskell/blob/develop/include/Language/Haskell/Liquid/ProofCombinators.hs"><code>ProofCombinators</code></a> comes with Liquid Haskell and allows for pretty proofs!</p>
<br>
<div id="program-pane-3" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-3" class="programbox">{-@ propOnePlusOne' :: _ -> { 1 + 1 == 2 } @-}
propOnePlusOne' _ = trivial *** QED</div>
</div>
</div>
<div id="slide-6" class="slide">
<h2 id="use-more-smt-knowledge">Use more SMT knowledge</h2>
<p><br></p>
<p><a href="https://github.com/ucsd-progsys/liquidhaskell/blob/develop/include/Language/Haskell/Liquid/ProofCombinators.hs"><code>ProofCombinators</code></a> comes with Liquid Haskell and allows for pretty proofs!</p>
<br>
<div id="program-pane-4" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-4" class="programbox">{-@ propPlusAccum :: x:Int -> y:Int -> { x + y == y + x } @-}
propPlusAccum _ _ = trivial *** QED</div>
</div>
</div>
<div id="slide-7" class="slide">
<h2 id="theorems-about-haskell-functions-2">Theorems about Haskell functions</h2>
<p><br> <br> <br> Can we express the above theorems in Liquid Haskell? <br> <br></p>
<p>Express & Prove Theorems <strong>in</strong> Haskell ...</p>
<p>... <strong>for</strong> Haskell functions.</p>
</div>
<div id="slide-8" class="slide">
<h2 id="refinement-reflection-1">Refinement Reflection</h2>
<p><strong>Reflect</strong> <code>fib</code> in the logic.</p>
<div id="program-pane-5" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-5" class="programbox">{-@ reflect fib @-}
{-@ fib :: i:Nat -> Nat @-}
fib i | i == 0 = 0
| i == 1 = 1
| otherwise = fib (i-1) + fib (i-2)</div>
</div>
<p><br></p>
<p>(Need to prove <code>fib</code> terminates...)</p>
</div>
<div id="slide-9" class="slide">
<h2 id="fib-is-an-uninterpreted-function"><code>fib</code> is an uninterpreted function</h2>
<p><br> For which logic only knows the congruence axiom... <br></p>
<div id="program-pane-6" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-6" class="programbox">{-@ fibCongr :: i:Nat -> j:Nat -> {i == j => fib i == fib j} @-}
fibCongr _ _ = trivial</div>
</div>
<p><br></p>
<p>... and nothing else</p>
<br>
<div id="program-pane-7" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-7" class="programbox">{-@ fibOne :: () -> {fib 1 == 1 } @-}
fibOne _ = trivial</div>
</div>
</div>
<div id="slide-10" class="slide">
<h2 id="reflect-function-into-output-type">Reflect Function into Output Type</h2>
<p><br> The type of <code>fib</code> connects logic & Haskell implementation <br></p>
<pre class="spec"><code>fib :: i:Nat
-> {v:Nat | v == fib i
&& v == if i == 0 then 0 else
if i == 1 then 1 else
fib (i-1) + fib (i-2)
}
</code></pre>
<p><br></p>
<p><strong>Calling</strong> <code>fib i</code> reveals its implementation in the logic!</p>
</div>
<div id="slide-11" class="slide">
<h2 id="reflection-at-result-type">Reflection at Result Type</h2>
<br>
<div id="program-pane-8" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-8" class="programbox">{-@ fibEq :: () -> {fib 1 == 1 } @-}
fibEq _ = let f1 = fib 1 -- f1:: {f1 == fib 1 && f1 == 1}
in [f1] *** QED</div>
</div>
<p><br></p>
<p><strong>Exercise:</strong> Lets prove that <code>fib 2 == 1</code>.</p>
</div>
<div id="slide-12" class="slide">
<h2 id="structuring-proofs">Structuring Proofs</h2>
<p><br> <br> Using combinators from <a href="https://github.com/ucsd-progsys/liquidhaskell/blob/develop/include/Language/Haskell/Liquid/ProofCombinators.hs"><code>ProofCombinators</code></a>!</p>
<br> <br>
<div id="program-pane-9" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-9" class="programbox">{-@ fibTwo :: _ -> { fib 2 == 1 } @-}
fibTwo _
= fib 2
==. fib 1 + fib 0
*** QED</div>
</div>
</div>
<div id="slide-13" class="slide">
<h2 id="reusing-proofs-the-because-operator">Reusing Proofs: The "because" operator</h2>
<p><br> <br></p>
<p>Using combinators from <a href="https://github.com/ucsd-progsys/liquidhaskell/blob/develop/include/Language/Haskell/Liquid/ProofCombinators.hs"><code>ProofCombinators</code></a>!</p>
<br> <br>
<div id="program-pane-10" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-10" class="programbox">{-@ fibThree :: _ -> { fib 3 == 2 } @-}
fibThree _
= fib 3
==. fib 2 + fib 1
==. 1 + 1 ? fibTwo ()
==. 2
*** QED</div>
</div>
</div>
<div id="slide-14" class="slide">
<h2 id="paper-pencil-style-proofs">Paper & Pencil style Proofs</h2>
<p><br> <code>fib</code> is increasing <br></p>
<div id="program-pane-11" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-11" class="programbox">{-@ fibUp :: i:Nat -> {fib i <= fib (i+1)} @-}
fibUp i
| i == 0
= fib 0 <. fib 1
*** QED
| i == 1
= fib 1 <=. fib 1 + fib 0 <=. fib 2
*** QED
| otherwise
= fib i
==. fib (i-1) + fib (i-2)
<=. fib i + fib (i-2) ? fibUp (i-1)
<=. fib i + fib (i-1) ? fibUp (i-2)
<=. fib (i+1)
*** QED</div>
</div>
</div>
<div id="slide-15" class="slide">
<h2 id="another-paper-pencil-proof">Another "Paper & Pencil" Proof</h2>
<p><br> <strong>Exercise:</strong> Lets fix the proof that <code>fib</code> is monotonic? <br></p>
<div id="program-pane-12" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-12" class="programbox">{-@ fibMonotonic :: x:Nat -> y:{Nat | x < y } -> {fib x <= fib y} @-}
fibMonotonic x y
| y == x + 1
= fib x
<=. fib (x+1) ? fibUp x
<=. fib y
*** QED
| x < y - 1
= fib x
<=. fib (y-1) ? trivial {- Inductive Hypothesis call goes here -}
<=. fib y ? fibUp (y-1)
*** QED</div>
</div>
<p><strong>Exercise:</strong> Can you replace <code>trivial</code> to fix the monotonicity proof? <br></p>
<p>Note: Totality checker should be on for valid proofs</p>
<div id="program-pane-13" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-13" class="programbox">{-@ LIQUID "--totality" @-}</div>
</div>
</div>
<div id="slide-16" class="slide">
<h2 id="generalizing-monotonicity-proof">Generalizing monotonicity proof</h2>
<p><br> <strong>Exercise:</strong> Generalize the implementation of <code>fMono</code> proof below to any increasing function <code>f</code>. <br></p>
<div id="program-pane-14" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-14" class="programbox">{-@ fMono :: f:(Nat -> Int)
-> fUp:(z:Nat -> {f z <= f (z+1)})
-> x:Nat
-> y:{Nat|x < y}
-> {f x <= f y} / [y] @-}
fMono f fUp x y
| y == x + 1
= fib x
<=. fib (x+1) ? fibUp x
<=. fib y
*** QED
| x < y - 1
= fib x
<=. fib (y-1) ? fibMonotonic x (y-1)
<=. fib y ? fibUp (y-1)
*** QED</div>
</div>
</div>
<div id="slide-17" class="slide">
<h2 id="reusing-theorems-by-application">Reusing Theorems by Application</h2>
<p><br></p>
<p><code>fib</code> is monotonic!</p>
<p><br></p>
<div id="program-pane-15" class="welleditor" style="background:#fff; position:relative">
<!-- Verify Source -->
<button class="btn btn-xs btn-link actbutton" type="button" style="z-index:1"
ng-show="isUnknown" ng-click="verifySource()">
<span class="glyphicon glyphicon-play"></span>
</button>
<div id="program-15" class="programbox">{-@ fibMono :: n:Nat -> m:{Nat | n < m } -> {fib n <= fib m} @-}
fibMono = fMono fib fibUp</div>
</div>
</div>
<div id="slide-18" class="slide">
<h2 id="recap">Recap</h2>
<p><br></p>
<table>
<tbody>
<tr class="odd">
<td style="text-align: right;"><strong>Refinements:</strong></td>
<td style="text-align: left;">Types + Predicates</td>
</tr>
<tr class="even">
<td style="text-align: right;"><strong>Specification:</strong></td>
<td style="text-align: left;">Refined Input/Output Types</td>
</tr>
<tr class="odd">
<td style="text-align: right;"><strong>Verification:</strong></td>
<td style="text-align: left;">SMT-based Predicate Subtyping</td>
</tr>
<tr class="even">
<td style="text-align: right;"><strong>Measures:</strong></td>
<td style="text-align: left;">Specify Properties of Data</td>
</tr>
<tr class="odd">
<td style="text-align: right;"><strong>Termination:</strong></td>
<td style="text-align: left;">Well-founded Metrics</td>
</tr>
<tr class="even">
<td style="text-align: right;"><strong>Reflection:</strong></td>
<td style="text-align: left;">Haskell functions in Logic</td>
</tr>
</tbody>
</table>
<p><br></p>
<p><strong>Next:</strong> <a href="07-structural-induction.html">Structural Induction</a>: Program Properties about data types!</p>
</div>
</div>
</div>
<!--Site Meter
<div class="hidden">
<script type="text/javascript" src="http://s23.sitemeter.com/js/counter.js?site=s23liquidtypes"></script>
<noscript>
<a href="http://s23.sitemeter.com/stats.asp?site=s23liquidtypes"
target="_top">
<img src="http://s23.sitemeter.com/meter.asp?site=s23liquidtypes"
alt="Site Meter" border="0"/></a>
</noscript>
</div>
-->
<!-- JavaScript below! ============================================== -->
<script src="./js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/ace/theme-monokai.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/ace/mode-haskell.js" type="text/javascript" charset="utf-8"></script>
<script src="./js/liquid/tooltip.js"></script>
<script src="./js/liquid/annot.js"></script>
<script src="./js/liquid/config.js"></script>
<script src="./js/liquid/slideshow.js"></script>
<script src="./js/liquid/liquid.js"></script>
<script type="text/javascript">
var queryServerURL = "http://goto.ucsd.edu:8090/" ;
</script>
<!-- rust nav JS -->
<script type="text/javascript">
window.playgroundUrl = "";
</script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById("toggle-nav").onclick = toggleNav;
function toggleNav() {
var toc = document.getElementById("toc");
var pagewrapper = document.getElementById("page-wrapper");
var status = document.getElementById("checker-status");
toggleClass(toc, "mobile-hidden");
// toggleClass(status, "mobile-hidden");
toggleClass(pagewrapper, "mobile-hidden");
};
function toggleClass(el, className) {
// from http://youmightnotneedjquery.com/
if (el.classList) {
el.classList.toggle(className);
} else {
var classes = el.className.split(' ');
var existingIndex = classes.indexOf(className);
if (existingIndex >= 0) {
classes.splice(existingIndex, 1);
} else {
classes.push(className);
}
el.className = classes.join(' ');
}
}
});
</script>
</body>
</html>