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
8cf5a7ad
Commit
8cf5a7ad
authored
7 years ago
by
Hai Dang
Browse files
Options
Downloads
Patches
Plain Diff
add countability for Q, Qc, and Qp
parent
ee6200b4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Add countability for Q, Qc, and Qp
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
theories/countable.v
+44
-1
44 additions, 1 deletion
theories/countable.v
theories/decidable.v
+9
-0
9 additions, 0 deletions
theories/decidable.v
with
53 additions
and
1 deletion
theories/countable.v
+
44
−
1
View file @
8cf5a7ad
(* Copyright (c) 2012-2017, Coq-std++ developers. *)
(* Copyright (c) 2012-2017, Coq-std++ developers. *)
(* This file is distributed under the terms of the BSD license. *)
(* This file is distributed under the terms of the BSD license. *)
From
stdpp
Require
Export
list
.
From
Coq
.
QArith
Require
Import
QArith_base
Qcanon
.
From
stdpp
Require
Export
list
numbers
.
Set
Default
Proof
Using
"Type"
.
Set
Default
Proof
Using
"Type"
.
Local
Open
Scope
positive
.
Local
Open
Scope
positive
.
...
@@ -268,3 +269,45 @@ Program Instance nat_countable : Countable nat :=
...
@@ -268,3 +269,45 @@ Program Instance nat_countable : Countable nat :=
Next
Obligation
.
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
.
Definition
_
Q2pair
(
p
:
Q
):
_
:=
(
Qnum
p
,
Qden
p
)
.
Definition
_
pair2Q
(
p
:
Z
*
positive
)
:
Q
:=
match
p
with
|
(
num
,
den
)
=>
Qmake
num
den
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
.
Definition
_
Qc2Qp
(
p
:
Qc
)
:
option
Qp
:=
match
(
decide
(
0
<
p
)
%
Qc
)
with
|
left
G0
=>
Some
(
mk_Qp
p
G0
)
|
_
=>
None
end
.
Global
Instance
Qp_countable
:
Countable
Qp
:=
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
.
This diff is collapsed.
Click to expand it.
theories/decidable.v
+
9
−
0
View file @
8cf5a7ad
...
@@ -200,3 +200,12 @@ Lemma not_and_l_alt {P Q : Prop} `{Decision P} : ¬(P ∧ Q) ↔ ¬P ∨ (¬Q
...
@@ -200,3 +200,12 @@ Lemma not_and_l_alt {P Q : Prop} `{Decision P} : ¬(P ∧ Q) ↔ ¬P ∨ (¬Q
Proof
.
destruct
(
decide
P
);
tauto
.
Qed
.
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
}
f
(
g
:
A
->
option
B
)
(
Inj
:
∀
x
,
g
(
f
x
)
=
Some
x
)
:
EqDecision
B
.
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.
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