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
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Gregory Malecha
stdpp
Commits
af633db2
Commit
af633db2
authored
10 years ago
by
Robbert Krebbers
Browse files
Options
Downloads
Patches
Plain Diff
Small stream library.
parent
ab930b45
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/streams.v
+48
-0
48 additions, 0 deletions
theories/streams.v
with
48 additions
and
0 deletions
theories/streams.v
0 → 100644
+
48
−
0
View file @
af633db2
(* Copyright (c) 2012-2014, Robbert Krebbers. *)
(* This file is distributed under the terms of the BSD license. *)
Require
Export
tactics
.
CoInductive
stream
(
A
:
Type
)
:
Type
:=
scons
:
A
→
stream
A
→
stream
A
.
Arguments
scons
{_}
_
_
.
Delimit
Scope
stream_scope
with
stream
.
Bind
Scope
stream_scope
with
stream
.
Open
Scope
stream_scope
.
Infix
":.:"
:=
scons
(
at
level
60
,
right
associativity
)
:
stream_scope
.
Definition
shead
{
A
}
(
s
:
stream
A
)
:
A
:=
match
s
with
x
:.:
_
=>
x
end
.
Definition
stail
{
A
}
(
s
:
stream
A
)
:
stream
A
:=
match
s
with
_
:.:
s
=>
s
end
.
CoInductive
stream_equiv'
{
A
}
(
s1
s2
:
stream
A
)
:
Prop
:=
scons_equiv'
:
shead
s1
=
shead
s2
→
stream_equiv'
(
stail
s1
)
(
stail
s2
)
→
stream_equiv'
s1
s2
.
Instance
stream_equiv
{
A
}
:
Equiv
(
stream
A
)
:=
stream_equiv'
.
Reserved
Infix
"!.!"
(
at
level
20
)
.
Fixpoint
slookup
{
A
}
(
i
:
nat
)
(
s
:
stream
A
)
:
A
:=
match
i
with
O
=>
shead
s
|
S
i
=>
stail
s
!.!
i
end
where
"s !.! i"
:=
(
slookup
i
s
)
.
Section
stream_properties
.
Context
{
A
:
Type
}
.
Implicit
Types
x
y
:
A
.
Implicit
Types
s
t
:
stream
A
.
Lemma
scons_equiv
s1
s2
:
shead
s1
=
shead
s2
→
stail
s1
≡
stail
s2
→
s1
≡
s2
.
Proof
.
by
constructor
.
Qed
.
Global
Instance
equal_equivalence
:
Equivalence
(
@
equiv
(
stream
A
)
_)
.
Proof
.
split
.
*
now
cofix
;
intros
[??];
constructor
.
*
now
cofix
;
intros
??
[??];
constructor
.
*
cofix
;
intros
???
[??]
[??];
constructor
;
etransitivity
;
eauto
.
Qed
.
Global
Instance
scons_proper
x
:
Proper
((
≡
)
==>
(
≡
))
(
scons
x
)
.
Proof
.
by
constructor
.
Qed
.
Global
Instance
shead_proper
:
Proper
((
≡
)
==>
(
=
))
(
@
shead
A
)
.
Proof
.
by
intros
??
[??]
.
Qed
.
Global
Instance
stail_proper
:
Proper
((
≡
)
==>
(
≡
))
(
@
stail
A
)
.
Proof
.
by
intros
??
[??]
.
Qed
.
Global
Instance
slookup_proper
:
Proper
((
≡
)
==>
eq
)
(
@
slookup
A
i
)
.
Proof
.
by
induction
i
as
[|
i
IH
];
intros
s1
s2
Hs
;
simpl
;
rewrite
Hs
.
Qed
.
End
stream_properties
.
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