Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Rodolphe Lepigre
stdpp
Commits
fba969b6
Commit
fba969b6
authored
Feb 06, 2019
by
Robbert Krebbers
Browse files
Infinite instances for prod/sum.
parent
db714636
Changes
1
Hide whitespace changes
Inline
Side-by-side
theories/infinite.v
View file @
fba969b6
...
@@ -11,17 +11,27 @@ Class Infinite A := {
...
@@ -11,17 +11,27 @@ Class Infinite A := {
inject_injective
:
>
Inj
(=)
(=)
inject
;
inject_injective
:
>
Inj
(=)
(=)
inject
;
}.
}.
(** Instances *)
Program
Definition
inj_infinite
`
{
Infinite
A
}
{
B
}
(
f
:
A
→
B
)
`
{!
Inj
(=)
(=)
f
}
:
Infinite
B
:
=
{|
inject
:
=
f
∘
inject
|}.
Instance
string_infinite
:
Infinite
string
:
=
{|
inject
:
=
λ
x
,
"~"
+
:
+
pretty
x
|}.
Instance
string_infinite
:
Infinite
string
:
=
{|
inject
:
=
λ
x
,
"~"
+
:
+
pretty
x
|}.
Instance
nat_infinite
:
Infinite
nat
:
=
{|
inject
:
=
id
|}.
Instance
nat_infinite
:
Infinite
nat
:
=
{|
inject
:
=
id
|}.
Instance
N_infinite
:
Infinite
N
:
=
{|
inject_injective
:
=
Nat2N
.
inj
|}.
Instance
N_infinite
:
Infinite
N
:
=
{|
inject_injective
:
=
Nat2N
.
inj
|}.
Instance
positive_infinite
:
Infinite
positive
:
=
{|
inject_injective
:
=
SuccNat2Pos
.
inj
|}.
Instance
positive_infinite
:
Infinite
positive
:
=
{|
inject_injective
:
=
SuccNat2Pos
.
inj
|}.
Instance
Z_infinite
:
Infinite
Z
:
=
{|
inject_injective
:
=
Nat2Z
.
inj
|}.
Instance
Z_infinite
:
Infinite
Z
:
=
{|
inject_injective
:
=
Nat2Z
.
inj
|}.
Instance
option_infinite
`
{
Infinite
A
}
:
Infinite
(
option
A
)
:
=
{|
inject
:
=
Some
∘
inject
|}.
Instance
option_infinite
`
{
Infinite
A
}
:
Infinite
(
option
A
)
:
=
inj_infinite
Some
.
Instance
sum_infinite_l
`
{
Infinite
A
}
{
B
}
:
Infinite
(
A
+
B
)
:
=
inj_infinite
inl
.
Instance
sum_infinite_r
{
A
}
`
{
Infinite
B
}
:
Infinite
(
A
+
B
)
:
=
inj_infinite
inr
.
Instance
prod_infinite_l
`
{
Infinite
A
,
Inhabited
B
}
:
Infinite
(
A
*
B
)
:
=
inj_infinite
(,
inhabitant
).
Instance
prod_infinite_r
`
{
Inhabited
A
,
Infinite
B
}
:
Infinite
(
A
*
B
)
:
=
inj_infinite
(
inhabitant
,).
Program
Instance
list_infinite
`
{
Inhabited
A
}
:
Infinite
(
list
A
)
:
=
Program
Instance
list_infinite
`
{
Inhabited
A
}
:
Infinite
(
list
A
)
:
=
{|
inject
:
=
λ
i
,
replicate
i
inhabitant
|}.
{|
inject
:
=
λ
i
,
replicate
i
inhabitant
|}.
Next
Obligation
.
Next
Obligation
.
Proof
.
intros
A
*
i
j
Heqrep
%(
f_equal
length
).
intros
A
*
i
j
Heqrep
%(
f_equal
length
).
rewrite
!
replicate_length
in
Heqrep
;
done
.
rewrite
!
replicate_length
in
Heqrep
;
done
.
Qed
.
Qed
.
...
...
Write
Preview
Supports
Markdown
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