MCPcopy Index your code
hub / github.com/emina/kodkod

github.com/emina/kodkod @v2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.1 ↗ · + Follow
3,485 symbols 16,262 edges 264 files 2,643 documented · 76% updated 3y agov2.1 · 2015-09-20★ 86
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Kodkod

This repository includes the source code for the Kodkod solver for relational logic. Kodkod provides a clean Java API for constructing, manipulating, and solving relational constraints. The source code is extensively documented, and the repository includes many examples demonstrating the use of the Kodkod API.

Kodkod is open-source and available under the MIT license. However, the implementation relies on third-party SAT solvers (SAT4J, MiniSat, Glucose, and (P)Lingeling), some of which are released under stricter licenses. Please see the solver licenses for details.

Building and installing Kodkod

The following compilation and installation instructions have been tested on Linux (Fedora 22 with gcc 5.1.1) and on Mac OS X (10.10.5 with clang 6.0 and gcc 4.9). You may need to modify the build scripts for other operating systems.

Kodkod uses the Waf build system, which requires Python 2.5 or later. You will also need Java 8 and a C/C++ compiler, and your JAVA_HOME environment variable needs to point to the JDK 8 home directory.

  • Set the JAVA_HOME variable. For example, on OS X:

$ export JAVA_HOME=`/usr/libexec/java_home`

  • Clone the kodkod repository:

$ git clone https://github.com/emina/kodkod.git
$ cd kodkod

  • Download Waf 1.8.12 and make it executable:

$ wget --no-check-certificate https://waf.io/waf-1.8.12
$ chmod u+x waf-1.8.12
$ alias waf=$PWD/waf-1.8.12

  • Build the native libraries, kodkod.jar, and examples.jar and install them into the kodkod/lib directory:

$ waf configure --prefix=. --libdir=lib build install

Running Kodkod

Download (or build) the kodkod.jar binary, solver binaries, and the examples.jar binary. Assuming that the current working directory contains these binaries, run the Sudoku example as follows:

$ java -cp kodkod.jar:examples.jar -Djava.library.path=. kodkod.examples.sudoku.Sudoku

The program will produce a solution to a sample Sudoku puzzle:

p cnf 3452 7954
primary variables: 486
translation time: 176 ms
solving time: 2 ms
+-------+-------+-------+
| 6 4 7 | 2 1 3 | 9 5 8 | 
| 9 1 8 | 5 6 4 | 7 2 3 | 
| 2 5 3 | 8 7 9 | 4 6 1 | 
+-------+-------+-------+
| 1 9 5 | 6 4 7 | 8 3 2 | 
| 4 8 2 | 3 5 1 | 6 7 9 | 
| 7 3 6 | 9 2 8 | 1 4 5 | 
+-------+-------+-------+
| 5 7 4 | 1 9 2 | 3 8 6 | 
| 8 2 9 | 7 3 6 | 5 1 4 | 
| 3 6 1 | 4 8 5 | 2 9 7 | 
+-------+-------+-------+

Extension points exported contracts — how you extend this code

ReductionStrategy (Interface)
Strategy for reducing the unsatisfiable core of a SATProver. @specfield traces: ResolutionTrace[] @specfield nex [52 implementers]
src/kodkod/engine/satlab/ReductionStrategy.java
SATSolver (Interface)
Provides an interface to a SAT solver. @specfield variables: set [1..) @specfield clauses: set Clause @invariant all i: [6 …
src/kodkod/engine/satlab/SATSolver.java
BooleanVisitor (Interface)
Visits kodkod.engine.bool.BooleanFormula boolean formulas. In addition to passing themselves as the argument to [18 implementers]
src/kodkod/engine/bool/BooleanVisitor.java
RecordFilter (Interface)
A filter for TranslationRecords, based on the value of a record's node and literal fields. [41 implementers]
src/kodkod/engine/fol2sat/RecordFilter.java
ReturnVisitor (Interface)
A visitor that visits every node in the AST, returning some value for each. The methods that visit an {@link kodkod.ast. [18 …
src/kodkod/ast/visitor/ReturnVisitor.java

Core symbols most depended-on inside this repo

join
called by 1180
src/kodkod/ast/Expression.java
tuple
called by 997
src/kodkod/instance/TupleFactory.java
and
called by 791
src/kodkod/ast/Decls.java
oneOf
called by 690
src/kodkod/ast/Variable.java
unary
called by 518
src/kodkod/ast/Variable.java
bound
called by 483
src/kodkod/instance/Bounds.java
add
called by 466
src/kodkod/util/ints/IntSet.java
forAll
called by 392
src/kodkod/ast/Formula.java

Shape

Method 3,116
Class 311
Function 25
Interface 18
Enum 15

Languages

Java99%
C++1%
C1%

Modules by API surface

src/kodkod/util/ints/Ints.java91 symbols
src/kodkod/util/ints/RangeSequence.java52 symbols
src/kodkod/engine/satlab/LazyTrace.java50 symbols
test/kodkod/test/unit/RegressionTests.java48 symbols
test/kodkod/test/unit/UCoreTest.java42 symbols
src/kodkod/engine/satlab/SAT4J.java42 symbols
test/kodkod/test/sys/ExamplesTest.java41 symbols
src/kodkod/util/ints/TreeSequence.java37 symbols
src/kodkod/engine/bool/BooleanMatrix.java37 symbols
examples/kodkod/examples/tptp/SET967.java36 symbols
src/kodkod/engine/bool/Dimensions.java35 symbols
src/kodkod/util/ints/IntBitSet.java34 symbols

For agents

$ claude mcp add kodkod \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact