Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stdpp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
49
Issues
49
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Iris
stdpp
Commits
88e31976
Commit
88e31976
authored
Aug 02, 2017
by
Robbert Krebbers
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'haidang/coq-stdpp-hai/QpCountable'
parents
ee6200b4
8f7f211d
Pipeline
#4286
passed with stage
in 7 minutes and 14 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
5 deletions
+28
-5
theories/countable.v
theories/countable.v
+24
-5
theories/decidable.v
theories/decidable.v
+4
-0
No files found.
theories/countable.v
View file @
88e31976
(* Copyright (c) 2012-2017, Coq-std++ developers. *)
(* 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"
.
Local
Open
Scope
positive
.
...
...
@@ -83,14 +84,14 @@ Qed.
(** * Instances *)
(** ** Injection *)
Section
inj
ective
_countable
.
Section
inj_countable
.
Context
`
{
Countable
A
,
EqDecision
B
}.
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
|}.
Next
Obligation
.
intros
y
;
simpl
;
rewrite
decode_encode
;
eauto
.
Qed
.
End
inj
ective
_countable
.
End
inj_countable
.
(** ** Option *)
Program
Instance
option_countable
`
{
Countable
A
}
:
Countable
(
option
A
)
:
=
{|
...
...
@@ -256,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
))
|}.
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
.
Program
Instance
Z_countable
:
Countable
Z
:
=
{|
encode
x
:
=
match
x
with
Z0
=>
1
|
Zpos
p
=>
p
~
0
|
Zneg
p
=>
p
~
1
end
;
...
...
@@ -268,3 +270,20 @@ Program Instance nat_countable : Countable nat :=
Next
Obligation
.
by
intros
x
;
lazy
beta
;
rewrite
decode_encode
;
csimpl
;
rewrite
Nat2N
.
id
.
Qed
.
Global
Program
Instance
Qc_countable
:
Countable
Qc
:
=
inj_countable
(
λ
p
:
Qc
,
let
'
Qcmake
(
x
#
y
)
_
:
=
p
return
_
in
(
x
,
y
))
(
λ
q
:
Z
*
positive
,
let
'
(
x
,
y
)
:
=
q
return
_
in
Some
(
Q2Qc
(
x
#
y
)))
_
.
Next
Obligation
.
intros
[[
x
y
]
Hcan
].
f_equal
.
apply
Qc_is_canon
.
simpl
.
by
rewrite
Hcan
.
Qed
.
Global
Program
Instance
Qp_countable
:
Countable
Qp
:
=
inj_countable
Qp_car
(
λ
p
:
Qc
,
guard
(
0
<
p
)%
Qc
as
Hp
;
Some
(
mk_Qp
p
Hp
))
_
.
Next
Obligation
.
intros
[
p
Hp
].
unfold
mguard
,
option_guard
;
simpl
.
case_match
;
[|
done
].
f_equal
.
by
apply
Qp_eq
.
Qed
.
theories/decidable.v
View file @
88e31976
...
...
@@ -200,3 +200,7 @@ Lemma not_and_l_alt {P Q : Prop} `{Decision P} : ¬(P ∧ Q) ↔ ¬P ∨ (¬Q
Proof
.
destruct
(
decide
P
)
;
tauto
.
Qed
.
Lemma
not_and_r_alt
{
P
Q
:
Prop
}
`
{
Decision
Q
}
:
¬
(
P
∧
Q
)
↔
(
¬
P
∧
Q
)
∨
¬
Q
.
Proof
.
destruct
(
decide
Q
)
;
tauto
.
Qed
.
Program
Definition
inj_eq_dec
`
{
EqDecision
A
}
{
B
}
(
f
:
B
→
A
)
`
{!
Inj
(=)
(=)
f
}
:
EqDecision
B
:
=
λ
x
y
,
cast_if
(
decide
(
f
x
=
f
y
)).
Solve
Obligations
with
firstorder
congruence
.
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