Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LogIA
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aalbert
LogIA
Merge requests
!8
Resolve "add horn sat algorithm"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "add horn sat algorithm"
5-add-horn-sat-algorithm
into
main
Overview
0
Commits
40
Pipelines
0
Changes
10
Merged
aalbert
requested to merge
5-add-horn-sat-algorithm
into
main
2 years ago
Overview
0
Commits
40
Pipelines
0
Changes
6
Expand
Closes
#5 (closed)
Closes
#4 (closed)
Edited
2 years ago
by
aalbert
👍
0
👎
0
Merge request reports
Compare
version 11
version 38
96deb648
2 years ago
version 37
472e21b6
2 years ago
version 36
673bbf6b
2 years ago
version 35
c078d9e0
2 years ago
version 34
6c431a7b
2 years ago
version 33
0e14aed4
2 years ago
version 32
d2000951
2 years ago
version 31
766c4f2f
2 years ago
version 30
6157b49b
2 years ago
version 29
cb6ef692
2 years ago
version 28
8ed1bc88
2 years ago
version 27
c22328a9
2 years ago
version 26
479c9dba
2 years ago
version 25
99aa8643
2 years ago
version 24
3935205d
2 years ago
version 23
8c881c1e
2 years ago
version 22
202d76a8
2 years ago
version 21
5be3ee3b
2 years ago
version 20
327183c6
2 years ago
version 19
b4feb844
2 years ago
version 18
34bb7f41
2 years ago
version 17
b002740c
2 years ago
version 16
5e7b0346
2 years ago
version 15
c145ebe4
2 years ago
version 14
c8a8f288
2 years ago
version 13
7ada20a7
2 years ago
version 12
f84282bd
2 years ago
version 11
2d5f344f
2 years ago
version 10
96657974
2 years ago
version 9
b902af33
2 years ago
version 8
b84684c3
2 years ago
version 7
b286945f
2 years ago
version 6
37e6bd4b
2 years ago
version 5
9e3db17c
2 years ago
version 4
c2a6bd98
2 years ago
version 3
99a0c0ac
2 years ago
version 2
a43cb6e6
2 years ago
version 1
e19dcdef
2 years ago
main (base)
and
version 16
latest version
ad6e573f
40 commits,
2 years ago
version 38
96deb648
39 commits,
2 years ago
version 37
472e21b6
38 commits,
2 years ago
version 36
673bbf6b
37 commits,
2 years ago
version 35
c078d9e0
36 commits,
2 years ago
version 34
6c431a7b
35 commits,
2 years ago
version 33
0e14aed4
34 commits,
2 years ago
version 32
d2000951
33 commits,
2 years ago
version 31
766c4f2f
32 commits,
2 years ago
version 30
6157b49b
31 commits,
2 years ago
version 29
cb6ef692
30 commits,
2 years ago
version 28
8ed1bc88
29 commits,
2 years ago
version 27
c22328a9
28 commits,
2 years ago
version 26
479c9dba
27 commits,
2 years ago
version 25
99aa8643
26 commits,
2 years ago
version 24
3935205d
25 commits,
2 years ago
version 23
8c881c1e
24 commits,
2 years ago
version 22
202d76a8
23 commits,
2 years ago
version 21
5be3ee3b
22 commits,
2 years ago
version 20
327183c6
21 commits,
2 years ago
version 19
b4feb844
19 commits,
2 years ago
version 18
34bb7f41
18 commits,
2 years ago
version 17
b002740c
17 commits,
2 years ago
version 16
5e7b0346
16 commits,
2 years ago
version 15
c145ebe4
15 commits,
2 years ago
version 14
c8a8f288
14 commits,
2 years ago
version 13
7ada20a7
13 commits,
2 years ago
version 12
f84282bd
12 commits,
2 years ago
version 11
2d5f344f
11 commits,
2 years ago
version 10
96657974
10 commits,
2 years ago
version 9
b902af33
9 commits,
2 years ago
version 8
b84684c3
8 commits,
2 years ago
version 7
b286945f
7 commits,
2 years ago
version 6
37e6bd4b
6 commits,
2 years ago
version 5
9e3db17c
5 commits,
2 years ago
version 4
c2a6bd98
4 commits,
2 years ago
version 3
99a0c0ac
3 commits,
2 years ago
version 2
a43cb6e6
2 commits,
2 years ago
version 1
e19dcdef
1 commit,
2 years ago
Show latest version
6 files
+
70
−
56
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
project1/bin/horn.ml
+
141
−
1
Options
let
process
clauses
=
Ok
([
List
.
length
clauses
])
(*TODO*)
open
Printf
open
Dolmen
open
Lib
(** A data structure to store horn clauses efficiently: *)
(* Clauses are modeled by the number of disjoint false hypothesis and the conlusion *)
(* and for every variable p, the list of clause where the variable p appear is maintained *)
(* for example, p1 /\ p2 /\ p2 => p3 is modeled by the clause (2,p3) and the array [| [ref (2,p3)]; [ref (2,p3)]; [] |] *)
(* When the number of false hypothesis of a clause reach zero, the conclusion is propagated: *)
(* if a variable p is propagated, we can iter the corresponding list and decrease the number of false hypothesis for each clause where p appear *)
(* if false is propagated, UNSAT has been reached *)
(* if nothing can be propagated anymore, SAT has been reached *)
module
Term
:
Dolmen_dimacs
.
Term
with
type
location
=
Std
.
Loc
.
t
and
type
t
=
int
=
struct
type
location
=
Std
.
Loc
.
t
type
t
=
int
let
atom
?
loc
x
=
let
_
=
loc
in
x
end
type
stat
=
Clause
of
int
ref
*
int
option
|
Vars
of
stat
ref
list
array
ref
module
Statement
(
Term
:
Dolmen_dimacs
.
Term
with
type
t
=
int
)
:
Dolmen_dimacs
.
Statement
with
type
location
=
Std
.
Loc
.
t
and
type
term
=
Term
.
t
and
type
t
=
stat
=
struct
type
location
=
Std
.
Loc
.
t
type
term
=
int
type
t
=
stat
let
vars
=
ref
[
||
]
let
p_cnf
?
loc
nb_var
_
=
let
_
=
loc
in
vars
:=
Array
.
make
(
nb_var
+
1
)
[]
;
Vars
vars
let
clause
?
loc
l
=
let
_
=
loc
and
l
=
remove_duplicates
l
and
len
=
ref
0
and
var
=
ref
None
in
List
.
iter
(
fun
t
->
if
t
<
0
then
incr
len
else
var
:=
Some
t
)
l
;
let
clause
=
Clause
(
len
,
!
var
)
in
List
.
iter
(
fun
t
->
if
t
<
0
then
(
!
vars
)
.
(
-
t
)
<-
(
ref
clause
)
::
(
!
vars
)
.
(
-
t
))
l
;
clause
end
module
M
=
Dimacs
.
Make
(
Std
.
Loc
)(
Term
)(
Statement
(
Term
))
let
parse_file
=
fun
x
->
snd
(
M
.
parse_file
x
)
let
sort_clauses
=
List
.
fast_sort
(
fun
c1
c2
->
match
c1
,
c2
with
|
Clause
(
n1
,_
)
,
Clause
(
n2
,_
)
->
compare
!
n1
!
n2
|
_
->
failwith
"cannot happen"
)
let
to_propagate
clauses
=
match
clauses
with
|
[]
->
false
|
Clause
(
n1
,_
)
::
_
->
!
n1
==
0
|
_
->
failwith
"cannot happen"
let
propagate
vars
assignement
p
=
if
assignement
.
(
p
)
==
false
then
(
assignement
.
(
p
)
<-
true
;
List
.
iter
(
fun
c
->
match
!
c
with
|
Clause
(
n
,_
)
->
decr
n
|
_
->
failwith
"cannot happen"
)
vars
.
(
p
)
)
let
get_model
assignement
=
let
n
=
Array
.
length
assignement
in
let
model
=
ref
[]
in
for
i
=
1
to
n
-
1
do
let
p
=
n
-
i
in
if
assignement
.
(
p
)
then
model
:=
p
::
!
model
else
model
:=
(
-
p
)
::
!
model
done
;
!
model
(* used for debugging *)
let
print_clauses
=
List
.
iter
(
function
|
Clause
(
n
,
Some
p
)
->
printf
"(nb: %d, var: %d) "
!
n
p
|
Clause
(
n
,
None
)
->
printf
"(nb: %d, no var)"
!
n
|
_
->
failwith
"cannot happen"
)
let
process
statements
=
match
statements
with
|
Vars
vars
::
clauses
->
let
vars
=
!
vars
and
clauses
=
ref
clauses
and
assignement
=
Array
.
make
(
Array
.
length
!
vars
)
false
and
processing
=
ref
true
and
unsat
=
ref
false
and
trace
=
ref
[]
in
while
!
processing
do
processing
:=
false
;
clauses
:=
sort_clauses
!
clauses
;
while
to_propagate
!
clauses
&&
not
!
unsat
do
match
!
clauses
with
|
Clause
(
_
,
Some
p
)
::
l
->
(
processing
:=
true
;
clauses
:=
l
;
trace
:=
(
"propagating "
^
string_of_int
p
)
::
!
trace
;
propagate
vars
assignement
p
)
|
Clause
(
_
,
None
)
::
_
->
(
trace
:=
"propagating false"
::
!
trace
;
unsat
:=
true
)
|
_
->
failwith
"cannot happen"
done
done
;
if
!
unsat
then
(
Error
(
List
.
rev
!
trace
)
)
else
(
Ok
(
get_model
assignement
,
List
.
rev
!
trace
)
)
|
_
->
failwith
"cannot happen"
Loading