Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/airtoxin/cnf-builder
Conjuctive-Normal-Form builder
https://github.com/airtoxin/cnf-builder
Last synced: about 11 hours ago
JSON representation
Conjuctive-Normal-Form builder
- Host: GitHub
- URL: https://github.com/airtoxin/cnf-builder
- Owner: airtoxin
- Created: 2021-01-08T10:22:41.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T17:59:18.000Z (almost 2 years ago)
- Last Synced: 2024-04-13T08:13:18.443Z (7 months ago)
- Language: TypeScript
- Size: 786 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cnf-builder
Conjuctive-Normal-Form builder
## Usage
```typescript
import { CNFBuilder } from "cnf-builder";const builder = new CNFBuilder();
const Alice = builder.addVariable("Alice");
const Bob = builder.addVariable("Bob");builder.addComments("My first cnf.");
builder.addClause(CNFClause.and([Alice, Bob.not]));console.log(builder.build());
// c My first cnf.
// p cnf 2 2
// 1 0
// -2 0
```## Supported Clauses
### `CNFClause.alwaysTrue(): CNFClause`
Always true.
### `CNFClause.alwaysFalse(): CNFClause`
Always false.
### `CNFClause.and(vars: CNFVariable[]): CNFClause`
A ∧ B ∧ C ...
### `CNFClause.or(vars: CNFVariable[]): CNFClause`
A ∨ B ∨ C ...
### `CNFClause.not(vars: CNFVariable[]): CNFClause`
¬A ∧ ¬B ∧ ¬C ...
### `CNFClause.implies(p: CNFVariable, q: CNFVariable): CNFClause`
P ⇒ Q
### `CNFClause.equals(p: CNFVariable, q: CNFVariable): CNFClause`
P ⇔ Q
### `CNFClause.allEquals(vars: CNFVariable[]): CNFClause`
A ⇔ B ⇔ C ...
### `CNFClause.atMostOne(vars: CNFVariable[]): CNFClause`
There are at most one true variable.
### `CNFClause.atLeastOne(vars: CNFVariable[]): CNFClause`
There are at least one true variables.
### `CNFClause.exactlyOne(vars: CNFVariable[]): CNFClause`
There are exactly one true variable.