Last active
January 7, 2020 15:13
-
-
Save yoshihiro503/7a4161917e01973a8c619edcd37ae1bd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
SCaml.v | |
ExtrSCaml.v | |
SCamlTest.v |
This file contains hidden or 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
Require Export ExtrOcamlBasic. | |
Require Import SCaml. | |
Extract Inlined Constant int => "SCaml.int". | |
Extract Inlined Constant operation => "Scaml.operation". | |
Extract Inlined Constant int_plus => "SCaml.(+)". | |
Extract Inlined Constant int_sub => "SCaml.(-)". |
This file contains hidden or 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
Parameter nat : Set. | |
Parameter int : Set. | |
Parameter int_plus : int -> int -> int. | |
Parameter int_sub : int -> int -> int. | |
Infix "+" := int_plus. | |
Infix "-" := int_sub. | |
Parameter operation : Set. |
This file contains hidden or 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
Require Import SCaml ExtrSCaml. | |
Inductive action : Set := | |
| Increment (i : int) | |
| Decrement (i : int). | |
Definition main action storage := | |
match action with | |
| Increment i => (nil : list operation, storage + i) | |
| Decrement i => (nil : list operation, storage - i) | |
end. | |
Extraction Language OCaml. | |
Extraction "test.ml" main. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A simple smart contract using Coq. This code compiled to smart contract VM language Michelson via SCaml.
The VM code obtained is here:
Requirement
How to build
coq_makefile -f _CoqProject -o Makefile make && rm test.mli scamlc test.ml