Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lecopivo/lean4-karray
https://github.com/lecopivo/lean4-karray
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lecopivo/lean4-karray
- Owner: lecopivo
- License: apache-2.0
- Created: 2021-12-09T19:00:54.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-23T03:26:54.000Z (almost 3 years ago)
- Last Synced: 2024-07-18T15:29:50.573Z (4 months ago)
- Language: Lean
- Size: 313 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lean4-karray
A WIP package that allows automatic C code generation for functions defined in
Lean.## Usage
Setup `KArray` according to our [example](examples/KArrayExample). It will allow
you to use the `kcompile` tag in your functions.The `kcompile` tag needs to be used along with the `extern` tag. Example:
```lean
import KArrayinstance : Reflected Float := ⟨"double"⟩
@[kcompile, extern "c_my_fun"] def myFun (x : Float) := x
````KArray` will then generate a C file with a function called `c_my_fun`, using
`double` as the reflected type for Lean's `Float`.You can now run the `kcompile` script to generate the C file:
```bash
$ lake script run kcompile
```If you create other functions of change the ones tagged with `kcompile`, you
will need to run the script again.After the C file has been generated and your `lakefile.lean` has been configured,
you're good to call```bash
$ lake build
```Which will generate the executable file for your application.