-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
262 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
embed | ||
{{ coq | ||
Require Export Ascii. | ||
Require Export String. | ||
|
||
Hint Resolve ascii_dec : ott_coq_equality. | ||
}} | ||
metavar n ::= | ||
{{ lex numeral }} | ||
{{ coq nat }} | ||
{{ coq-equality }} | ||
{{ com number }} | ||
metavar x ::= | ||
{{ lex alphanum }} | ||
{{ coq string }} | ||
{{ coq-equality }} | ||
{{ com variable }} | ||
grammar | ||
e :: e_ ::= | ||
| x :: :: var {{ com variable }} | ||
| n :: :: num {{ com number }} | ||
| e + e' :: :: plus {{ com plus }} | ||
| e * e' :: :: times {{ com times }} | ||
| let x := e in e' :: :: def (+ bind x in e' +) | ||
{{ com let }} | ||
| e [ e' / x ] :: M :: subst | ||
{{ com substitution }} | ||
{{ coq (subst_e [[e']] [[x]] [[e]]) }} | ||
| ( e ) :: S :: parentheses | ||
{{ coq ([[e]]) }} | ||
|
||
terminals :: terminals_ ::= | ||
| -> :: :: red | ||
{{ tex \rightarrow }} | ||
| \||/ :: :: down | ||
{{ tex \Downarrow }} | ||
|
||
formula :: formula_ ::= | ||
{{ com formulas }} | ||
| judgement :: :: judgement | ||
| n + n' = n'' :: M :: num_plus_eq | ||
{{ coq ([[n]] + [[n']] = [[n'']]) }} | ||
| n * n' = n'' :: M :: num_times_eq | ||
{{ coq ([[n]] * [[n']] = [[n'']]) }} | ||
|
||
substitutions | ||
single e x :: subst | ||
|
||
%freevars | ||
% e x :: free | ||
|
||
defns | ||
operational_semantics :: os_ ::= | ||
|
||
defn | ||
e -> e' :: :: red :: red_ | ||
{{ com reduction step }} by | ||
|
||
n1 + n2 = n | ||
------------ :: plus | ||
n1 + n2 -> n | ||
|
||
e1 -> e'1 | ||
------------------- :: plus_l | ||
e1 + e2 -> e'1 + e2 | ||
|
||
e -> e' | ||
--------------- :: plus_r | ||
n + e -> n + e' | ||
|
||
n1 * n2 = n | ||
------------ :: times | ||
n1 * n2 -> n | ||
|
||
e1 -> e'1 | ||
------------------- :: times_l | ||
e1 * e2 -> e'1 * e2 | ||
|
||
e -> e' | ||
--------------- :: times_r | ||
n * e -> n * e' | ||
|
||
e1 -> e'1 | ||
--------------------------------------- :: let | ||
let x := e1 in e2 -> let x := e'1 in e2 | ||
|
||
-------------------------------- :: bind | ||
let x := n in e2 -> e2 [ n / x ] | ||
|
||
defn | ||
e \||/ n :: :: eval :: eval_ | ||
{{ com evaluates to }} by | ||
|
||
-------- :: num | ||
n \||/ n | ||
|
||
e1 \||/ n1 | ||
e2 \||/ n2 | ||
n1 + n2 = n | ||
-------------- :: plus | ||
e1 + e2 \||/ n | ||
|
||
e1 \||/ n1 | ||
e2 \||/ n2 | ||
n1 * n2 = n | ||
-------------- :: times | ||
e1 * e2 \||/ n | ||
|
||
e1 \||/ n1 | ||
e2 [ n1 / x ] \||/ n2 | ||
------------------------- :: let | ||
let x := e1 in e2 \||/ n2 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
% all | ||
metavar termvar, x, y ::= {{ com term variable }} | ||
{{ isa string}} {{ coq nat}} {{ hol string}} {{ coq-equality }} | ||
{{ ocaml int}} {{ lex alphanum}} {{ tex \mathit{[[termvar]]} }} | ||
|
||
grammar | ||
t :: 't_' ::= {{ com term }} | ||
| x :: :: Var {{ com variable}} | ||
| \ x . t :: :: Lam (+ bind x in t +) {{ com lambda }} | ||
| t t' :: :: App {{ com app }} | ||
| ( t ) :: S:: Paren {{ icho [[t]] }} | ||
| [ t / x ] t' :: M:: Tsub | ||
{{ icho (tsubst_t [[t]] [[x]] [[t']])}} | ||
|
||
v :: 'v_' ::= {{ com value }} | ||
| \ x . t :: :: Lam {{ com lambda }} | ||
|
||
terminals :: 'terminals_' ::= | ||
| \ :: :: lambda {{ tex \lambda }} | ||
| --> :: :: red {{ tex \longrightarrow }} | ||
| in :: :: in {{ tex \in }} | ||
| <> :: :: neq {{ tex \neq }} | ||
| =a :: :: eqa {{ tex \equiv_\alpha }} | ||
| =b :: :: eqb {{ tex \equiv_\beta }} | ||
| FV :: :: FV {{ tex \mathrm{FV} }} | ||
| notin :: :: notin {{ tex \notin }} | ||
|
||
formula :: formula_ ::= | ||
{{ com formulas }} | ||
| judgement :: :: judgement | ||
| x <> x' :: M :: var_neq | ||
| x notin FV(t) :: M :: notin_fv | ||
|
||
subrules | ||
v <:: t | ||
|
||
substitutions | ||
single t x :: tsubst | ||
|
||
defns | ||
Jop :: '' ::= | ||
|
||
defn | ||
t1 --> t2 :: ::reduce::'' {{ com $[[t1]]$ reduces to $[[t2]]$}} by | ||
|
||
|
||
-------------------------- :: ax_app | ||
(\x.t12) v2 --> [v2/x]t12 | ||
|
||
t1 --> t1' | ||
-------------- :: ctx_app_fun | ||
t1 t --> t1' t | ||
|
||
t1 --> t1' | ||
-------------- :: ctx_app_arg | ||
v t1 --> v t1' | ||
|
||
defn | ||
x in FV ( t ) :: :: fv ::'' {{ com free variable }} by | ||
|
||
---------- :: var | ||
x in FV(x) | ||
|
||
x in FV(t1) | ||
-------------- :: app_l | ||
x in FV(t1 t2) | ||
|
||
x in FV(t2) | ||
-------------- :: app_r | ||
x in FV(t1 t2) | ||
|
||
x in FV(t) | ||
x <> y | ||
------------- :: lam | ||
x in FV(\y.t) | ||
|
||
defn | ||
t =a t' :: :: aeq :: aeq_ {{ com alpha equivalence }} by | ||
|
||
------ :: id | ||
t =a t | ||
|
||
t =a t' | ||
------- :: sym | ||
t' =a t | ||
|
||
t =a t' | ||
t' =a t'' | ||
--------- :: trans | ||
t =a t'' | ||
|
||
t1 =a t1' | ||
t2 =a t2' | ||
---------------- :: app | ||
t1 t2 =a t1' t2' | ||
|
||
t =a t' | ||
------------- :: lam | ||
\x.t =a \x.t' | ||
|
||
x' notin FV(t) | ||
------------------- :: subst | ||
\x.t =a \x'.[x'/x]t | ||
|
||
defn | ||
t =b t' :: :: beq :: beq_ {{ com beta equivalence }} by | ||
|
||
------ :: id | ||
t =b t | ||
|
||
t =b t' | ||
------- :: sym | ||
t' =b t | ||
|
||
t =b t' | ||
t' =b t'' | ||
--------- :: trans | ||
t =b t'' | ||
|
||
t1 =b t1' | ||
t2 =b t2' | ||
--------- :: app | ||
t1 t2 =b t1' t2' | ||
|
||
t =b t' | ||
------------- :: lam | ||
\x.t =b \x.t' | ||
|
||
--------------------- :: subst | ||
(\x.t) t' =b [t'/x] t |
Binary file not shown.