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
697fed0c
Commit
697fed0c
authored
Aug 29, 2008
by
Adam Chlipala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start of Intro
parent
0f1efe21
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
202 additions
and
89 deletions
+202
-89
.hgignore
.hgignore
+2
-0
Makefile
book/Makefile
+12
-3
Intro.v
book/src/Intro.v
+109
-0
StackMachine.v
book/src/StackMachine.v
+79
-86
No files found.
.hgignore
View file @
697fed0c
...
@@ -11,3 +11,5 @@ syntax: glob
...
@@ -11,3 +11,5 @@ syntax: glob
*/cpdt.*
*/cpdt.*
*/*.log
*/*.log
book/html/coqdoc.css
book/html/*.html
book/Makefile
View file @
697fed0c
MODULES_NODOC
:=
Tactics
MODULES_NODOC
:=
Tactics
MODULES_DOC
:=
StackMachine
MODULES_DOC
:=
Intro
StackMachine
MODULES
:=
$(MODULES_NODOC)
$(MODULES_DOC)
MODULES
:=
$(MODULES_NODOC)
$(MODULES_DOC)
VS
:=
$
(
MODULES:%
=
src/%.v
)
VS
:=
$
(
MODULES:%
=
src/%.v
)
VS_DOC
:=
$
(
MODULES_DOC:%
=
%.v
)
VS_DOC
:=
$
(
MODULES_DOC:%
=
%.v
)
GLOBALS
:=
.coq_globals
GLOBALS
:=
.coq_globals
.PHONY
:
coq clean doc
.PHONY
:
coq clean doc
dvi html
coq
:
Makefile.coq
coq
:
Makefile.coq
make
-f
Makefile.coq
make
-f
Makefile.coq
...
@@ -21,11 +21,20 @@ clean:: Makefile.coq
...
@@ -21,11 +21,20 @@ clean:: Makefile.coq
rm
-f
Makefile.coq .depend
$(GLOBALS)
\
rm
-f
Makefile.coq .depend
$(GLOBALS)
\
latex/
*
.sty latex/cpdt.
*
latex/
*
.sty latex/cpdt.
*
doc
:
latex/cpdt.dvi
doc
:
latex/cpdt.dvi
html
latex/cpdt.tex
:
$(VS)
latex/cpdt.tex
:
$(VS)
cd
src
;
coqdoc
--latex
$(VS_DOC)
\
cd
src
;
coqdoc
--latex
$(VS_DOC)
\
-p
"
\u
sepackage{url}"
\
-o
../latex/cpdt.tex
-o
../latex/cpdt.tex
latex/cpdt.dvi
:
latex/cpdt.tex
latex/cpdt.dvi
:
latex/cpdt.tex
cd
latex
;
latex cpdt
cd
latex
;
latex cpdt
html
:
$(VS)
cd
src
;
coqdoc
$(VS_DOC)
\
--glob-from
../
$(GLOBALS)
\
-d
../html
dvi
:
xdvi latex/cpdt
book/src/Intro.v
0 → 100644
View file @
697fed0c
This diff is collapsed.
Click to expand it.
book/src/StackMachine.v
View file @
697fed0c
...
@@ -16,24 +16,21 @@ Require Import Tactics.
...
@@ -16,24 +16,21 @@ Require Import Tactics.
(
**
*
Arithmetic
expressions
over
natural
numbers
*
)
(
**
*
Arithmetic
expressions
over
natural
numbers
*
)
(
*
begin
hide
*
)
Module
Nat
.
(
*
end
hide
*
)
(
**
**
Source
language
*
)
(
**
**
Source
language
*
)
Inductive
binop
:
Set
:=
Plus
|
Times
.
Inductive
binop
:
Set
:=
Plus
|
Times
.
Inductive
exp
:
Set
:=
Inductive
exp
:
Set
:=
|
Const
:
nat
->
exp
|
Const
:
nat
->
exp
|
Binop
:
binop
->
exp
->
exp
->
exp
.
|
Binop
:
binop
->
exp
->
exp
->
exp
.
Definition
binopDenote
(
b
:
binop
)
:
nat
->
nat
->
nat
:=
Definition
binopDenote
(
b
:
binop
)
:
nat
->
nat
->
nat
:=
match
b
with
match
b
with
|
Plus
=>
plus
|
Plus
=>
plus
|
Times
=>
mult
|
Times
=>
mult
end
.
end
.
Fixpoint
expDenote
(
e
:
exp
)
:
nat
:=
Fixpoint
expDenote
(
e
:
exp
)
:
nat
:=
match
e
with
match
e
with
|
Const
n
=>
n
|
Const
n
=>
n
|
Binop
b
e1
e2
=>
(
binopDenote
b
)
(
expDenote
e1
)
(
expDenote
e2
)
|
Binop
b
e1
e2
=>
(
binopDenote
b
)
(
expDenote
e1
)
(
expDenote
e2
)
...
@@ -42,14 +39,14 @@ Module Nat.
...
@@ -42,14 +39,14 @@ Module Nat.
(
**
**
Target
language
*
)
(
**
**
Target
language
*
)
Inductive
instr
:
Set
:=
Inductive
instr
:
Set
:=
|
IConst
:
nat
->
instr
|
IConst
:
nat
->
instr
|
IBinop
:
binop
->
instr
.
|
IBinop
:
binop
->
instr
.
Definition
prog
:=
list
instr
.
Definition
prog
:=
list
instr
.
Definition
stack
:=
list
nat
.
Definition
stack
:=
list
nat
.
Definition
instrDenote
(
i
:
instr
)
(
s
:
stack
)
:
option
stack
:=
Definition
instrDenote
(
i
:
instr
)
(
s
:
stack
)
:
option
stack
:=
match
i
with
match
i
with
|
IConst
n
=>
Some
(
n
::
s
)
|
IConst
n
=>
Some
(
n
::
s
)
|
IBinop
b
=>
|
IBinop
b
=>
...
@@ -59,7 +56,7 @@ Module Nat.
...
@@ -59,7 +56,7 @@ Module Nat.
end
end
end
.
end
.
Fixpoint
progDenote
(
p
:
prog
)
(
s
:
stack
)
{
struct
p
}
:
option
stack
:=
Fixpoint
progDenote
(
p
:
prog
)
(
s
:
stack
)
{
struct
p
}
:
option
stack
:=
match
p
with
match
p
with
|
nil
=>
Some
s
|
nil
=>
Some
s
|
i
::
p
'
=>
|
i
::
p
'
=>
...
@@ -72,7 +69,7 @@ Module Nat.
...
@@ -72,7 +69,7 @@ Module Nat.
(
**
**
Translation
*
)
(
**
**
Translation
*
)
Fixpoint
compile
(
e
:
exp
)
:
prog
:=
Fixpoint
compile
(
e
:
exp
)
:
prog
:=
match
e
with
match
e
with
|
Const
n
=>
IConst
n
::
nil
|
Const
n
=>
IConst
n
::
nil
|
Binop
b
e1
e2
=>
compile
e2
++
compile
e1
++
IBinop
b
::
nil
|
Binop
b
e1
e2
=>
compile
e2
++
compile
e1
++
IBinop
b
::
nil
...
@@ -81,7 +78,7 @@ Module Nat.
...
@@ -81,7 +78,7 @@ Module Nat.
(
**
**
Translation
correctness
*
)
(
**
**
Translation
correctness
*
)
Lemma
compileCorrect
'
:
forall
e
s
p
,
progDenote
(
compile
e
++
p
)
s
=
Lemma
compileCorrect
'
:
forall
e
s
p
,
progDenote
(
compile
e
++
p
)
s
=
progDenote
p
(
expDenote
e
::
s
)
.
progDenote
p
(
expDenote
e
::
s
)
.
induction
e
.
induction
e
.
...
@@ -102,20 +99,16 @@ Module Nat.
...
@@ -102,20 +99,16 @@ Module Nat.
rewrite
IHe1
.
rewrite
IHe1
.
simpl
.
simpl
.
reflexivity
.
reflexivity
.
Abort
.
Abort
.
Lemma
compileCorrect
'
:
forall
e
s
p
,
progDenote
(
compile
e
++
p
)
s
=
Lemma
compileCorrect
'
:
forall
e
s
p
,
progDenote
(
compile
e
++
p
)
s
=
progDenote
p
(
expDenote
e
::
s
)
.
progDenote
p
(
expDenote
e
::
s
)
.
induction
e
;
crush
.
induction
e
;
crush
.
Qed
.
Qed
.
Theorem
compileCorrect
:
forall
e
,
progDenote
(
compile
e
)
nil
=
Some
(
expDenote
e
::
nil
)
.
Theorem
compileCorrect
:
forall
e
,
progDenote
(
compile
e
)
nil
=
Some
(
expDenote
e
::
nil
)
.
intro
.
intro
.
rewrite
(
app_nil_end
(
compile
e
))
.
rewrite
(
app_nil_end
(
compile
e
))
.
rewrite
compileCorrect
'
.
rewrite
compileCorrect
'
.
reflexivity
.
reflexivity
.
Qed
.
Qed
.
(
*
begin
hide
*
)
End
Nat
.
(
*
end
hide
*
)
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