AI prompts
base on language-agnostic program reducer. ![CI](https://github.com/uw-pluverse/perses/actions/workflows/main.yml/badge.svg)
# Perses: Syntax-Directed Program Reduction
Perses is a language-agnostic program reducer to minimize a program with
respect to a set of constraints. It takes as input a program to reduce,
and a test script which specifies the constraints.
It outputs a minimized program which still satisfies the constraints specified
in the test script. Compared to Delta Debugging and Hierarchical Delta Debugging,
Perses leverages the syntax information in the Antlr grammar, and prunes the
search space by avoiding generating syntactically invalid programs.
### Supported Languages
Currently, Perses supports reduction for the following programming languages:
+ C: [c]
+ Cpp: [cc, cpp, cxx]
+ Rust: [rs]
+ Scala: [scala, sc]
+ Java: [java]
+ JavaScript: [javascript, js]
+ Python3: [py, py3]
+ GLSL: [glsl, comp, frag, vert]
+ Go: [go]
+ PHP: [php]
+ Ruby: [rb]
+ SQLite: [sqlite]
+ MySQL: [mysql]
+ Solidity: [sol]
+ System_Verilog: [v, sv]
+ SMTLIBv2: [smt2]
Support for other languages is coming soon.
### Obtain and Run
There are three ways to obtain Perses.
- Download a prebuilt release JAR file from our [release page](https://github.com/perses-project/perses/releases),
for example,
```
wget https://github.com/perses-project/perses/releases/download/v1.4/perses_deploy.jar
java -jar perses_deploy.jar [options]? --test-script <test-script.sh> --input-file <program file>
```
- Clone the repo and build Perses from the source.
```
git clone https://github.com/perses-project/perses.git
cd perses
bazel build //src/org/perses:perses_deploy.jar
java -jar bazel-bin/src/org/perses/perses_deploy.jar [options]? --test-script <test-script.sh> --input-file <program file>
```
- If you want to always use the trunk version of Perses, [perses-trunk](https://github.com/perses-project/perses/blob/master/scripts/perses-trunk) automatically downloads and builds the latest version.
NOTE: [Bazel](https://bazel.build/) is the prerequisite to run perses-trunk successfully.
` wget https://raw.githubusercontent.com/perses-project/perses/master/scripts/perses-trunk
chmod +x perses-trunk
./perses-trunk [options]? --test-script <test-script.sh> --input-file <program file>`
#### Important Flags
- --test-script **<test-script.sh>**:
The script encodes the constraints that both of the original program file and the reduced version should satisfy. It should return **0** if the constraints are satisfied.
- --input-file **<program-file>**: the program needs to be reduced. Currently, Perses
supports C, Rust, Java and Go. Note that we can easily support any other languages,
if the specific language can be parsed by an Antlr parser.
Check all available command line arguments
```
java -jar perses_deploy.jar --help
```
### License
GNU General Public License 3.
### References
This repository contains the implementations of the techniques proposed in the following papers.
#### 1. Perses: Syntax-Guided Program Reduction (ICSE 2018, [pdf](./doc/publication/2018_perses_icse.pdf))
```
@inproceedings{perses,
author = {Sun, Chengnian and Li, Yuanbo and Zhang, Qirun and Gu, Tianxiao and Su, Zhendong},
title = {Perses: Syntax-Guided Program Reduction},
year = {2018},
publisher = {Association for Computing Machinery},
doi = {10.1145/3180155.3180236},
booktitle = {Proceedings of the 40th International Conference on Software Engineering},
pages = {361–371},
}
```
##### 2. Pushing the Limit of 1-Minimality of Language-Agnostic Program Reduction (OOPSLA 2023, [pdf](./doc/publication/2023_vulcan_oopsla.pdf))
```
@article{vulcan,
title={Pushing the Limit of 1-Minimality of Language-Agnostic Program Reduction},
author={Xu, Zhenyang and Tian, Yongqiang and Zhang, Mengxiao and Zhao, Gaosen and Jiang, Yu and Sun, Chengnian},
journal={Proceedings of the ACM on Programming Languages},
volume={7},
number={OOPSLA1},
pages={636--664},
year={2023},
publisher={ACM New York, NY, USA}
}
```
##### 3. PPR: Pairwise Program Reduction (ESEC/FSE 2023, [pdf](./doc/publication/2023_ppr_fse.pdf))
```
@inproceedings{ppr,
title={PPR: Pairwise Program Reduction},
author={Zhang, Mengxiao and Xu, Zhenyang and Tian, Yongqiang and Jiang, Yu and Sun, Chengnian},
booktitle={Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering},
pages={338--349},
year={2023}
}
```
##### 4. On the Caching Schemes to Speed Up Program Reduction (TOSEM, [pdf](./doc/publication/2023_caching_tosem.pdf))
```
@article{perses-caching,
title={On the Caching Schemes to Speed Up Program Reduction},
author={Tian, Yongqiang and Zhang, Xueyan and Dong, Yiwen and Xu, Zhenyang and Zhang, Mengxiao and Jiang, Yu and Cheung, Shing-Chi and Sun, Chengnian},
journal={ACM Transactions on Software Engineering and Methodology},
volume={33},
number={1},
pages={1--30},
year={2023},
publisher={ACM New York, NY, USA}
}
```
", Assign "at most 3 tags" to the expected json: {"id":"6438","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"