File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import Valaig.External.Basic
22import Valaig.External.Ric3
3+ import Valaig.External.Abc
Original file line number Diff line number Diff line change 1+ import Valaig.External.Basic
2+
3+ namespace Valaig.External
4+
5+ def Abc.dsec (timeoutMs : Option Nat := none) : SafetyAigerMC :=
6+ {
7+ timeoutMs,
8+ supportsAag := false ,
9+ interpretOutput,
10+ safetyArgs,
11+ }
12+ where
13+ safetyArgs (problem : System.FilePath) : IO.Process.SpawnArgs :=
14+ let cmd := "abc"
15+ let cmdStr := s! "read { problem.toString} ; "
16+ let args := #["-c" , cmdStr]
17+ { cmd, args }
18+
19+ interpretOutput (out : IO.Process.Output) : EResult := do
20+ if out.stdout.contains "Networks are equivalent." then
21+ return Result.proof
22+ else
23+ return Result.counterexample
24+
25+ end Valaig.External
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ open Valaig.Aig
88
99structure ExternalMC where
1010 timeoutMs : Option Nat := none
11+ supportsAag : Bool := true
1112 interpretOutput (output : IO.Process.Output) : EResult
1213
1314structure SafetyAigerMC extends ExternalMC where
@@ -71,9 +72,15 @@ def checkSafety (config : SafetyAigerMC) (aig : Aiger) : IO EResult := do
7172 IO.FS.withTempDir fun dir => do
7273 -- Some solvers need the extension to be aag to work correctly so we create
7374 -- such a file rather than just using withTempFile
74- let path := dir / "model.aag"
75- IO.FS.withFile path .write fun handle => do
75+ let aagPath := dir / "model.aag"
76+ let aigPath := dir / "model.aig"
77+ IO.FS.withFile aagPath .write fun handle => do
7678 aig.writeAag <| IO.FS.Stream.ofHandle handle
79+
80+ if ¬config.supportsAag then
81+ let _ ← runProcess none { cmd := "aigtoaig" , args := #[aagPath.toString, aigPath.toString] }
82+
83+ let path := if config.supportsAag then aagPath else aigPath
7784 let out ← runProcess config.timeoutMs (config.safetyArgs path)
7885 return out >>= config.interpretOutput
7986
You can’t perform that action at this time.
0 commit comments