GitXplorerGitXplorer
f

boolform

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
84909e5bf1698c9d24db9b22068ff7be33d54177

export CNF type

ffrrad committed 6 years ago
Unverified
f9112974fb2c3c35d81ee8a3703ca49461744cf0

update docs

ffrrad committed 6 years ago
Unverified
25d3f2565216b47fa24a7628dc82cf793a85c1b3

update readme

ffrrad committed 6 years ago
Unverified
fda8b33f0ac234093f96e8620dad6a247b03e42f

rename

ffrrad committed 6 years ago
Unverified
afb69992c1838b71f0701ed474b3e275693fe228

add gini support

ffrrad committed 6 years ago
Unverified
78fd45bf0397d052593acc64e2269b1f78f6516d

remove parser

ffrrad committed 6 years ago

README

The README file for this repository.

The package bf (forked from crillab/gophersat/bf) allows for the specification of boolean formula and the translation of specified formulas into CNF.

The package smt lets the user specify constraints in a friendly form. There is also support for some higher-level theories built out of boolean variables.

There are also a helper packages bfgophersat, bfgini, bfgosat to take a formula created by bf and change it into problem instances for these solvers.

As a rule each of these helper packages has a Solve function if you are just interested in a solution, and a Export function that translates a given problem into a formula / solver instance which you can interact with in more interesting ways.

Solving a simple problem with all three solvers:

package bf

import (
	"fmt"

	"github.com/frrad/boolform/bf"
	"github.com/frrad/boolform/bfgini"
	"github.com/frrad/boolform/bfgophersat"
	"github.com/frrad/boolform/bfgosat"
)

func main() {
	x := bf.Var("x")
	y := bf.Var("y")
	z := bf.Var("z")
	f := bf.And(bf.And(x, y), bf.Not(z))

	fmt.Println(bfgophersat.Solve(f))
	fmt.Println(bfgosat.Solve(f))
	fmt.Println(bfgini.Solve(f))
}

Solving a bitvector problem with gosat:

package main

import (
	"fmt"

	solver "github.com/frrad/boolform/bfgosat"
	"github.com/frrad/boolform/smt"
)

func main() {
	prob := smt.NewProb()
	a := prob.NewBitVectConst([]bool{true, false, true, false})
	b := prob.NewBitVectConst([]bool{true, true, false, false})

	x := a.Or(b)
	y := a.And(b)
	prob.Solve(solver.Solve)

	fmt.Println(x.SolVal())
	fmt.Println(y.SolVal())
}