Skip to content

Commit 5aebd06

Browse files
committed
update sat docs
1 parent 1bf342e commit 5aebd06

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

docs/src/ref.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Matching
99
Coloring
1010
MaxCut
1111
PaintShop
12+
Satisfiability
1213
```
1314

1415
```@docs

examples/Coloring.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ show_graph(graph; locs=locations)
2929
# For a vertex ``v``, we define the degree of freedoms ``c_v\in\{1,2,3\}`` and a vertex tensor labelled by it as
3030
# ```math
3131
# W(v) = \left(\begin{matrix}
32-
# r_v\\
33-
# g_v\\
34-
# b_v
32+
# 1\\
33+
# 1\\
34+
# 1
3535
# \end{matrix}\right).
3636
# ```
3737
# For an edge ``(u, v)``, we define an edge tensor as a matrix labelled by ``(c_u, c_v)`` to specify the constraint
3838
# ```math
3939
# B = \left(\begin{matrix}
40-
# 0 & 1 & 1\\
41-
# 1 & 0 & 1\\
42-
# 1 & 1 & 0
40+
# 1 & x & x\\
41+
# x & 1 & x\\
42+
# x & x & 1
4343
# \end{matrix}\right).
4444
# ```
4545
# The number of possible colouring can be obtained by contracting this tensor network by setting vertex tensor elements ``r_v, g_v`` and ``b_v`` to 1.

examples/Satisfiability.jl

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,37 @@ assignment = Dict([:a=>true, :b=>false, :c=>false, :d=>true, :e=>false, :f=>fals
2424

2525
satisfiable(cnf, assignment)
2626

27-
# We can contruct a [`Satisfiability`](@ref) problem to solve the above problem more cleverly.
27+
# ## Tensor network representation
28+
# We can contruct a [`Satisfiability`](@ref) problem to solve the above problem.
29+
# To generate a tensor network, we map a boolean variable ``x`` and its negation ``\neg x`` to a degree of freedom (label) ``s_x \in \{0, 1\}``,
30+
# where 0 stands for variable ``x`` having value `false` while 1 stands for having value `true`.
31+
# Then we map a clause to a tensor. For example, a clause ``¬x ∨ y ∨ ¬z`` can be mapped to a tensor labeled by ``(s_x, s_y, s_z)``.
32+
# ```math
33+
# C = \left(\begin{matrix}
34+
# \left(\begin{matrix}
35+
# x & x \\
36+
# x & x
37+
# \end{matrix}\right) \\
38+
# \left(\begin{matrix}
39+
# x & x \\
40+
# 1 & x
41+
# \end{matrix}\right)
42+
# \end{matrix}\right).
43+
# ```
44+
# There is only one entry ``(s_x, s_y, s_z) = (1, 0, 1)`` that makes this clause unsatisfied.
45+
# If we contract this tensor network, we will get a multiplicative factor ``x`` whenever there is a clause satisfied.
2846

2947
problem = Satisfiability(cnf);
3048

31-
# ## Satisfiability and its counting
49+
# ## Solving properties
50+
# #### Satisfiability and its counting
3251
# The size of a satisfiability problem is defined by the number of satisfiable clauses.
3352
num_satisfiable = solve(problem, SizeMax())[]
3453

3554
# The [`GraphPolynomial`](@ref) of a satisfiability problem counts the number of solutions that `k` clauses satisfied.
3655
num_satisfiable_count = solve(problem, GraphPolynomial())[]
3756

38-
# ## Find one of the solutions
57+
# #### Find one of the solutions
3958
single_config = solve(problem, SingleConfigMax())[].c.data
4059

4160
# One will see a bit vector printed.

0 commit comments

Comments
 (0)