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
Package Registry
Model registry
Operate
Terraform modules
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
Thibaut Pérami
stdpp
Commits
94b04a14
Commit
94b04a14
authored
4 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Add `encode_Z` function to encode element of countable type as `Z`.
parent
b4103098
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
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
theories/countable.v
+14
-4
14 additions, 4 deletions
theories/countable.v
with
16 additions
and
4 deletions
CHANGELOG.md
+
2
−
0
View file @
94b04a14
...
@@ -60,6 +60,8 @@ Noteworthy additions and changes:
...
@@ -60,6 +60,8 @@ Noteworthy additions and changes:
-
Rename
`fin_maps.singleton_proper`
into
`singletonM_proper`
since it concerns
-
Rename
`fin_maps.singleton_proper`
into
`singletonM_proper`
since it concerns
`singletonM`
and to avoid overlap with
`sets.singleton_proper`
.
`singletonM`
and to avoid overlap with
`sets.singleton_proper`
.
-
Add
`wn R`
for weakly normalizing elements w.r.t. a relation
`R`
.
-
Add
`wn R`
for weakly normalizing elements w.r.t. a relation
`R`
.
-
Add
`encode_Z`
/
`decode_Z`
functions to encode elements of a countable type
as integers
`Z`
, in analogy with
`encode_nat`
/
`decode_nat`
.
The following
`sed`
script should perform most of the renaming
The following
`sed`
script should perform most of the renaming
(on macOS, replace
`sed`
by
`gsed`
, installed via e.g.
`brew install gnu-sed`
):
(on macOS, replace
`sed`
by
`gsed`
, installed via e.g.
`brew install gnu-sed`
):
...
...
This diff is collapsed.
Click to expand it.
theories/countable.v
+
14
−
4
View file @
94b04a14
...
@@ -12,15 +12,16 @@ Hint Mode Countable ! - : typeclass_instances.
...
@@ -12,15 +12,16 @@ Hint Mode Countable ! - : typeclass_instances.
Arguments
encode
:
simpl
never
.
Arguments
encode
:
simpl
never
.
Arguments
decode
:
simpl
never
.
Arguments
decode
:
simpl
never
.
Definition
encode_nat
`{
Countable
A
}
(
x
:
A
)
:
nat
:=
pred
(
Pos
.
to_nat
(
encode
x
))
.
Definition
decode_nat
`{
Countable
A
}
(
i
:
nat
)
:
option
A
:=
decode
(
Pos
.
of_nat
(
S
i
))
.
Instance
encode_inj
`{
Countable
A
}
:
Inj
(
=
)
(
=
)
(
encode
(
A
:=
A
))
.
Instance
encode_inj
`{
Countable
A
}
:
Inj
(
=
)
(
=
)
(
encode
(
A
:=
A
))
.
Proof
.
Proof
.
intros
x
y
Hxy
;
apply
(
inj
Some
)
.
intros
x
y
Hxy
;
apply
(
inj
Some
)
.
by
rewrite
<-
(
decode_encode
x
),
Hxy
,
decode_encode
.
by
rewrite
<-
(
decode_encode
x
),
Hxy
,
decode_encode
.
Qed
.
Qed
.
Definition
encode_nat
`{
Countable
A
}
(
x
:
A
)
:
nat
:=
pred
(
Pos
.
to_nat
(
encode
x
))
.
Definition
decode_nat
`{
Countable
A
}
(
i
:
nat
)
:
option
A
:=
decode
(
Pos
.
of_nat
(
S
i
))
.
Instance
encode_nat_inj
`{
Countable
A
}
:
Inj
(
=
)
(
=
)
(
encode_nat
(
A
:=
A
))
.
Instance
encode_nat_inj
`{
Countable
A
}
:
Inj
(
=
)
(
=
)
(
encode_nat
(
A
:=
A
))
.
Proof
.
unfold
encode_nat
;
intros
x
y
Hxy
;
apply
(
inj
encode
);
lia
.
Qed
.
Proof
.
unfold
encode_nat
;
intros
x
y
Hxy
;
apply
(
inj
encode
);
lia
.
Qed
.
Lemma
decode_encode_nat
`{
Countable
A
}
(
x
:
A
)
:
decode_nat
(
encode_nat
x
)
=
Some
x
.
Lemma
decode_encode_nat
`{
Countable
A
}
(
x
:
A
)
:
decode_nat
(
encode_nat
x
)
=
Some
x
.
...
@@ -30,6 +31,15 @@ Proof.
...
@@ -30,6 +31,15 @@ Proof.
by
rewrite
Pos2Nat
.
id
,
decode_encode
.
by
rewrite
Pos2Nat
.
id
,
decode_encode
.
Qed
.
Qed
.
Definition
encode_Z
`{
Countable
A
}
(
x
:
A
)
:
Z
:=
Zpos
(
encode
x
)
.
Definition
decode_Z
`{
Countable
A
}
(
i
:
Z
)
:
option
A
:=
match
i
with
Zpos
i
=>
decode
i
|
_
=>
None
end
.
Instance
encode_Z_inj
`{
Countable
A
}
:
Inj
(
=
)
(
=
)
(
encode_Z
(
A
:=
A
))
.
Proof
.
unfold
encode_Z
;
intros
x
y
Hxy
;
apply
(
inj
encode
);
lia
.
Qed
.
Lemma
decode_encode_Z
`{
Countable
A
}
(
x
:
A
)
:
decode_Z
(
encode_Z
x
)
=
Some
x
.
Proof
.
apply
decode_encode
.
Qed
.
(** * Choice principles *)
(** * Choice principles *)
Section
choice
.
Section
choice
.
Context
`{
Countable
A
}
(
P
:
A
→
Prop
)
.
Context
`{
Countable
A
}
(
P
:
A
→
Prop
)
.
...
...
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