-
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.
Merge pull request #7 from bsubercaseaux/cube_check
Scripts and README for verification
- Loading branch information
Showing
13 changed files
with
197 additions
and
360 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
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
File renamed without changes.
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,77 @@ | ||
from eznf import modeler | ||
import argparse | ||
|
||
argparser = argparse.ArgumentParser() | ||
argparser.add_argument( | ||
"-f", "--formula", required=True, type=str, help="CNF Formula file" | ||
) | ||
argparser.add_argument("-c", "--cubes", required=True, type=str, help="Cube file") | ||
argparser.add_argument("-o", "--output", required=False, type=str, help="Output file") | ||
argparser.add_argument( | ||
"--tautcheck", action="store_true", help="Checks for a tautology" | ||
) | ||
argparser.add_argument('--inccnf', action="store_true", help="Creates a .icnf file with the formula + cubes") | ||
|
||
|
||
args = argparser.parse_args() | ||
|
||
formula_file = args.formula | ||
cube_file = args.cubes | ||
output_file = args.output | ||
tautcheck = args.tautcheck | ||
icnf = args.inccnf | ||
|
||
encoding = modeler.Modeler() | ||
|
||
def itokenize(line): | ||
""" | ||
takes a line as a string, coming from either a `p cnf` or a `p inccnf` file | ||
returns array of ints without 0 | ||
ignores lines starting with c or p | ||
""" | ||
if len(line) == 0: | ||
return [] | ||
if line[0] == "c" or line[0] == "p": | ||
return [] | ||
if line[:-1] == "\n": | ||
line = line[:-1] | ||
tokens = line.split(" ") | ||
ans = [] | ||
for t in tokens: | ||
try: | ||
t = int(t) | ||
if t != 0: | ||
ans.append(t) | ||
except ValueError: | ||
continue | ||
return ans | ||
|
||
|
||
with open(formula_file, 'r', encoding='utf-8') as sb_file: | ||
for line in sb_file.readlines(): | ||
tkns = itokenize(line) | ||
if len(tkns) > 0: | ||
encoding.add_clause(tkns) | ||
|
||
|
||
cubes = [] | ||
with open(cube_file, 'r', encoding='utf-8') as cb_file: | ||
for line in cb_file.readlines(): | ||
tkns = itokenize(line) | ||
if len(tkns) == 0: | ||
continue | ||
if tautcheck: | ||
encoding.add_clause([-t for t in tkns]) | ||
else: | ||
cubes.append(tkns) | ||
|
||
if tautcheck: | ||
encoding.serialize(output_file) | ||
elif icnf: | ||
encoding.cube_and_conquer(lambda: cubes, output_file) | ||
else: | ||
assert len(cubes) == 1 | ||
cube = cubes[0] | ||
for lit in cube: | ||
encoding.add_clause([lit]) | ||
encoding.serialize(output_file) |
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,9 @@ | ||
#!/bin/sh | ||
# Receives the desired cube number as $1 | ||
gcc 6hole-cube.c -o cube_gen | ||
./cube_gen $1 vars.out > .tmp_cube_$1 | ||
python3 cube_join.py -f 6-30.cnf -c .tmp_cube_$1 -o with_cube_$1.cnf | ||
${CADICAL:-cadical} with_cube_$1.cnf proof_cube_$1.lrat --lrat | ||
${CAKELPR:-cake_lpr} with_cube_$1.cnf proof_cube_$1.lrat | ||
|
||
rm with_cube_$1.cnf proof_cube_$1.lrat .tmp_cube_$1 |
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,7 @@ | ||
#!/bin/sh | ||
|
||
gcc 6hole-cube.c -o cube_gen | ||
./cube_gen 0 vars.out > cubes.icnf | ||
python3 cube_join.py -f 6-30.cnf -c cubes.icnf --tautcheck -o taut_if_unsat.cnf | ||
${CADICAL:-cadical} taut_if_unsat.cnf tautology_proof.lrat --lrat | ||
${CAKELPR:-cake_lpr} taut_if_unsat.cnf tautology_proof.lrat |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.