File: dimacs_to_smt.pl

package info (click to toggle)
cvc4 1.8-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 69,876 kB
  • sloc: cpp: 274,686; sh: 5,833; python: 1,893; java: 929; lisp: 763; ansic: 275; perl: 214; makefile: 22; awk: 2
file content (37 lines) | stat: -rwxr-xr-x 749 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl -w
# DIMACS to SMT
# Morgan Deters
# Copyright (c) 2009, 2010, 2011  The CVC4 Project

use strict;

my ($nvars, $nclauses);
while(<>) {
    next if /^c/;

    if(/^p cnf (\d+) (\d+)/) {
        ($nvars, $nclauses) = ($1, $2);
        print "(benchmark b\n";
        print ":status unknown\n";
        print ":logic QF_UF\n";
        for(my $i = 1; $i <= $nvars; ++$i) {
            print ":extrapreds ((x$i))\n";
        }
        print ":formula (and\n";
        next;
    }

    print "(or";
    chomp;
    @_ = split(/ /);
    for(my $i = 0; $i < $#_; ++$i) {
        if($_[$i] < 0) {
            print " (not x" . -$_[$i] . ")";
        } else {
            print " x" . $_[$i];
        }
    }
    print ")\n";
}

print "))\n";