Skip to content

Commit fa3689f

Browse files
committed
Updated header settings, moved files to folder, added samples
1 parent 34e2034 commit fa3689f

File tree

9 files changed

+19848
-59
lines changed

9 files changed

+19848
-59
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
*.c
21
.idea
32
__pycache__

README.md

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
# CHC2C Converter
22

3-
This project is a Python-based tool that converts Constrained Horn Clauses (CHC) in SMT-LIB format into C code for verification.
4-
The CHC2C tool is designed to handle both linear and non-linear CHC problems, producing equivalent C code which can then be used in verification processes.
3+
This project is a Python-based tool that converts Constrained Horn Clauses (CHC) in SMT-LIB format into C code for
4+
verification.
5+
The CHC2C tool is designed to handle both linear and non-linear CHC problems, producing equivalent C code which can then
6+
be used in verification processes.
57

68
## Features
9+
710
- Converts CHC files (in SMT-LIB format) into C code.
811
- Supports both linear and non-linear CHC transformations.
912
- Automatically retries with a recursive mapping if necessary.
1013
- Command-line interface for specifying input and output files.
1114

1215
## Prerequisites
16+
1317
- Python 3.12
1418
- [z3-solver](https://pypi.org/project/z3-solver/)
1519

20+
For exact versions, see [requirements.txt](requirements.txt).
21+
22+
Run `pip install -r requirements.txt` to install all python dependencies.
23+
1624
## Installation
25+
1726
Clone the repository and navigate to the directory:
27+
1828
```bash
1929
git clone https://github.com/your-repo/CHC2C.git
2030
cd CHC2C
2131
```
2232

2333
## Usage
34+
2435
To use the tool, run the script with a CHC file as input. The following arguments are supported:
2536

2637
```bash
@@ -31,22 +42,25 @@ To use the tool, run the script with a CHC file as input. The following argument
3142
- `-o`, `--out`: (Optional) Specifies the name of the output C file. Defaults to `chc.c`.
3243
- `--recursive`: (Optional) Enables recursive conversion for non-linear CHC problems.
3344

34-
If the tool encounters a recursive CHC problem while using the linear conversion, it will automatically retry using a recursive mapping.
45+
If the tool encounters a recursive CHC problem while using the linear conversion, it will automatically retry using a
46+
recursive mapping.
3547

3648
### Example
49+
3750
```bash
3851
./chc2c.py example.chc -o output.c
3952
```
4053

4154
This command converts the `example.chc` file to C code and writes the output to `output.c`.
4255

4356
## Further Information
57+
4458
For more information on the CHC format, visit [CHC Competition Documentation](https://chc-comp.github.io/format.html).
4559

4660
## Contributors
4761

48-
* [Levente Bajczi](https://github.com/leventebajczi/)
49-
* [Mihály Dobos-Kovács](https://github.com/as3810t/)
62+
* [Levente Bajczi](https://github.com/leventebajczi/)
63+
* [Mihály Dobos-Kovács](https://github.com/as3810t/)
5064

5165
## Publications
5266

chc2c.py

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
#!/usr/bin/python3
22

3-
4-
# Copyright 2025 Budapest University of Technology and Economics
5-
#
6-
# Licensed under the Apache License, Version 2.0 (the "License");
7-
# you may not use this file except in compliance with the License.
8-
# You may obtain a copy of the License at
3+
# Copyright 2025 Budapest University of Technology and Economics
94
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
118
#
12-
# Unless required by applicable law or agreed to in writing, software
13-
# distributed under the License is distributed on an "AS IS" BASIS,
14-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
# See the License for the specific language governing permissions and
16-
# limitations under the License.
9+
# http://www.apache.org/licenses/LICENSE-2.0
1710
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
1816

1917
import argparse
2018

21-
from LinearCHC2C import LinearCHC2C, RecursiveException
22-
from NonLinearCHC2C import NonLinearCHC2C
19+
from src.LinearCHC2C import LinearCHC2C, RecursiveException
20+
from src.NonLinearCHC2C import NonLinearCHC2C
2321

2422

2523
def main():

sample/linear.c

+15,759
Large diffs are not rendered by default.

sample/recursive.c

+4,032
Large diffs are not rendered by default.
File renamed without changes.

BaseCHC2C.py renamed to src/BaseCHC2C.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# Copyright 2025 Budapest University of Technology and Economics
1+
# Copyright 2025 Budapest University of Technology and Economics
22
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
66
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
7+
# http://www.apache.org/licenses/LICENSE-2.0
148
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
1514

16-
import z3
1715
import re
1816

17+
import z3
18+
1919

2020
# As long as the CHC is nonrecursive, this can be used
2121
class BaseCHC2C:

LinearCHC2C.py renamed to src/LinearCHC2C.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
# Copyright 2025 Budapest University of Technology and Economics
1+
# Copyright 2025 Budapest University of Technology and Economics
22
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
66
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
7+
# http://www.apache.org/licenses/LICENSE-2.0
148
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
1514

16-
import z3
1715
import textwrap
1816

19-
from BaseCHC2C import BaseCHC2C
17+
import z3
18+
19+
from src.BaseCHC2C import BaseCHC2C
2020

2121

2222
class RecursiveException(Exception):

NonLinearCHC2C.py renamed to src/NonLinearCHC2C.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,12 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#
15-
# Licensed under the Apache License, Version 2.0 (the "License");
16-
# you may not use this file except in compliance with the License.
17-
# You may obtain a copy of the License at
18-
#
19-
# http://www.apache.org/licenses/LICENSE-2.0
20-
#
21-
# Unless required by applicable law or agreed to in writing, software
22-
# distributed under the License is distributed on an "AS IS" BASIS,
23-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24-
# See the License for the specific language governing permissions and
25-
# limitations under the License.
26-
#
2714

2815
import textwrap
2916

3017
import z3
3118

32-
from BaseCHC2C import BaseCHC2C
19+
from src.BaseCHC2C import BaseCHC2C
3320

3421

3522
# This works for all CHCs, linear, nonlinear, recursive, etc.

0 commit comments

Comments
 (0)