Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tej Chajed
stdpp
Commits
cdcfeee8
Commit
cdcfeee8
authored
Dec 14, 2016
by
Ralf Jung
Committed by
Robbert Krebbers
Jan 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
list: relate nth and lookup
parent
30b2cbc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
theories/list.v
theories/list.v
+20
-0
No files found.
theories/list.v
View file @
cdcfeee8
...
...
@@ -477,6 +477,26 @@ Lemma list_lookup_middle l1 l2 x n :
n = length l1 → (l1 ++ x :: l2) !! n = Some x.
Proof. intros ->. by induction l1. Qed.
Lemma nth_lookup_or_length l i d :
{l !! i = Some (nth i l d)} + {(length l ≤ i)%nat}.
Proof.
revert i; induction l; intros i.
- right. simpl. omega.
- destruct i; simpl.
+ left. done.
+ destruct (IHl i) as [->|]; [by left|].
right. omega.
Qed.
Lemma nth_lookup l i d x :
l !! i = Some x → nth i l d = x.
Proof.
revert i; induction l; intros i; [done|].
destruct i; simpl.
- congruence.
- apply IHl.
Qed.
Lemma list_insert_alter l i x : <[i:=x]>l = alter (λ _, x) i l.
Proof. by revert i; induction l; intros []; intros; f_equal/=. Qed.
Lemma alter_length f l i : length (alter f i l) = length l.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment