Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Iris
Iris
Commits
669217fe
Commit
669217fe
authored
Dec 14, 2016
by
Robbert Krebbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify proofs relating nth to lookup.
Also make names more consistent.
parent
b1fa82f0
Pipeline
#3378
passed with stage
in 10 minutes and 51 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
17 deletions
+6
-17
theories/prelude/list.v
theories/prelude/list.v
+6
-17
No files found.
theories/prelude/list.v
View file @
669217fe
...
...
@@ -477,24 +477,13 @@ 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}.
Lemma nth_lookup l i d : nth i l d = from_option id d (l !! i).
Proof. revert i. induction l as [|x l IH]; intros [|i]; simpl; auto. Qed.
Lemma nth_lookup_Some l i d x : l !! i = Some x → nth i l d = x.
Proof. rewrite nth_lookup. by intros ->. Qed.
Lemma nth_lookup_or_length l i d : {l !! i = Some (nth i l d)} + {length l ≤ i}.
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.
rewrite nth_lookup. destruct (l !! i) eqn:?; eauto using lookup_ge_None_1.
Qed.
Lemma list_insert_alter l i x : <[i:=x]>l = alter (λ _, x) i 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