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
stdpp
Commits
653cb9db
Commit
653cb9db
authored
Jul 15, 2020
by
Ralf Jung
Committed by
Robbert Krebbers
Jul 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add map_filter_insert_not_delete
by Tej
parent
5bdd73dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
theories/fin_maps.v
theories/fin_maps.v
+45
-0
theories/list.v
theories/list.v
+11
-0
No files found.
theories/fin_maps.v
View file @
653cb9db
...
...
@@ -1132,6 +1132,17 @@ Section map_filter.
+
rewrite
Eq
,
Hm
,
lookup_insert
.
naive_solver
.
+
by
rewrite
lookup_insert_ne
.
Qed
.
Lemma
map_filter_lookup_Some_11
m
i
x
:
filter
P
m
!!
i
=
Some
x
→
m
!!
i
=
Some
x
.
Proof
.
apply
map_filter_lookup_Some
.
Qed
.
Lemma
map_filter_lookup_Some_12
m
i
x
:
filter
P
m
!!
i
=
Some
x
→
P
(
i
,
x
).
Proof
.
apply
map_filter_lookup_Some
.
Qed
.
Lemma
map_filter_lookup_Some_2
m
i
x
:
m
!!
i
=
Some
x
→
P
(
i
,
x
)
→
filter
P
m
!!
i
=
Some
x
.
Proof
.
intros
.
by
apply
map_filter_lookup_Some
.
Qed
.
Lemma
map_filter_lookup_None
m
i
:
filter
P
m
!!
i
=
None
↔
m
!!
i
=
None
∨
∀
x
,
m
!!
i
=
Some
x
→
¬
P
(
i
,
x
).
...
...
@@ -1139,6 +1150,14 @@ Section map_filter.
rewrite
eq_None_not_Some
.
unfold
is_Some
.
setoid_rewrite
map_filter_lookup_Some
.
naive_solver
.
Qed
.
Lemma
map_filter_lookup_None_1
m
i
:
filter
P
m
!!
i
=
None
→
m
!!
i
=
None
∨
∀
x
,
m
!!
i
=
Some
x
→
¬
P
(
i
,
x
).
Proof
.
apply
map_filter_lookup_None
.
Qed
.
Lemma
map_filter_lookup_None_2
m
i
:
m
!!
i
=
None
∨
(
∀
x
:
A
,
m
!!
i
=
Some
x
→
¬
P
(
i
,
x
))
→
filter
P
m
!!
i
=
None
.
Proof
.
apply
map_filter_lookup_None
.
Qed
.
Lemma
map_filter_lookup_eq
m1
m2
:
(
∀
k
x
,
P
(
k
,
x
)
→
m1
!!
k
=
Some
x
↔
m2
!!
k
=
Some
x
)
→
...
...
@@ -1170,6 +1189,14 @@ Section map_filter.
(
∀
y
,
¬
P
(
i
,
y
))
→
filter
P
(<[
i
:
=
x
]>
m
)
=
filter
P
m
.
Proof
.
intros
HP
.
by
apply
map_filter_insert_not'
.
Qed
.
Lemma
map_filter_insert_not_delete
m
i
x
:
¬
P
(
i
,
x
)
→
filter
P
(<[
i
:
=
x
]>
m
)
=
filter
P
(
delete
i
m
).
Proof
.
intros
.
rewrite
<-
insert_delete
by
done
.
rewrite
map_filter_insert_not'
;
[
done
..|].
rewrite
lookup_delete
;
done
.
Qed
.
Lemma
map_filter_delete
m
i
:
filter
P
(
delete
i
m
)
=
delete
i
(
filter
P
m
).
Proof
.
apply
map_eq
.
intros
j
.
apply
option_eq
;
intros
y
.
...
...
@@ -1200,6 +1227,24 @@ Section map_filter.
Qed
.
End
map_filter
.
Lemma
map_filter_fmap
{
A
A2
}
(
P
:
K
*
A
→
Prop
)
`
{!
∀
x
,
Decision
(
P
x
)}
(
f
:
A2
→
A
)
(
m
:
M
A2
)
:
filter
P
(
f
<$>
m
)
=
f
<$>
filter
(
λ
'
(
k
,
v
),
P
(
k
,
(
f
v
)))
m
.
Proof
.
apply
map_eq
.
intros
i
.
apply
option_eq
;
intros
x
.
repeat
(
rewrite
lookup_fmap
,
fmap_Some
||
setoid_rewrite
map_filter_lookup_Some
).
naive_solver
.
Qed
.
Lemma
map_filter_iff
{
A
}
(
P1
P2
:
K
*
A
→
Prop
)
`
{!
∀
x
,
Decision
(
P1
x
),
!
∀
x
,
Decision
(
P2
x
)}
(
m
:
M
A
)
:
(
∀
x
,
P1
x
↔
P2
x
)
→
filter
P1
m
=
filter
P2
m
.
Proof
.
intros
HPiff
.
rewrite
!
map_filter_alt
.
f_equal
.
apply
list_filter_iff
.
done
.
Qed
.
(** ** Properties of the [map_Forall] predicate *)
Section
map_Forall
.
Context
{
A
}
(
P
:
K
→
A
→
Prop
).
...
...
theories/list.v
View file @
653cb9db
...
...
@@ -1791,6 +1791,17 @@ Section filter.
Qed.
End filter.
Lemma list_filter_iff (P1 P2 : A → Prop)
`{!∀ x, Decision (P1 x), !∀ x, Decision (P2 x)} (l : list A) :
(∀ x, P1 x ↔ P2 x) →
filter P1 l = filter P2 l.
Proof.
intros HPiff. induction l as [|a l IH]; [done|].
destruct (decide (P1 a)).
- rewrite !filter_cons_True by naive_solver. by rewrite IH.
- rewrite !filter_cons_False by naive_solver. by rewrite IH.
Qed.
(** ** Properties of the [prefix] and [suffix] predicates *)
Global Instance: PreOrder (@prefix A).
Proof.
...
...
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