Git Product home page Git Product logo

3-sat-certifier's Introduction

3-SAT Certifier (3 Satisfiability Problem)

A certifier algorithm for the NP-Complete 3-Satisfiability Problem

Problem Statement

Given a Conjunctive Normal Form formula, is there a satisfying truth assignment so that it evaluates to true?

  • Each clause must have the same number of literals (literals are X1, X2, X3, etc.)
    This is the 3-SAT problem so each clause has exactly 3 literals
    But the code is generic enough to work on ANY NUMBER OF LITERALS in a clause (given that each clause has the same number)
  • The literals in a clauses can have their value flipped using NOT, boolean negation
  • In each clause, literals (or their negation) are combined with compound boolean OR
  • All clauses are combined with compound boolean AND
  • The final result of the CNF is either 1 or 0 (true or false)
  • The 3-SAT problem asks if this result for all clauses is true

Certifier Algorithm

This 3-SAT problem is NP-Complete, this not a solution to the problem Instead, given a certificate of truth assignments, does the CNF evaluate to true?

Code Details

  • Literals must be "Xi" where i is an integer
  • Input for the CNF formula is a String with "AND" and "OR" spelled out
  • String parsing is case-INsensitive
  • Input for certificates a String array. Each one in the form:
    • (x1=1, x2=1, x3=0, x4=1)

Sample Certificates

The program parses the following strings to check if they're valid certificates to the CNF
(NOT x1 OR X2 OR x3) AND (x1 OR NOT x2 OR x3) AND (x1 OR x2 OR x4) AND (NOT x1 OR NOT x3 OR NOT x4)

  1. (x1=1, x2=1, x3=0, x4=1) valid
  2. (x1=1, x2=1, x3=1, x4=1) INVALID
  3. (x1=0, x2=0, x3=0, x4=1) valid
  4. (x1=0, x2=1, x3=0, x4=1) INVALID

3-sat-certifier's People

Contributors

sleekpanther avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

brendan7255

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.