Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
stdpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Iris
stdpp
Commits
8f7f211d
Commit
8f7f211d
authored
7 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Some tweaks to Hai's commit.
parent
8cf5a7ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
theories/countable.v
+18
-42
18 additions, 42 deletions
theories/countable.v
theories/decidable.v
+3
-8
3 additions, 8 deletions
theories/decidable.v
with
21 additions
and
50 deletions
theories/countable.v
+
18
−
42
View file @
8f7f211d
...
@@ -84,14 +84,14 @@ Qed.
...
@@ -84,14 +84,14 @@ Qed.
(** * Instances *)
(** * Instances *)
(** ** Injection *)
(** ** Injection *)
Section
inj
ective
_countable
.
Section
inj_countable
.
Context
`{
Countable
A
,
EqDecision
B
}
.
Context
`{
Countable
A
,
EqDecision
B
}
.
Context
(
f
:
B
→
A
)
(
g
:
A
→
option
B
)
(
fg
:
∀
x
,
g
(
f
x
)
=
Some
x
)
.
Context
(
f
:
B
→
A
)
(
g
:
A
→
option
B
)
(
fg
:
∀
x
,
g
(
f
x
)
=
Some
x
)
.
Program
Instance
inj
ective
_countable
:
Countable
B
:=
Program
Instance
inj_countable
:
Countable
B
:=
{|
encode
y
:=
encode
(
f
y
);
decode
p
:=
x
←
decode
p
;
g
x
|}
.
{|
encode
y
:=
encode
(
f
y
);
decode
p
:=
x
←
decode
p
;
g
x
|}
.
Next
Obligation
.
intros
y
;
simpl
;
rewrite
decode_encode
;
eauto
.
Qed
.
Next
Obligation
.
intros
y
;
simpl
;
rewrite
decode_encode
;
eauto
.
Qed
.
End
inj
ective
_countable
.
End
inj_countable
.
(** ** Option *)
(** ** Option *)
Program
Instance
option_countable
`{
Countable
A
}
:
Countable
(
option
A
)
:=
{|
Program
Instance
option_countable
`{
Countable
A
}
:
Countable
(
option
A
)
:=
{|
...
@@ -257,7 +257,8 @@ Program Instance N_countable : Countable N := {|
...
@@ -257,7 +257,8 @@ Program Instance N_countable : Countable N := {|
decode
p
:=
if
decide
(
p
=
1
)
then
Some
0
%
N
else
Some
(
Npos
(
Pos
.
pred
p
))
decode
p
:=
if
decide
(
p
=
1
)
then
Some
0
%
N
else
Some
(
Npos
(
Pos
.
pred
p
))
|}
.
|}
.
Next
Obligation
.
Next
Obligation
.
by
intros
[|
p
];
simpl
;[|
rewrite
decide_False
,
Pos
.
pred_succ
by
(
by
destruct
p
)]
.
intros
[|
p
];
simpl
;
[
done
|]
.
by
rewrite
decide_False
,
Pos
.
pred_succ
by
(
by
destruct
p
)
.
Qed
.
Qed
.
Program
Instance
Z_countable
:
Countable
Z
:=
{|
Program
Instance
Z_countable
:
Countable
Z
:=
{|
encode
x
:=
match
x
with
Z0
=>
1
|
Zpos
p
=>
p
~
0
|
Zneg
p
=>
p
~
1
end
;
encode
x
:=
match
x
with
Z0
=>
1
|
Zpos
p
=>
p
~
0
|
Zneg
p
=>
p
~
1
end
;
...
@@ -270,44 +271,19 @@ Next Obligation.
...
@@ -270,44 +271,19 @@ Next Obligation.
by
intros
x
;
lazy
beta
;
rewrite
decode_encode
;
csimpl
;
rewrite
Nat2N
.
id
.
by
intros
x
;
lazy
beta
;
rewrite
decode_encode
;
csimpl
;
rewrite
Nat2N
.
id
.
Qed
.
Qed
.
Global
Program
Instance
Qc_countable
:
Countable
Qc
:=
Definition
_
Q2pair
(
p
:
Q
):
_
:=
(
Qnum
p
,
Qden
p
)
.
inj_countable
(
λ
p
:
Qc
,
let
'
Qcmake
(
x
#
y
)
_
:=
p
return
_
in
(
x
,
y
))
Definition
_
pair2Q
(
p
:
Z
*
positive
)
:
Q
:=
(
λ
q
:
Z
*
positive
,
let
'
(
x
,
y
)
:=
q
return
_
in
Some
(
Q2Qc
(
x
#
y
)))
_
.
match
p
with
Next
Obligation
.
|
(
num
,
den
)
=>
Qmake
num
den
intros
[[
x
y
]
Hcan
]
.
f_equal
.
apply
Qc_is_canon
.
simpl
.
by
rewrite
Hcan
.
end
.
Instance
Q_dec_eq
:
EqDecision
Q
:=
injective_dec_eq
_
Q2pair
(
Some
∘
_
pair2Q
)
_
.
Proof
.
by
destruct
0
.
Qed
.
Instance
Q_countable
:
Countable
Q
:=
injective_countable
_
Q2pair
(
Some
∘
_
pair2Q
)
_
.
Proof
.
by
destruct
0
.
Qed
.
Definition
_
Qc_to_Q
(
p
:
Qc
):
_
:=
match
p
with
|
Qcmake
pb
_
=>
pb
end
.
Global
Instance
Qc_countable
:
Countable
Qc
:=
injective_countable
_
Qc_to_Q
(
Some
∘
Q2Qc
)
_
.
Proof
.
intros
[
p
Can
]
.
simpl
.
f_equal
.
apply
Qc_is_canon
.
simpl
.
rewrite
Can
.
reflexivity
.
Qed
.
Qed
.
Definition
_
Qc2Qp
(
p
:
Qc
)
:
option
Qp
:=
Global
Program
Instance
Qp_countable
:
Countable
Qp
:=
match
(
decide
(
0
<
p
)
%
Qc
)
with
inj_countable
|
left
G0
=>
Some
(
mk_Qp
p
G0
)
Qp_car
|
_
=>
None
(
λ
p
:
Qc
,
guard
(
0
<
p
)
%
Qc
as
Hp
;
Some
(
mk_Qp
p
Hp
))
_
.
end
.
Next
Obligation
.
intros
[
p
Hp
]
.
unfold
mguard
,
option_guard
;
simpl
.
Global
Instance
Qp_countable
:
Countable
Qp
:=
case_match
;
[|
done
]
.
f_equal
.
by
apply
Qp_eq
.
injective_countable
Qp_car
(_
Qc2Qp
)
_
.
Proof
.
intros
[
p
G0
]
.
unfold
_
Qc2Qp
.
simpl
.
destruct
(
decide
(
0
<
p
)
%
Qc
);
[|
tauto
]
.
f_equal
.
apply
Qp_eq
.
auto
.
Qed
.
Qed
.
This diff is collapsed.
Click to expand it.
theories/decidable.v
+
3
−
8
View file @
8f7f211d
...
@@ -201,11 +201,6 @@ Proof. destruct (decide P); tauto. Qed.
...
@@ -201,11 +201,6 @@ Proof. destruct (decide P); tauto. Qed.
Lemma
not_and_r_alt
{
P
Q
:
Prop
}
`{
Decision
Q
}
:
¬
(
P
∧
Q
)
↔
(
¬
P
∧
Q
)
∨
¬
Q
.
Lemma
not_and_r_alt
{
P
Q
:
Prop
}
`{
Decision
Q
}
:
¬
(
P
∧
Q
)
↔
(
¬
P
∧
Q
)
∨
¬
Q
.
Proof
.
destruct
(
decide
Q
);
tauto
.
Qed
.
Proof
.
destruct
(
decide
Q
);
tauto
.
Qed
.
Lemma
injective_dec_eq
`{
EqDecision
A
}
{
B
:
Type
}
Program
Definition
inj_eq_dec
`{
EqDecision
A
}
{
B
}
(
f
:
B
→
A
)
f
(
g
:
A
->
option
B
)
(
Inj
:
∀
x
,
g
(
f
x
)
=
Some
x
)
`{
!
Inj
(
=
)
(
=
)
f
}
:
EqDecision
B
:=
λ
x
y
,
cast_if
(
decide
(
f
x
=
f
y
))
.
:
EqDecision
B
.
Solve
Obligations
with
firstorder
congruence
.
Proof
.
intros
x
y
.
destruct
(
decide
(
f
x
=
f
y
))
as
[
Eq
%
(
f_equal
g
)|
NEq
]
.
-
rewrite
!
Inj
in
Eq
.
inversion
Eq
.
left
;
auto
.
-
right
.
intros
Eq
.
apply
NEq
.
rewrite
Eq
.
auto
.
Qed
.
This diff is collapsed.
Click to expand it.
Robbert Krebbers
@robbertkrebbers
mentioned in merge request
!4 (merged)
·
7 years ago
mentioned in merge request
!4 (merged)
mentioned in merge request !4
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment