-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVariants4.v
55 lines (50 loc) · 1.32 KB
/
Variants4.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
Require Import Arith NPeano List.
Inductive ListSum : list nat -> nat -> Type :=
| ListSumNil :
ListSum nil 0
| ListSumCons :
forall (h : nat) (tl : list nat) (n : nat),
ListSum tl n ->
ListSum (h :: tl) (h + n).
Theorem new5 :
forall (n m : nat) (l1 l2 : list nat),
ListSum l1 n ->
ListSum (l1 ++ l2) (n + m) ->
ListSum l2 m.
Proof.
intros. induction H.
- apply H0.
- inversion H0. subst.
rewrite plus_assoc_reverse in H4.
assert (n0 = n + m).
+ eapply plus_reg_l; eauto.
+ subst. apply IHListSum in H2. apply H2.
Qed.
Theorem old5_v1 :
forall (n m : nat) (l1 l2 : list nat),
ListSum l1 n ->
ListSum (l1 ++ l2) (n + m) ->
ListSum (rev (rev l2)) m.
Proof.
intros. rewrite rev_involutive. induction H.
- apply H0.
- inversion H0. subst.
rewrite plus_assoc_reverse in H4.
assert (n0 = n + m).
+ eapply plus_reg_l; eauto.
+ subst. apply IHListSum in H2. apply H2.
Qed.
Theorem old5_v2 :
forall (n m : nat) (l1 l2 : list nat),
ListSum l1 n ->
ListSum (l1 ++ l2) (n + m) ->
ListSum (rev (rev l2)) m.
Proof.
intros. induction H.
- rewrite rev_involutive. apply H0.
- inversion H0. subst.
rewrite plus_assoc_reverse in H4.
assert (n0 = n + m).
+ eapply plus_reg_l; eauto.
+ subst. apply IHListSum in H2. apply H2.
Qed.