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
8bc737f3
Commit
8bc737f3
authored
Nov 01, 2011
by
Adam Chlipala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak Generic templating
parent
6548d5b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
9 deletions
+1
-9
Generic.v
src/Generic.v
+1
-9
No files found.
src/Generic.v
View file @
8bc737f3
...
@@ -233,11 +233,8 @@ Eval cbv beta iota delta -[plus] in fun A => size (@tree_fix A).
...
@@ -233,11 +233,8 @@ Eval cbv beta iota delta -[plus] in fun A => size (@tree_fix A).
(
**
**
Pretty
-
Printing
*
)
(
**
**
Pretty
-
Printing
*
)
(
*
EX
:
Define
a
generic
pretty
-
printing
function
.
*
)
(
**
It
is
also
useful
to
do
generic
pretty
-
printing
of
datatype
values
,
rendering
them
as
human
-
readable
strings
.
To
do
so
,
we
will
need
a
bit
of
metadata
for
each
constructor
.
Specifically
,
we
need
the
name
to
print
for
the
constructor
and
the
function
to
use
to
render
its
non
-
recursive
arguments
.
Everything
else
can
be
done
generically
.
*
)
(
**
It
is
also
useful
to
do
generic
pretty
-
printing
of
datatype
values
,
rendering
them
as
human
-
readable
strings
.
To
do
so
,
we
will
need
a
bit
of
metadata
for
each
constructor
.
Specifically
,
we
need
the
name
to
print
for
the
constructor
and
the
function
to
use
to
render
its
non
-
recursive
arguments
.
Everything
else
can
be
done
generically
.
*
)
(
*
begin
thide
*
)
Record
print_constructor
(
c
:
constructor
)
:
Type
:=
PI
{
Record
print_constructor
(
c
:
constructor
)
:
Type
:=
PI
{
printName
:
string
;
printName
:
string
;
printNonrec
:
nonrecursive
c
->
string
printNonrec
:
nonrecursive
c
->
string
...
@@ -270,7 +267,6 @@ Definition print T dt (pr : print_datatype dt) (fx : fixDenote T dt) : T -> stri
...
@@ -270,7 +267,6 @@ Definition print T dt (pr : print_datatype dt) (fx : fixDenote T dt) : T -> stri
fx
string
(
hmap
(
B1
:=
print_constructor
)
(
B2
:=
constructorDenote
string
)
fx
string
(
hmap
(
B1
:=
print_constructor
)
(
B2
:=
constructorDenote
string
)
(
fun
_
pc
x
r
=>
printName
pc
++
"("
++
printNonrec
pc
x
(
fun
_
pc
x
r
=>
printName
pc
++
"("
++
printNonrec
pc
x
++
foldr
(
fun
s
acc
=>
", "
++
s
++
acc
)
")"
r
)
pr
)
.
++
foldr
(
fun
s
acc
=>
", "
++
s
++
acc
)
")"
r
)
pr
)
.
(
*
end
thide
*
)
(
**
Some
simple
tests
establish
that
[
print
]
gets
the
job
done
.
*
)
(
**
Some
simple
tests
establish
that
[
print
]
gets
the
job
done
.
*
)
...
@@ -369,16 +365,12 @@ Eval cbv beta iota delta -[append] in fun A (pr : A -> string) =>
...
@@ -369,16 +365,12 @@ Eval cbv beta iota delta -[append] in fun A (pr : A -> string) =>
(
**
**
Mapping
*
)
(
**
**
Mapping
*
)
(
*
EX
:
Define
a
generic
[
map
]
function
.
*
)
(
**
By
this
point
,
we
have
developed
enough
machinery
that
it
is
old
hat
to
define
a
generic
function
similar
to
the
list
[
map
]
function
.
*
)
(
**
By
this
point
,
we
have
developed
enough
machinery
that
it
is
old
hat
to
define
a
generic
function
similar
to
the
list
[
map
]
function
.
*
)
(
*
begin
thide
*
)
Definition
map
T
dt
(
dd
:
datatypeDenote
T
dt
)
(
fx
:
fixDenote
T
dt
)
(
f
:
T
->
T
)
Definition
map
T
dt
(
dd
:
datatypeDenote
T
dt
)
(
fx
:
fixDenote
T
dt
)
(
f
:
T
->
T
)
:
T
->
T
:=
:
T
->
T
:=
fx
T
(
hmap
(
B1
:=
constructorDenote
T
)
(
B2
:=
constructorDenote
T
)
fx
T
(
hmap
(
B1
:=
constructorDenote
T
)
(
B2
:=
constructorDenote
T
)
(
fun
_
c
x
r
=>
f
(
c
x
r
))
dd
)
.
(
fun
_
c
x
r
=>
f
(
c
x
r
))
dd
)
.
(
*
end
thide
*
)
Eval
compute
in
map
Empty_set_den
Empty_set_fix
.
Eval
compute
in
map
Empty_set_den
Empty_set_fix
.
(
**
%
\
vspace
{-
.15
in
}%
[[
(
**
%
\
vspace
{-
.15
in
}%
[[
...
@@ -470,7 +462,6 @@ Eval simpl in map_nat S 2.
...
@@ -470,7 +462,6 @@ Eval simpl in map_nat S 2.
(
**
We
would
like
to
be
able
to
prove
theorems
about
our
generic
functions
.
To
do
so
,
we
need
to
establish
additional
well
-
formedness
properties
that
must
hold
of
pieces
of
evidence
.
*
)
(
**
We
would
like
to
be
able
to
prove
theorems
about
our
generic
functions
.
To
do
so
,
we
need
to
establish
additional
well
-
formedness
properties
that
must
hold
of
pieces
of
evidence
.
*
)
(
*
begin
thide
*
)
Section
ok
.
Section
ok
.
Variable
T
:
Type
.
Variable
T
:
Type
.
Variable
dt
:
datatype
.
Variable
dt
:
datatype
.
...
@@ -504,6 +495,7 @@ End ok.
...
@@ -504,6 +495,7 @@ End ok.
(
**
We
are
now
ready
to
prove
that
the
[
size
]
function
we
defined
earlier
always
returns
positive
results
.
First
,
we
establish
a
simple
lemma
.
*
)
(
**
We
are
now
ready
to
prove
that
the
[
size
]
function
we
defined
earlier
always
returns
positive
results
.
First
,
we
establish
a
simple
lemma
.
*
)
(
*
begin
thide
*
)
Lemma
foldr_plus
:
forall
n
(
ils
:
ilist
nat
n
)
,
Lemma
foldr_plus
:
forall
n
(
ils
:
ilist
nat
n
)
,
foldr
plus
1
ils
>
0.
foldr
plus
1
ils
>
0.
induction
ils
;
crush
.
induction
ils
;
crush
.
...
...
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