Ejemplo n.º 1
0
if __name__ == '__main__':
    error = True
    acquired = 0

    vals = dict()
    q = mp.Queue()

    smtdata = smtlib2_string_from_file(
        'assert', sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "1")

    sema = mp.BoundedSemaphore(3)
    jobs = [('str', mp.Process(target=runZ3Str2, args=(sema, smtdata, q))),
            ('z3', mp.Process(target=runZ3, args=(sema, smtdata, q))),
            ('cvc4',
             mp.Process(target=runCVC4,
                        args=(sema, z3str_to_cvc4(smtdata), q)))]
    [j.start() for (p, j) in jobs]
    sleep(epsilon)

    final_result = ''
    try:
        # If we still have error, and have other verifiers running
        while error and acquired < len(jobs):
            acquired += 1
            sema_status = sema.acquire(timeout=timeout)
            if not sema_status:
                raise Exception

            while True:
                try:
                    item = q.get(False)
Ejemplo n.º 2
0
if __name__ == '__main__':
    error = True
    acquired = 0

    vals = dict()
    q = mp.Queue()

    smtdata = (smtlib2_string_from_file('define-fun goal () Bool',
                                        sys.argv[1], sys.argv[3] if len(sys.argv) > 3 else "1",
                                        sys.argv[2], sys.argv[4] if len(sys.argv) > 4 else "1")
               + "\n(assert (not goal))")

    sema = mp.BoundedSemaphore(3)
    jobs = [('str', mp.Process(target=runZ3Str2, args=(sema, smtdata, q))),
            ('z3', mp.Process(target=runZ3, args=(sema, smtdata, q))),
            ('cvc4', mp.Process(target=runCVC4, args=(sema, z3str_to_cvc4(smtdata), q)))]
    [j.start() for (p, j) in jobs]
    sleep(epsilon)

    final_result = ''
    try:
        # If we still have error, and have other verifiers running
        while error and acquired < len(jobs):
            acquired += 1
            sema_status = sema.acquire(timeout=timeout)
            if not sema_status:
                raise Exception

            while True:
                try:
                    item = q.get(False)
Ejemplo n.º 3
0
#!/usr/bin/env python

import subprocess
import sys

from mcf2smtlib import z3str_to_cvc4, string_from_cvc4_model, smtlib2_string_from_file

if __name__ == '__main__':
    smtdata = z3str_to_cvc4(
        (smtlib2_string_from_file("define-fun goal () Bool", sys.argv[1],
                                  sys.argv[2] if len(sys.argv) > 2 else "1") +
         "\n(assert (not goal))"))

    cvc4_in = ('\n'.join([
        '(set-option :produce-models true)', '(set-option :strings-fmf true)',
        '(set-logic ALL_SUPPORTED)'
    ]) + smtdata + '\n(check-sat)\n')
    cvc4 = subprocess.Popen(
        ['cvc4', '--lang', 'smt', '--rewrite-divk', '--strings-exp'],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=sys.stderr)
    cvc4.stdin.write(cvc4_in)
    cvc4_res = cvc4.stdout.readline().strip()

    if cvc4_res == 'unsat':
        print("VALID")
    elif cvc4_res == 'sat' or cvc4_res == "valid":
        print(string_from_cvc4_model(cvc4))
    else:
        print("ERROR")
Ejemplo n.º 4
0
#!/usr/bin/python

import subprocess
import sys

from mcf2smtlib import z3str_to_cvc4, string_from_cvc4_model, smtlib2_string_from_file

if __name__ == '__main__':
    smtdata = z3str_to_cvc4(
        smtlib2_string_from_file('assert', sys.argv[1],
                                 sys.argv[2] if len(sys.argv) > 2 else "1"))

    cvc4_in = ('\n'.join([
        '(set-option :produce-models true)', '(set-option :strings-fmf true)',
        '(set-logic ALL_SUPPORTED)'
    ]) + smtdata + '\n(check-sat)\n')
    cvc4 = subprocess.Popen(
        ['cvc4', '--lang', 'smt', '--rewrite-divk', '--strings-exp'],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=sys.stderr)
    cvc4.stdin.write(cvc4_in)
    cvc4_res = cvc4.stdout.readline().strip()

    if cvc4_res == 'unsat':
        print("UNSAT")
    elif cvc4_res == 'sat' or cvc4_res == 'valid':
        print(string_from_cvc4_model(cvc4))
    else:
        print("ERROR")
Ejemplo n.º 5
0
let << ( pred
       | (LPAR + Suppress('let') + LPAR + LPAR + term + (expr | pred) + RPAR + RPAR + let + RPAR).setParseAction(let_action))

if __name__ == '__main__':
    with open(sys.argv[1]) as f:
        mcf = f.readlines()
    mcf = (mcf[0] if len(sys.argv) > 2 and sys.argv[2] == '0' else mcf[2]).strip()
    print(mcf)
    sys.exit(0)

    # ---------------------------------------------------------------
    # FIXME: No simplification for now. Weird __ufSS output from CVC4
    # FIXME: Replace CVC string functions with the new MCF format

    smtdata = z3str_to_cvc4(smtlib2_string_from_file("simplify", sys.argv[1], "1" if len(sys.argv) > 2 and sys.argv[2] == "0" else "0"))

    cvc4_in = ('\n'.join([
                 '(set-option :produce-models true)',
                 '(set-option :strings-fmf true)',
                 '(set-logic ALL_SUPPORTED)'])
               + smtdata + '\n')
    cvc4 = subprocess.Popen(['cvc4', '--lang', 'smt', '--rewrite-divk', '--strings-exp'],
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE,
                            stderr=sys.stderr)
    cvc4.stdin.write(cvc4_in)
    cvc4_res = cvc4.stdout.readline().strip()

    print(cvc4_in)
    print(cvc4_res)
Ejemplo n.º 6
0
#!/usr/bin/python

import subprocess
import sys

from mcf2smtlib import z3str_to_cvc4, string_from_cvc4_model, smtlib2_string_from_file

if __name__ == '__main__':
    smtdata = z3str_to_cvc4(smtlib2_string_from_file('assert', sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "1"))

    cvc4_in = ('\n'.join([
                 '(set-option :produce-models true)',
                 '(set-option :strings-fmf true)',
                 '(set-logic ALL_SUPPORTED)'])
               + smtdata
               + '\n(check-sat)\n')
    cvc4 = subprocess.Popen(['cvc4', '--lang', 'smt', '--rewrite-divk', '--strings-exp'],
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE,
                            stderr=sys.stderr)
    cvc4.stdin.write(cvc4_in)
    cvc4_res = cvc4.stdout.readline().strip()

    if cvc4_res == 'unsat':
        print("UNSAT")
    elif cvc4_res == 'sat' or cvc4_res == 'valid':
        print(string_from_cvc4_model(cvc4))
    else:
        print("ERROR")
Ejemplo n.º 7
0
         (expr | pred) + RPAR + RPAR + let + RPAR).setParseAction(let_action))

if __name__ == '__main__':
    with open(sys.argv[1]) as f:
        mcf = f.readlines()
    mcf = (mcf[0]
           if len(sys.argv) > 2 and sys.argv[2] == '0' else mcf[2]).strip()
    print(mcf)
    sys.exit(0)

    # ---------------------------------------------------------------
    # FIXME: No simplification for now. Weird __ufSS output from CVC4
    # FIXME: Replace CVC string functions with the new MCF format

    smtdata = z3str_to_cvc4(
        smtlib2_string_from_file(
            "simplify", sys.argv[1],
            "1" if len(sys.argv) > 2 and sys.argv[2] == "0" else "0"))

    cvc4_in = ('\n'.join([
        '(set-option :produce-models true)', '(set-option :strings-fmf true)',
        '(set-logic ALL_SUPPORTED)'
    ]) + smtdata + '\n')
    cvc4 = subprocess.Popen(
        ['cvc4', '--lang', 'smt', '--rewrite-divk', '--strings-exp'],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=sys.stderr)
    cvc4.stdin.write(cvc4_in)
    cvc4_res = cvc4.stdout.readline().strip()

    print(cvc4_in)