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
20dc1def
Commit
20dc1def
authored
Nov 18, 2008
by
Adam Chlipala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Impredicative Impure example
parent
6c218a7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
8 deletions
+70
-8
Impure.v
src/Impure.v
+70
-8
No files found.
src/Impure.v
View file @
20dc1def
...
...
@@ -39,6 +39,76 @@ Infix "@" := App (left associativity, at level 72).
Notation
"\ x , e"
:=
(
Abs
(
fun
x
=>
e
))
(
at
level
73
)
.
Notation
"\ ? , e"
:=
(
Abs
(
fun
_
=>
e
))
(
at
level
73
)
.
Definition
Term
:=
forall
var
,
term
var
.
Definition
ident
:
Term
:=
fun
_
=>
\
x
,
#
x
.
Definition
unite
:
Term
:=
fun
_
=>
()
.
Definition
ident_self
:
Term
:=
fun
_
=>
ident
_
@
ident
_.
Definition
ident_unit
:
Term
:=
fun
_
=>
ident
_
@
unite
_.
Module
impredicative
.
Inductive
dynamic
:
Set
:=
|
Dyn
:
forall
(
dynTy
:
Type
)
,
dynTy
->
dynamic
.
Inductive
computation
(
T
:
Type
)
:
Set
:=
|
Return
:
T
->
computation
T
|
Bind
:
forall
(
T
'
:
Type
)
,
computation
T
'
->
(
T
'
->
computation
T
)
->
computation
T
|
Unpack
:
dynamic
->
computation
T
.
Inductive
eval
:
forall
T
,
computation
T
->
T
->
Prop
:=
|
EvalReturn
:
forall
T
(
v
:
T
)
,
eval
(
Return
v
)
v
|
EvalUnpack
:
forall
T
(
v
:
T
)
,
eval
(
Unpack
T
(
Dyn
v
))
v
|
EvalBind
:
forall
T1
T2
(
c1
:
computation
T1
)
(
c2
:
T1
->
computation
T2
)
v1
v2
,
eval
c1
v1
->
eval
(
c2
v1
)
v2
->
eval
(
Bind
c1
c2
)
v2
.
Fixpoint
termDenote
(
e
:
term
dynamic
)
:
computation
dynamic
:=
match
e
with
|
Var
v
=>
Return
v
|
App
e1
e2
=>
Bind
(
termDenote
e1
)
(
fun
f
=>
Bind
(
termDenote
e2
)
(
fun
x
=>
Bind
(
Unpack
(
dynamic
->
computation
dynamic
)
f
)
(
fun
f
'
=>
f
'
x
)))
|
Abs
e
'
=>
Return
(
Dyn
(
fun
x
=>
termDenote
(
e
'
x
)))
|
Unit
=>
Return
(
Dyn
tt
)
end
.
Definition
TermDenote
(
E
:
Term
)
:=
termDenote
(
E
_
)
.
Eval
compute
in
TermDenote
ident
.
Eval
compute
in
TermDenote
unite
.
Eval
compute
in
TermDenote
ident_self
.
Eval
compute
in
TermDenote
ident_unit
.
Theorem
eval_ident_unit
:
eval
(
TermDenote
ident_unit
)
(
Dyn
tt
)
.
compute
.
repeat
econstructor
.
simpl
.
constructor
.
Qed
.
Theorem
invert_ident
:
forall
(
E
:
Term
)
d
,
eval
(
TermDenote
(
fun
_
=>
ident
_
@
E
_
))
d
->
eval
(
TermDenote
E
)
d
.
inversion
1.
crush
.
Focus
3.
crush
.
unfold
TermDenote
in
H0
.
simpl
in
H0
.
(
**
[
injection
H0
.
]
*
)
Abort
.
End
impredicative
.
Module
predicative
.
...
...
@@ -88,19 +158,11 @@ Module predicative.
|
Unit
=>
Return
VUnit
end
.
Definition
Term
:=
forall
var
,
term
var
.
Definition
TermDenote
(
E
:
Term
)
:=
termDenote
(
E
_
)
.
Definition
ident
:
Term
:=
fun
_
=>
\
x
,
#
x
.
Eval
compute
in
TermDenote
ident
.
Definition
unite
:
Term
:=
fun
_
=>
()
.
Eval
compute
in
TermDenote
unite
.
Definition
ident_self
:
Term
:=
fun
_
=>
ident
_
@
ident
_.
Eval
compute
in
TermDenote
ident_self
.
Definition
ident_unit
:
Term
:=
fun
_
=>
ident
_
@
unite
_.
Eval
compute
in
TermDenote
ident_unit
.
Theorem
eval_ident_unit
:
exists
ds
,
eval
nil
(
TermDenote
ident_unit
)
ds
VUnit
.
...
...
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