Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
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
23
Issues
23
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
a62a60ae
Commit
a62a60ae
authored
Oct 31, 2017
by
Johannes Kloos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compile fixes and addition of wf_guard.
parent
34e58198
Changes
1
Hide whitespace changes
Inline
Sidebyside
Showing
1 changed file
with
28 additions
and
26 deletions
+28
26
theories/infinite.v
theories/infinite.v
+28
26
No files found.
theories/infinite.v
View file @
a62a60ae
(* Copyright (c) 20122017, Coqstd++ developers. *)
(* Copyright (c) 20122017, Coqstd++ 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
Import
pretty
fin_collections
.
From
stdpp
Require
Import
pretty
fin_collections
relations
prelude
.
(** The class [Infinite] axiomatizes types with infinitely many elements
(** The class [Infinite] axiomatizes types with infinitely many elements
by giving an injection from the natural numbers into the type. It is mostly
by giving an injection from the natural numbers into the type. It is mostly
...
@@ 25,7 +25,7 @@ Qed.
...
@@ 25,7 +25,7 @@ Qed.
(** * Fresh elements *)
(** * Fresh elements *)
Section
Fresh
.
Section
Fresh
.
Context
`
{
Infinite
A
,
∀
(
x
:
A
)
(
s
:
C
),
Decision
(
x
∈
s
)}.
Context
`
{
FinCollection
A
C
}
`
{
Infinite
A
,
!
RelDecision
(@
elem_of
A
C
_
)}.
Lemma
subset_difference_in
{
x
:
A
}
{
s
:
C
}
(
inx
:
x
∈
s
)
:
s
∖
{[
x
]}
⊂
s
.
Lemma
subset_difference_in
{
x
:
A
}
{
s
:
C
}
(
inx
:
x
∈
s
)
:
s
∖
{[
x
]}
⊂
s
.
Proof
.
set_solver
.
Qed
.
Proof
.
set_solver
.
Qed
.
...
@@ 47,36 +47,35 @@ Section Fresh.
...
@@ 47,36 +47,35 @@ Section Fresh.
apply
relfg
.
apply
relfg
.
Qed
.
Qed
.
Definition
fresh_generic_fix
:
=
Fix
collection_wf
(
const
(
nat
→
A
))
fresh_generic_body
.
Definition
fresh_generic_fix
u
:
=
Fix
(
wf_guard
u
collection_wf
)
(
const
(
nat
→
A
))
fresh_generic_body
.
Lemma
fresh_generic_fixpoint_unfold
s
n
:
Lemma
fresh_generic_fixpoint_unfold
u
s
n
:
fresh_generic_fix
s
n
=
fresh_generic_body
s
(
λ
s'
_
n
,
fresh_generic_fix
s'
n
)
n
.
fresh_generic_fix
u
s
n
=
fresh_generic_body
s
(
λ
s'
_
n
,
fresh_generic_fix
u
s'
n
)
n
.
Proof
.
Proof
.
apply
(
Fix_unfold_rel
collection_wf
(
const
(
nat
→
A
))
(
const
(
pointwise_relation
nat
(=)))
apply
(
Fix_unfold_rel
(
wf_guard
u
collection_wf
)
(
const
(
nat
→
A
))
(
const
(
pointwise_relation
nat
(=)))
fresh_generic_body
fresh_generic_body_proper
s
n
).
fresh_generic_body
fresh_generic_body_proper
s
n
).
Qed
.
Qed
.
Lemma
fresh_generic_fixpoint_spec
s
n
:
Lemma
fresh_generic_fixpoint_spec
u
s
n
:
∃
m
,
n
≤
m
∧
fresh_generic_fix
s
n
=
inject
m
∧
inject
m
∉
s
∧
∀
i
,
n
≤
i
<
m
→
inject
i
∈
s
.
∃
m
,
n
≤
m
∧
fresh_generic_fix
u
s
n
=
inject
m
∧
inject
m
∉
s
∧
∀
i
,
n
≤
i
<
m
→
inject
i
∈
s
.
Proof
.
Proof
.
revert
n
.
revert
n
.
induction
s
as
[
s
IH
]
using
(
well_founded_ind
collection_wf
)
;
intro
.
induction
s
as
[
s
IH
]
using
(
well_founded_ind
collection_wf
)
;
intro
.
setoid_rewrite
fresh_generic_fixpoint_unfold
;
unfold
fresh_generic_body
.
setoid_rewrite
fresh_generic_fixpoint_unfold
;
unfold
fresh_generic_body
.
destruct
decide
as
[
case

case
].
destruct
decide
as
[
case

case
]
;
eauto
with
omega
.

destruct
(
IH
_
(
subset_difference_in
case
)
(
S
n
))
as
[
m
[
mbound
[
eqfix
[
notin
inbelow
]]]].
destruct
(
IH
_
(
subset_difference_in
case
)
(
S
n
))
as
[
m
[
mbound
[
eqfix
[
notin
inbelow
]]]].
exists
m
;
repeat
split
;
auto
.
exists
m
;
repeat
split
;
auto
with
omega
.
+
omega
.

rewrite
not_elem_of_difference
,
elem_of_singleton
in
notin
.
+
rewrite
not_elem_of_difference
,
elem_of_singleton
in
notin
.
destruct
notin
as
[??%
inject_injective
]
;
auto
with
omega
.
destruct
notin
as
[??%
inject_injective
]
;
auto
;
omega
.

intros
i
ibound
.
+
intros
i
ibound
.
destruct
(
decide
(
i
=
n
))
as
[<
neq
]
;
auto
.
destruct
(
decide
(
i
=
n
))
as
[<
neq
]
;
auto
.
enough
(
inject
i
∈
s
∖
{[
inject
n
]})
by
set_solver
.
enough
(
inject
i
∈
s
∖
{[
inject
n
]})
by
set_solver
.
apply
inbelow
;
omega
.
apply
inbelow
;
omega
.

exists
n
;
repeat
split
;
auto
.
intros
;
omega
.
Qed
.
Qed
.
Instance
fresh_generic
:
Fresh
A
C

20
:
=
λ
s
,
fresh_generic_fix
s
0
.
Instance
fresh_generic
:
Fresh
A
C

20
:
=
λ
s
,
fresh_generic_fix
(
1
+
Nat
.
log2
(
size
s
))
s
0
.
Instance
fresh_generic_spec
:
FreshSpec
A
C
.
Instance
fresh_generic_spec
:
FreshSpec
A
C
.
Proof
.
Proof
.
...
@@ 84,20 +83,23 @@ Section Fresh.
...
@@ 84,20 +83,23 @@ Section Fresh.

apply
_
.

apply
_
.

intros
*
eqXY
.

intros
*
eqXY
.
unfold
fresh
,
fresh_generic
.
unfold
fresh
,
fresh_generic
.
destruct
(
fresh_generic_fixpoint_spec
X
0
)
as
[
mX
[
_
[>
[
notinX
belowinX
]]]].
destruct
(
fresh_generic_fixpoint_spec
(
1
+
Nat
.
log2
(
size
X
))
X
0
)
destruct
(
fresh_generic_fixpoint_spec
Y
0
)
as
[
mY
[
_
[>
[
notinY
belowinY
]]]].
as
[
mX
[
_
[>
[
notinX
belowinX
]]]].
destruct
(
fresh_generic_fixpoint_spec
(
1
+
Nat
.
log2
(
size
Y
))
Y
0
)
as
[
mY
[
_
[>
[
notinY
belowinY
]]]].
destruct
(
Nat
.
lt_trichotomy
mX
mY
)
as
[
case
[>
case
]]
;
auto
.
destruct
(
Nat
.
lt_trichotomy
mX
mY
)
as
[
case
[>
case
]]
;
auto
.
+
contradict
notinX
;
rewrite
eqXY
;
apply
belowinY
;
omega
.
+
contradict
notinX
;
rewrite
eqXY
;
apply
belowinY
;
omega
.
+
contradict
notinY
;
rewrite
<
eqXY
;
apply
belowinX
;
omega
.
+
contradict
notinY
;
rewrite
<
eqXY
;
apply
belowinX
;
omega
.

intro
.

intro
.
unfold
fresh
,
fresh_generic
.
unfold
fresh
,
fresh_generic
.
destruct
(
fresh_generic_fixpoint_spec
X
0
)
as
[
m
[
_
[>
[
notinX
belowinX
]]]]
;
auto
.
destruct
(
fresh_generic_fixpoint_spec
(
1
+
Nat
.
log2
(
size
X
))
X
0
)
as
[
m
[
_
[>
[
notinX
belowinX
]]]]
;
auto
.
Qed
.
Qed
.
End
Fresh
.
End
Fresh
.
(** Derive fresh instances. *)
(** Derive fresh instances. *)
Section
StringFresh
.
Section
StringFresh
.
Context
`
{
FinCollection
string
C
,
∀
(
x
:
string
)
(
s
:
C
),
Decision
(
x
∈
s
)
}.
Context
`
{
FinCollection
string
C
,
!
RelDecision
elem_of
}.
Global
Instance
string_fresh
:
Fresh
string
C
:
=
fresh_generic
.
Global
Instance
string_fresh
:
Fresh
string
C
:
=
fresh_generic
.
Global
Instance
string_fresh_spec
:
FreshSpec
string
C
:
=
_
.
Global
Instance
string_fresh_spec
:
FreshSpec
string
C
:
=
fresh_generic_spec
.
End
StringFresh
.
End
StringFresh
.
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