-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVcg_Opt.v
724 lines (685 loc) · 17.7 KB
/
Vcg_Opt.v
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
From Rela Require Import Aexp.
From Rela Require Import Bexp.
From Rela Require Import Com.
From Rela Require Import Proc.
From Rela Require Import Sigma.
From Rela Require Import Loc.
From Rela Require Vcg.
From Rela Require Import Hoare_Triple.
Import Bool.Bool.
Import Arith.
From Coq Require Import Lists.List.
Import ListNotations.
Import Vcg.Why3_Set.
Import Vcg.Assn_b.
(** Definition of logical banching **)
Inductive branch (A B C : Prop) : Prop :=
| Then : A -> B -> branch A B C
| Else : ~ A -> C -> branch A B C.
Lemma branch_simpl : forall A B C,
branch A B C -> (A -> B) /\ (~A -> C).
Proof.
intros.
destruct H.
+ split.
* auto.
* intros. contradiction H1.
+ split.
* intros. contradiction H1.
* auto.
Qed.
(** Partial translation of boolean expression into Prop **)
Fixpoint simpl_bassn b st :=
match b with
| BTrue => True
| BFalse => False
| BEq a1 a2 => aeval st a1 = aeval st a2
| BLe a1 a2 => aeval st a1 <= aeval st a2
| BAnd b1 b2 => (simpl_bassn b1 st) /\ (simpl_bassn b2 st)
| BOr b1 b2 => (simpl_bassn b1 st) \/ (simpl_bassn b2 st)
| BNot (BEq a1 a2) => aeval st a1 <> aeval st a2
| BNot (BLe a1 a2) => aeval st a2 < aeval st a1
| BNot BTrue => False
| BNot BFalse => True
| _ => bassn b st
end.
Lemma bassn_simpl_bassn : forall b st , bassn b st -> simpl_bassn b st.
Proof.
unfold bassn.
intros.
induction b.
* auto.
* auto.
* simpl.
apply Is_true_eq_true in H.
simpl in H.
apply Nat.eqb_eq in H.
assumption.
* simpl.
apply Is_true_eq_true in H.
simpl in H.
apply Compare_dec.leb_complete in H.
assumption.
* destruct b;simpl.
+ auto.
+ auto.
+ apply Nat.eqb_neq.
apply negb_true_iff.
apply Is_true_eq_true.
apply H.
+ apply Nat.leb_gt.
apply negb_true_iff.
apply Is_true_eq_true.
apply H.
+ auto.
+ auto.
+ auto.
* simpl. apply Is_true_eq_true in H.
simpl in H.
apply andb_true_iff in H.
split.
+ apply IHb1.
apply Is_true_eq_left.
apply H.
+ apply IHb2.
apply Is_true_eq_left.
apply H.
* simpl. apply Is_true_eq_true in H.
simpl in H.
apply orb_true_iff in H.
destruct H.
+ apply or_introl.
apply IHb1.
apply Is_true_eq_left.
assumption.
+ apply or_intror.
apply IHb2.
apply Is_true_eq_left.
assumption.
Qed.
Lemma bassn_not_simpl_bassn_not : forall b st , ~ bassn b st -> ~ simpl_bassn b st.
Proof.
unfold bassn.
intros.
induction b.
* auto.
* auto.
* simpl.
apply Nat.eqb_neq.
apply negb_true_iff.
apply negb_prop_intro in H.
apply Is_true_eq_true in H.
apply H.
* simpl.
apply Nat.nle_gt.
apply Nat.leb_gt.
apply negb_true_iff.
apply negb_prop_intro in H.
apply Is_true_eq_true in H.
apply H.
* destruct b;simpl.
+ auto.
+ auto.
+ apply Nat.eq_dne.
apply negb_prop_intro in H.
apply Is_true_eq_true in H.
simpl in H.
rewrite negb_involutive in H.
apply Nat.eqb_eq.
apply H.
+ apply Nat.nlt_ge.
apply negb_prop_intro in H.
apply Is_true_eq_true in H.
simpl in H.
rewrite negb_involutive in H.
apply Nat.leb_le.
apply H.
+ auto.
+ auto.
+ auto.
* simpl.
intros H1.
destruct H1.
apply negb_prop_intro in H.
apply Is_true_eq_true in H.
apply negb_true_iff in H.
simpl in H.
apply andb_false_iff in H.
destruct H.
+ apply negb_true_iff in H.
apply Is_true_eq_left in H.
apply negb_prop_elim in H.
apply IHb1 in H.
contradiction H.
+ apply negb_true_iff in H.
apply Is_true_eq_left in H.
apply negb_prop_elim in H.
apply IHb2 in H.
contradiction H.
* apply negb_prop_intro in H.
apply Is_true_eq_true in H.
apply negb_true_iff in H.
simpl in H.
apply orb_false_iff in H.
destruct H.
simpl.
intros H1.
destruct H1.
+ apply negb_true_iff in H.
apply Is_true_eq_left in H.
apply negb_prop_elim in H.
apply IHb1 in H.
contradiction H.
+ apply negb_true_iff in H0.
apply Is_true_eq_left in H0.
apply negb_prop_elim in H0.
apply IHb2 in H0.
contradiction H0.
Qed.
(** Defintion of optimized verification condition generator:
- We do not have an exponential growth of the size of the formulas due
to condition branching.
- Boolean expression are translated to Prop for convenience during proof
of verification conditions.
**)
Definition suite : Type := Prop -> Vcg.history -> Prop.
Fixpoint tc (c: com) (m m': Sigma.sigma) (h: Vcg.history)
(cl: Phi.phi) (fin: suite): Prop :=
match c with
| CSkip => fin (m' = m) (m :: h)
| CAss x a => fin (m' = set m x (aeval m a)) (m :: h)
| CAssr x a => fin (m' = set m (m x) (aeval m a)) (m :: h)
| CAssert b => fin (b (m :: h) /\ m = m') (m :: h)
| CSeq p1 p2 => forall m'',
tc p1 m m'' h cl (fun f1 h => tc p2 m'' m' h cl
(fun f2 h => fin (f1 /\ f2) h ))
| CIf b p1 p2 =>
tc p1 m m' h cl (fun p1 _ =>
tc p2 m m' h cl (fun p2 _ =>
fin (branch (simpl_bassn b m) p1 p2) (m :: h)))
| CWhile b p inv => fin (inv (m :: h) /\ inv (m' :: h) /\ ~(simpl_bassn b m')) (m :: h)
| CCall f => fin ((get_pre (cl f)) m /\ (get_post (cl f)) m' m) (m :: h)
end.
(** Facts about verification condition generator **)
Ltac ltc1 := simpl; intros m m' l suite1 suite2 H H0;
apply H; apply H0.
Lemma consequence_tc_suite :
forall p cl m m' l (suite1 suite2 : suite),
(forall p l, suite1 p l -> suite2 p l) ->
tc p m m' l cl suite1 -> tc p m m' l cl suite2.
Proof.
intros p cl.
induction p.
* ltc1.
* ltc1.
* ltc1.
* ltc1.
* simpl. intros.
eapply IHp1 with (fun p h => tc p2 m'' m' h cl (fun f2 h => suite1 (p /\ f2) h)).
- intros.
eapply IHp2 with (fun f h => suite1(p /\ f) h).
+ intros. apply H. assumption.
+ apply H1.
- apply H0.
* simpl. intros.
eapply IHp1 with
(fun p _ => tc p2 m m' l cl (fun f2 _ => suite1 (branch (simpl_bassn b m) p f2) (m ::l))).
- intros.
eapply IHp2 with (fun f _ => suite1 (branch (simpl_bassn b m) p f) (m :: l)).
+ intros. apply H. assumption.
+ apply H1.
- apply H0.
* ltc1.
* ltc1.
Qed.
Lemma intros_tc :
forall p m m' l cl (debut : Prop) (suite : suite),
tc p m m' l cl (fun f h => debut -> suite f h) ->
(debut -> tc p m m' l cl suite).
Proof.
induction p;simpl.
* intros. apply H. assumption.
* intros. apply H. assumption.
* intros. apply H. assumption.
* intros. apply H. assumption.
* intros.
eapply consequence_tc_suite.
+ intros.
generalize H0.
apply IHp2.
apply H1.
+ apply H.
* intros.
eapply consequence_tc_suite.
+ intros.
generalize H0.
apply IHp2.
apply H1.
+ apply H.
* intros. apply H. assumption.
* intros. apply H. assumption.
Qed.
Lemma prenexe_tc:
forall (A:Type) p m m' l cl (suite : A -> suite),
(forall s, tc p m m' l cl (suite s)) ->
tc p m m' l cl (fun f h => forall s,suite s f h).
Proof.
induction p;simpl.
* intros. apply H.
* intros. apply H.
* intros. apply H.
* intros. apply H.
* intros.
eapply consequence_tc_suite.
+ intros p l0 He.
apply IHp2.
apply He.
+ apply IHp1.
intros.
apply H.
* intros.
eapply consequence_tc_suite.
+ intros p l0 He.
apply IHp2.
apply He.
+ apply IHp1.
intros.
apply H.
* intros. apply H.
* intros. apply H.
Qed.
Lemma opt_1_true:
forall p1 p2 b m m' l cl (s : Prop),
simpl_bassn b m ->
tc p1 m m' l cl (fun f1 _ =>
tc p2 m m' l cl (fun f2 _ => branch (simpl_bassn b m) f1 f2 -> s)) ->
tc p1 m m' l cl (fun f1 _ =>
tc p2 m m' l cl (fun f2 _ => f1 -> s)).
Proof.
intros.
apply consequence_tc_suite with
(fun f1 _ => tc p2 m m' l cl (fun f2 _ =>
branch (simpl_bassn b m) f1 f2 -> s)).
* intros.
apply consequence_tc_suite with
(fun f2 _ => branch (simpl_bassn b m) p f2 -> s).
- intros. apply H2.
apply Then.
all: try assumption.
- assumption.
* assumption.
Qed.
Lemma opt_1_false:
forall p1 p2 b m m' l cl (s : Prop),
~simpl_bassn b m ->
tc p1 m m' l cl (fun f1 _ =>
tc p2 m m' l cl (fun f2 _ => branch (simpl_bassn b m) f1 f2 -> s)) ->
tc p1 m m' l cl (fun f1 _ =>
tc p2 m m' l cl (fun f2 _ => f2 -> s)).
Proof.
intros.
apply consequence_tc_suite with
(fun f1 _ => tc p2 m m' l cl (fun f2 _ =>
branch (simpl_bassn b m) f1 f2 -> s)).
* intros.
apply consequence_tc_suite with
(fun f2 _ => branch (simpl_bassn b m) p f2 -> s).
- intros. apply H2.
apply Else.
all: try assumption.
- assumption.
* assumption.
Qed.
Lemma simpl_tc :
forall p m m' l cl (s : Prop),
tc p m m' l cl (fun _ _ => s) -> s .
Proof.
induction p;simpl.
* intros. apply H.
* intros. apply H.
* intros. apply H.
* intros. apply H.
* intros.
assert (H1: tc p1 m m l cl (fun _ _ => s)).
{ intros.
eapply consequence_tc_suite with
((fun _ h => tc p2 m m' h cl (fun _ _ => s))).
+ intros.
eapply IHp2.
apply H0.
+ apply H.
}
eapply IHp1.
apply H1.
* intros.
eapply IHp2.
eapply IHp1.
apply H.
* intros. apply H.
* intros. apply H.
Qed.
Lemma true_tc :
forall p m m' l cl,
True -> tc p m m' l cl (fun _ _ => True).
Proof.
induction p;simpl;intros.
all: try auto.
* eapply consequence_tc_suite.
+ intros.
apply IHp2.
apply H0.
+ apply IHp1. auto.
* eapply consequence_tc_suite.
+ intros.
apply IHp2.
apply H0.
+ apply IHp1. auto.
Qed.
Lemma rev_simpl_tc :
forall p m m' l cl (s : Prop),
s -> tc p m m' l cl (fun _ _ => s) .
Proof.
induction p;simpl.
* intros. apply H.
* intros. apply H.
* intros. apply H.
* intros. apply H.
* intros.
apply consequence_tc_suite with (fun _ _ => s).
+ intros.
apply IHp2.
apply H.
+ apply IHp1.
apply H.
* intros.
apply consequence_tc_suite with (fun _ _ => s).
+ intros.
apply IHp2.
apply H.
+ apply IHp1.
apply H.
* intros. apply H.
* intros. apply H.
Qed.
(* The optimized version implies the naive version *)
Lemma tc_same :
forall p cl m l (suite1 : Vcg.suite),
(forall m', tc p m m' l cl (fun p h => p -> suite1 m' h)) ->
Vcg.tc p m l cl suite1.
Proof.
intros.
generalize dependent suite1.
generalize dependent l.
generalize dependent m.
induction p;simpl.
* intros. apply H. symmetry. assumption.
* intros. apply H. assumption.
* intros. apply H. assumption.
* intros. apply H. auto.
* intros.
eapply Vcg.consequence_tc_suite.
+ intros.
apply IHp2.
apply H0.
+ apply IHp1.
intros.
eapply consequence_tc_suite.
- intros p l0 He Hp m'0.
generalize dependent Hp.
generalize dependent m'0.
apply He.
- apply prenexe_tc.
intros.
eapply consequence_tc_suite.
** intros p l0 He.
apply intros_tc.
eapply consequence_tc_suite with
(fun f h => p /\ f -> suite1 s h).
++ auto.
++ apply He.
** apply H.
* intros.
split;intros.
+ apply IHp1.
intros.
specialize (H m').
apply bassn_simpl_bassn in H0.
specialize (opt_1_true p1 p2 b m m' l cl (suite1 m' (m :: l)) H0 H).
intros.
eapply consequence_tc_suite.
- intros p l0 He.
apply (simpl_tc p2 m m' l cl (p -> suite1 m' (m :: l))).
apply He.
- apply H1.
+ apply IHp2.
intros.
specialize (H m').
apply bassn_not_simpl_bassn_not in H0.
specialize (opt_1_false p1 p2 b m m' l cl (suite1 m' (m :: l)) H0 H).
intros.
apply
(simpl_tc p1 m m' l cl (tc p2 m m' l cl (fun p _ => p -> suite1 m' (m :: l)))).
apply H1.
* intros.
apply H.
apply bexp_eval_false in H2.
apply bassn_not_simpl_bassn_not in H2.
auto.
* intros.
apply H.
auto.
Qed.
(** Definition of a verification condition generator for the auxiliary goals **)
Fixpoint tc' (c : com) (m: Sigma.sigma) (h: Vcg.history) (cl: Phi.phi) : Prop :=
match c with
| CSkip => True
| CAss x a => True
| CAssr x a => True
| CAssert b => b (m :: h)
| CSeq p1 p2 => tc' p1 m h cl /\
forall m'',
tc p1 m m'' h cl (fun f h => f -> tc' p2 m'' h cl)
| CIf b p1 p2 =>
(simpl_bassn b m -> tc' p1 m h cl) /\ (~simpl_bassn b m -> tc' p2 m h cl)
| CWhile b p inv => inv (m :: h) /\
(forall m', simpl_bassn b m' ->
inv (m' :: h) ->
tc' p m' h cl) /\
(forall m' m'', simpl_bassn b m' ->
inv (m' :: h) ->
tc p m' m'' h cl (fun f _ => f -> inv (m'' :: h)))
| CCall f => (get_pre (cl f)) m
end.
(* The optimized version implies the naive version *)
Lemma tc'_same : forall p cl m l, tc' p m l cl -> Vcg.tc' p m l cl.
Proof.
induction p; simpl.
* intros. auto.
* intros. auto.
* intros. auto.
* intros. apply H.
* intros.
split.
- apply IHp1.
apply H.
- apply tc_same.
intros.
eapply consequence_tc_suite with (fun f h => f -> tc' p2 m' h cl).
+ intros.
apply IHp2.
auto.
+ apply H.
* intros.
split;intros.
- apply IHp1.
apply H.
apply bassn_simpl_bassn in H0.
assumption.
- apply IHp2.
apply H.
apply bassn_not_simpl_bassn_not in H0.
assumption.
* intros.
split.
- apply H.
- split;intros.
+ apply IHp.
apply H.
apply bassn_simpl_bassn in H0.
assumption.
assumption.
+ apply tc_same.
intros.
apply H.
** apply bassn_simpl_bassn.
assumption.
** assumption.
* intros. apply H.
Qed.
(** Definition of a verification condition generator for procedures **)
Definition tc_p (ps: Psi.psi) (cl : Phi.phi) : Prop :=
forall f m m', (get_pre (cl f)) m ->
tc' (ps f) m Vcg.empty_history cl /\
tc (ps f) m m' Vcg.empty_history cl (fun p _ => p -> (get_post (cl f)) m' m).
(* The optimized version implies the naive version *)
Theorem tc_p_same :
forall ps cl,
tc_p ps cl -> Vcg.tc_p ps cl.
Proof.
intros.
unfold Vcg.tc_p.
split;intros.
* apply tc'_same.
apply H.
all: try assumption.
* apply tc_same.
intros.
apply H.
apply H0.
Qed.
(** Definition of a verification condition generator for the auxiliary goals
returning a list of goals **)
Module Tc'_list.
Definition continuation (p1: com) (cl: Phi.phi)
(a : Vcg.suite) (m : sigma) (h: Vcg.history) :=
forall m'' : sigma, tc p1 m m'' h cl (fun f h => f -> a m'' h).
Fixpoint tc'_list (c : com) (cl: Phi.phi) : list Vcg.suite :=
match c with
| CSkip => []
| CAss x a => []
| CAssr x a => []
| CAssert b => [fun m h => b (m :: h)]
| CSeq p1 p2 => tc'_list p1 cl ++
map (continuation p1 cl) (tc'_list p2 cl)
| CIf b p1 p2 => (map (fun a: Vcg.suite =>
fun m h => simpl_bassn b m -> a m h) (tc'_list p1 cl))
++
(map (fun a: Vcg.suite =>
fun m h => ~simpl_bassn b m -> a m h ) (tc'_list p2 cl))
| CWhile b p i => [fun m h => i (m :: h)]
++
(map (fun a: Vcg.suite =>
fun _ h => forall m',
simpl_bassn b m' -> i (m' :: h) ->a m' h) (tc'_list p cl))
++
[fun _ h => forall m' m'',
simpl_bassn b m' -> i (m' :: h) -> tc p m' m'' h cl (fun f _ => f -> i (m''::h))]
| CCall f => [fun m _ => (get_pre (cl f)) m]
end.
(* The optimized version implies the naive version *)
Lemma tc'_list_same :
forall p cl m l,
(forall n, (nth n (tc'_list p cl) (fun _ _ => True)) m l) -> tc' p m l cl.
Proof.
induction p;intros.
+ simpl. auto.
+ simpl. auto.
+ simpl. auto.
+ simpl.
apply (H 0).
+ simpl.
split.
* apply IHp1.
simpl in H.
intro n.
specialize (H n).
destruct (Nat.lt_ge_cases n (length ((tc'_list p1 cl)))).
- rewrite app_nth1 in H; [assumption|assumption].
- rewrite nth_overflow; [ auto | assumption].
* intros.
eapply consequence_tc_suite.
- intros.
apply IHp2.
intros n.
generalize dependent H1.
generalize dependent n.
apply H0.
- simpl in H.
apply prenexe_tc.
intro n.
specialize (H ((length(tc'_list p1 cl))+n)).
rewrite app_nth2_plus in H.
destruct (Nat.lt_ge_cases n (length ((tc'_list p2 cl)))).
++ erewrite nth_indep in H;[|rewrite map_length;assumption].
rewrite map_nth in H.
apply H.
++ rewrite nth_overflow;[ | assumption].
eapply consequence_tc_suite.
** intros. apply H1.
** apply true_tc. auto.
+ simpl.
split.
* intros.
apply IHp1.
simpl in H.
intro n.
specialize (H n).
destruct (Nat.lt_ge_cases n (length ((tc'_list p1 cl)))).
- rewrite app_nth1 in H;[ | rewrite map_length;assumption].
erewrite nth_indep in H;[ | rewrite map_length;assumption].
rewrite
(map_nth (fun (a : Vcg.suite) m h => simpl_bassn b m -> a m h)) in H.
apply H.
assumption.
- rewrite nth_overflow;[auto | assumption].
* intros.
apply IHp2.
simpl in H.
intro n.
specialize (H ((length(tc'_list p1 cl))+n)).
erewrite <- map_length in H.
rewrite app_nth2_plus in H.
destruct (Nat.lt_ge_cases n (length ((tc'_list p2 cl)))).
- erewrite nth_indep in H;[ | rewrite map_length;assumption].
rewrite
(map_nth (fun (a : Vcg.suite) m h => ~simpl_bassn b m -> a m h)) in H.
apply H.
assumption.
- rewrite nth_overflow;[auto | assumption].
+ simpl.
split;[ apply (H 0)| ].
split.
* intros.
apply IHp.
intro n.
specialize (H (1 + n)).
simpl in H.
destruct (Proc.lt_ge_cases n (length ((tc'_list p cl)))).
- rewrite app_nth1 in H ;[ | rewrite map_length;assumption].
erewrite nth_indep in H;[ | rewrite map_length;assumption].
rewrite
(map_nth (fun (a : Vcg.suite) _ h =>
forall m', simpl_bassn b m' -> inv (m' :: h)-> a m' h)) in H.
apply H.
assumption.
assumption.
- rewrite nth_overflow;[auto | assumption].
* intros.
specialize (H (1 + (length (tc'_list p cl)) + 0)).
simpl in H.
erewrite <- map_length in H.
rewrite app_nth2_plus in H.
simpl in H. apply H;[ assumption | assumption ].
+ apply (H 0).
Qed.
End Tc'_list.