diff --git a/README.md b/README.md index d719795..182f21a 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Overall structure: ## Generating CNFs -The project includes scripts for generating the CNFs we formalized against. +The project includes scripts for generating the CNFs we formalized against. These must be run inside the `Lean` subfolder. #### Convex 6-gon For `n` points: @@ -66,7 +66,7 @@ The **tautology proof** is implied by checking that $F \land (\bigwedge_i \neg C As a first step, we will generate the main CNF by running: ``` cd Lean -lake exe encode hole 6 30 cube_checking/vars.out > cube_checking/6-30.cnf +lake exe encode hole 6 30 ../cube_checking/vars.out > ../cube_checking/6-30.cnf ``` Then, inside the `cube_checking` folder, the **tautology proof** can be verified by running `sh verify_tautology`, which boils down to: @@ -74,7 +74,7 @@ Then, inside the `cube_checking` folder, the **tautology proof** can be verified 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 taut_if_unsat.cnf tautology_proof.lrat --lrat +cadical taut_if_unsat.cnf tautology_proof.lrat --lrat # this should take around 30 seconds cake_lpr taut_if_unsat.cnf tautology_proof.lrat ``` Note that this requires: @@ -90,7 +90,7 @@ For the **UNSAT proof**, given the total amount of computation required to run a ``` ./cube_gen vars.out > .tmp_cube_ python3 cube_join.py -f 6-30.cnf -c .tmp_cube_ -o with_cube_.cnf -cadical with_cube_.cnf proof_cube_.lrat --lrat +cadical with_cube_.cnf proof_cube_.lrat --lrat # this should take a few seconds cake_lpr with_cube_.cnf proof_cube_.lrat ``` To simplify the process, we have added a bash script `solve_cube.sh`, which can be simply run as (for example, for cube number 42): @@ -98,8 +98,14 @@ To simplify the process, we have added a bash script `solve_cube.sh`, which can ``` sh solve_cube.sh 42 ``` +The cubes are indexed from 1 to 312418. - +To generate the formula + the totality of the cubes for incremental solving, run: +``` +./cube_gen 0 vars.out > cubes.icnf +python3 cube_join.py -f 6-30.cnf -c cubes.icnf --inccnf -o full_computation.icnf +cadical full_computation.icnf # this should take a while :P +``` ## Authors - [Bernardo Subercaseaux](https://bsubercaseaux.github.io/) (Carnegie Mellon University) diff --git a/cube_checking/cube_join.py b/cube_checking/cube_join.py index 1b3eb04..44b72e7 100644 --- a/cube_checking/cube_join.py +++ b/cube_checking/cube_join.py @@ -6,10 +6,11 @@ "-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("-o", "--output", required=False, type=str, help="Output file") +argparser.add_argument('--inccnf', action="store_true", help="Creates a .icnf file with the formula + cubes") args = argparser.parse_args() @@ -18,6 +19,7 @@ cube_file = args.cubes output_file = args.output tautcheck = args.tautcheck +icnf = args.inccnf encoding = modeler.Modeler() @@ -25,7 +27,6 @@ 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: @@ -66,10 +67,11 @@ def itokenize(line): 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) - \ No newline at end of file