Giter Club home page Giter Club logo

qi-explorer's Introduction

QI Explorer

This script generates CSV/SVG/PNG/MIDI files to explore the quantifier instantiations of a Z3 trace, (hopefully) helping to identify matching loops. See below for an example.

  • The CSV file lists the quantifier and generation of each instantiation, in the same order as they appear in the Z3 trace.
  • The SVG and PNG images visualize the order in which the quantifiers are matched and instantiated. Each quantifier is associated with a column and time progresses downwords. Each match is a green square and each instantiation is a red square, whose color intensity represents the generation of the instantiation.
  • The MIDI file represents just the quantifier instantiations. Each quantifier is associated with a pitch and each instantiation generates a note whose volume increases with the generation of the instantiation.

Requirements

Python 3.6 or later.

Optionally, to generate the SVG/PNG/MIDI files:

pip install --user svgwrite==1.4.2 cairosvg==2.5.2 midiutil==1.2.1

Usage

usage: python script.py [-h] [-i INPUT] [--csv CSV] [--svg SVG] [--png PNG] [--midi MIDI]
                        [--max-instantiations MAX_INSTANTIATIONS]
                        [--skip-instantiations SKIP_INSTANTIATIONS] [--tempo TEMPO]

Explore quantifier instantiations.

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        path of the Z3 trace (default: read from stdin)
  --csv CSV             output path of the CSV file
  --svg SVG             output path of the SVG file
  --png PNG             output path of the PNG file
  --midi MIDI           output path of the MIDI file
  --max-instantiations MAX_INSTANTIATIONS
                        maximum number of quantifier instantiations to load (default: all)
  --skip-instantiations SKIP_INSTANTIATIONS
                        number of *loaded* quantifier instantiations to skip (default: 0)
  --tempo TEMPO         beats per minute (default: 480)

Example

Command:

python script.py \
    --input z3.log \
    --max-instantiations 5500 \
    --skip-instantiations 5000 \
    --csv example/example.csv \
    --svg example/example.svg \
    --midi example/example.mid

Output:

Loading trace file 'z3.log'...
Tool version: Z3 4.8.6
Only the first 5500 quantifier instantiations will be loaded.
Number of quantifiers: 222
Number of used quantifiers: 42
Number of unique matches: 1274
Number of quantifier instantiations: 5500
Creating CSV file at 'example/example.csv'...
CSV file created
Creating SVG image...
The first 5000 quantifier instantiations will be ignored.
SVG image created
Creating SVG file at 'example/example.svg'...
SVG file created
Creating MIDI file at 'example/example.mid'...
MIDI file created

Generated files: example.csv, example.svg, example.mid

Explanation of the generated image: Explanation of the generated image

How to generate the Z3 trace

To generate a z3.log file:

z3 trace=true smt.qi.profile=true smt.qi.profile_freq=10000 program.smt2

The smt.qi.profile=true smt.qi.profile_freq=10000 arguments make Z3 periodically report the number of quantifier instantiations, which is usefuly if you want to check the progress or kill Z3 when too many quantifiers have been instantiated.

References

qi-explorer's People

Contributors

fpoli avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.