Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
cpdt
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
research
cpdt
Commits
419e2d0e
Commit
419e2d0e
authored
Aug 29, 2012
by
Adam Chlipala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proofreading pass through Chapter 17
parent
19ce70ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
DataStruct.v
src/DataStruct.v
+14
-14
No files found.
src/DataStruct.v
View file @
419e2d0e
...
...
@@ -209,8 +209,8 @@ Section hlist.
Variable
elm
:
A
.
Inductive
member
:
list
A
->
Type
:=
|
M
First
:
forall
ls
,
member
(
elm
::
ls
)
|
M
Next
:
forall
x
ls
,
member
ls
->
member
(
x
::
ls
)
.
|
H
First
:
forall
ls
,
member
(
elm
::
ls
)
|
H
Next
:
forall
x
ls
,
member
ls
->
member
(
x
::
ls
)
.
(
**
Because
the
element
[
elm
]
that
we
are
"searching for"
in
a
list
does
not
change
across
the
constructors
of
[
member
]
,
we
simplify
our
definitions
by
making
[
elm
]
a
local
variable
.
In
the
definition
of
[
member
]
,
we
say
that
[
elm
]
is
found
in
any
list
that
begins
with
[
elm
]
,
and
,
if
removing
the
first
element
of
a
list
leaves
[
elm
]
present
,
then
[
elm
]
is
present
in
the
original
list
,
too
.
The
form
looks
much
like
a
predicate
for
list
membership
,
but
we
purposely
define
[
member
]
in
[
Type
]
so
that
we
may
decompose
its
values
to
guide
computations
.
...
...
@@ -223,8 +223,8 @@ Section hlist.
|
nil
=>
B
elm
|
_
::
_
=>
unit
end
)
with
|
M
First
_
=>
tt
|
M
Next
_
_
_
=>
tt
|
H
First
_
=>
tt
|
H
Next
_
_
_
=>
tt
end
|
HCons
_
_
x
mls
'
=>
fun
mem
=>
match
mem
in
member
ls
'
return
(
match
ls
'
with
...
...
@@ -233,8 +233,8 @@ Section hlist.
B
x
'
->
(
member
ls
''
->
B
elm
)
->
B
elm
end
)
with
|
M
First
_
=>
fun
x
_
=>
x
|
M
Next
_
_
mem
'
=>
fun
_
get_mls
'
=>
get_mls
'
mem
'
|
H
First
_
=>
fun
x
_
=>
x
|
H
Next
_
_
mem
'
=>
fun
_
get_mls
'
=>
get_mls
'
mem
'
end
x
(
hget
mls
'
)
end
.
(
*
end
thide
*
)
...
...
@@ -244,8 +244,8 @@ End hlist.
Implicit
Arguments
HNil
[
A
B
]
.
Implicit
Arguments
HCons
[
A
B
x
ls
]
.
Implicit
Arguments
M
First
[
A
elm
ls
]
.
Implicit
Arguments
M
Next
[
A
elm
x
ls
]
.
Implicit
Arguments
H
First
[
A
elm
ls
]
.
Implicit
Arguments
H
Next
[
A
elm
x
ls
]
.
(
*
end
thide
*
)
(
**
By
putting
the
parameters
[
A
]
and
[
B
]
in
[
Type
]
,
we
allow
some
very
higher
-
order
uses
.
For
instance
,
one
use
of
[
hlist
]
is
for
the
simple
heterogeneous
lists
that
we
referred
to
earlier
.
*
)
...
...
@@ -257,14 +257,14 @@ Definition someTypes : list Set := nat :: bool :: nil.
Example
someValues
:
hlist
(
fun
T
:
Set
=>
T
)
someTypes
:=
HCons
5
(
HCons
true
HNil
)
.
Eval
simpl
in
hget
someValues
M
First
.
Eval
simpl
in
hget
someValues
H
First
.
(
**
%
\
vspace
{-
.15
in
}%
[[
=
5
:
(
fun
T
:
Set
=>
T
)
nat
]]
*
)
Eval
simpl
in
hget
someValues
(
MNext
M
First
)
.
Eval
simpl
in
hget
someValues
(
HNext
H
First
)
.
(
**
%
\
vspace
{-
.15
in
}%
[[
=
true
:
(
fun
T
:
Set
=>
T
)
bool
...
...
@@ -334,7 +334,7 @@ Eval simpl in expDenote Const HNil.
]]
*
)
Eval
simpl
in
expDenote
(
Abs
(
dom
:=
Unit
)
(
Var
M
First
))
HNil
.
Eval
simpl
in
expDenote
(
Abs
(
dom
:=
Unit
)
(
Var
H
First
))
HNil
.
(
**
%
\
vspace
{-
.15
in
}%
[[
=
fun
x
:
unit
=>
x
:
typeDenote
(
Arrow
Unit
Unit
)
...
...
@@ -342,21 +342,21 @@ Eval simpl in expDenote (Abs (dom := Unit) (Var MFirst)) HNil.
*
)
Eval
simpl
in
expDenote
(
Abs
(
dom
:=
Unit
)
(
Abs
(
dom
:=
Unit
)
(
Var
(
MNext
M
First
))))
HNil
.
(
Abs
(
dom
:=
Unit
)
(
Var
(
HNext
H
First
))))
HNil
.
(
**
%
\
vspace
{-
.15
in
}%
[[
=
fun
x
_
:
unit
=>
x
:
typeDenote
(
Arrow
Unit
(
Arrow
Unit
Unit
))
]]
*
)
Eval
simpl
in
expDenote
(
Abs
(
dom
:=
Unit
)
(
Abs
(
dom
:=
Unit
)
(
Var
M
First
)))
HNil
.
Eval
simpl
in
expDenote
(
Abs
(
dom
:=
Unit
)
(
Abs
(
dom
:=
Unit
)
(
Var
H
First
)))
HNil
.
(
**
%
\
vspace
{-
.15
in
}%
[[
=
fun
_
x0
:
unit
=>
x0
:
typeDenote
(
Arrow
Unit
(
Arrow
Unit
Unit
))
]]
*
)
Eval
simpl
in
expDenote
(
App
(
Abs
(
Var
M
First
))
Const
)
HNil
.
Eval
simpl
in
expDenote
(
App
(
Abs
(
Var
H
First
))
Const
)
HNil
.
(
**
%
\
vspace
{-
.15
in
}%
[[
=
tt
:
typeDenote
Unit
...
...
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