Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luizzak/swift-z3
A Swift wrapper over Microsoft's Z3 Theorem Prover
https://github.com/luizzak/swift-z3
swift swift-wrapper z3 z3-smt-solver
Last synced: about 2 months ago
JSON representation
A Swift wrapper over Microsoft's Z3 Theorem Prover
- Host: GitHub
- URL: https://github.com/luizzak/swift-z3
- Owner: LuizZak
- License: mit
- Created: 2020-02-03T21:41:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-30T14:51:47.000Z (8 months ago)
- Last Synced: 2024-04-30T16:13:16.008Z (8 months ago)
- Topics: swift, swift-wrapper, z3, z3-smt-solver
- Language: C++
- Homepage: https://LuizZak.github.io/swift-z3/
- Size: 116 MB
- Stars: 10
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SwiftZ3
[![Swift](https://github.com/LuizZak/swift-z3/actions/workflows/swift.yml/badge.svg)](https://github.com/LuizZak/swift-z3/actions/workflows/swift.yml)
A Swift wrapper over Microsoft's [Z3 Theorem Prover](https://github.com/Z3Prover/z3)
The aim is to wrap the entire C API layer into Swift types, with many conveniences and type safety sprinkled on top.
Example:
```swift
let config = Z3Config()
config.setParameter(name: "model", value: "true")let context = Z3Context(configuration: config)
let left: Z3Float = context.makeConstant(name: "left")
let width: Z3Float = context.makeConstant(name: "width")
let right: Z3Float = context.makeConstant(name: "right")let lValue = left == 50.0
let wValue = width == 100.0let rightEq = right == left + width
let solver = context.makeSolver()
solver.assert([lValue, wValue, rightEq])
XCTAssertEqual(solver.check(), .satisfiable)if let model = solver.getModel() {
XCTAssertEqual(model.double(right), 150)
} else {
XCTFail("Failed to get expected model")
}
```Development is ongoing and the public API might change at any time without notice.
### Requirements
Swift 5.4, macOS 10.13+
### Installation
SwiftZ3 is available to Swift Package Manager:
```swift
dependencies: [
.package(url: "https://github.com/LuizZak/swift-z3.git", .branch("master"))
]
```Specific tagged versions of Z3 are available as branches instead of tags in this repository. This allows base Swift API updates on master to be merged into different release versions of Z3 without requiring rewriting tags:
```swift
dependencies: [
.package(url: "https://github.com/LuizZak/swift-z3.git", .branch("4.11.2")) // Pulls 4.11.2 branch, with latest 'z3-4.11.2' source code + any API updates from master
]
```