Code Monkey home page Code Monkey logo

safetysynth's Introduction

SafetySynth

A symbolic safety game solver written in Swift. It follows the rules of the Reactive Synthesis Competition.

Awards

  • First and second place in sequential AIGER synthesis track (SYNTOMP 2017)
  • Second place in sequential AIGER realizability track (SYNTOMP 2017)
  • First and second place in sequential AIGER synthesis track (SYNTOMP 2016)
  • Third place in sequential AIGER realizability track (SYNTOMP 2016)

Installation

  • Requires Swift (version 3.1)
  • make release builds dependencies and the binary
  • .build/release/SafetySynth [--synthesize] instance.aag

How to Generate AIGER Synthesis Files

The synthesis specification file format is described in Extended AIGER Format for Synthesis. Instead of generating AIGER files directly, one can describe the game as a Verilog file and compile it down to AIGER using the yosys toolset.

Example

Consider the following example game, played on a 2-bit state space representing a binary counter. The input player can increase the counter, while the output player can reset the counter to zero once the value 2 is reached. The output player should avoid the value 3.

module counter(increase, controllable_reset, err);
  input increase;
  input controllable_reset; // inputs with prefix `controllable_` are to be synthesized
  output err;
  reg [1:0] state;

  assign err = (state == 3) ;  // single output is specification, should be always 0

  // encoding of transition function
  initial
  begin
    state = 0;
  end
  always @($global_clock)
  begin
    case(state)
        0 : if (!increase)
                state = 0;
            else
                state = 1;
        1 : if (!increase)
                state = 1;
            else
                state = 2;
        2 : if (!increase && !controllable_reset)
                state = 2;
            else if (increase && !controllable_reset)
                state = 3;
            else
                state = 0;
        3 : state = 3;
    endcase
  end
endmodule

This verilog file can be encoded in AIGER using the following yosys commands:

$ read_verilog counter.v 
$ synth -flatten -top counter
$ abc -g AND
$ write_aiger -ascii -symbols counter.aag

The resulting AIGER file can be directly solved using SafetySynth.

safetysynth's People

Contributors

ltentrup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

safetysynth's Issues

Synthesis with ABC

Hi,
when I ask only for (un)realizability of a circuit, the binary ./SafetySynth works well.
But when I ask also for synthesis it works only if called from the root directory of the project.
Did I make some mistakes during installation or do you have the same problem?

I think the problem is that it cannot resolve the path to the ABC tool.

Thanks.

Error with CAigerHelper

When trying to compile, I find this error:

SafetySynth/Sources/SafetyGameSolver/AigerHelper.swift:2:8: error: no such module 'CAigerHelper'
import CAigerHelper

Troubles during compilation

During the compilation of SafetySynth, I have the following issue when trying make test:

swift test
safetysynth: error: manifest parse error(s):
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/module.modulemap:1:8: error: redefinition of module 'AppleTextureEncoder'
module AppleTextureEncoder [system] [extern_c] {
       ^
/usr/local/include/module.modulemap:1:8: note: previously defined here
module AppleTextureEncoder [system] [extern_c] {
       ^

I tried it on macOS Catalina v. 10.15.6.
Most likely, the update to Catalina caused this issue.

Do you have any idea about a workaround?

Troubles with the makefile

Hi,
I think that the abc's repository on Mercurial is obsolete, and for that reason it didn't work.
They moved to "https://github.com/berkeley-abc/abc".
I changed the Makefile as follows:

.PHONY: default debug release test tools all clean distclean

default: debug

debug: tools
	swift build

release: tools
	swift build --configuration release -Xcc -O3 -Xcc -DNDEBUG -Xswiftc -Ounchecked

test:
	swift test

clean:
	swift package clean

distclean:
	swift package reset
	rm -rf Tools

tools: Tools/abc

Tools/.f:
	mkdir -p Tools
	touch Tools/.f

# abc
Tools/abc: Tools/abc-build
  mv abc build-abc; cp build-abc/abc .

Tools/abc-build: Tools/abc-git
	make -C Tools/abc

Tools/abc-git: Tools/.f
	cd Tools ; git clone https://github.com/berkeley-abc/abc

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.