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
1
Expand
Closes
#5 (closed)
Closes
#4 (closed)
Edited
2 years ago
by
aalbert
👍
0
👎
0
Merge request reports
Compare
version 17
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 19
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
1 file
+
67
−
5
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
project1/lib/lib.ml
0 → 100644
+
209
−
0
Options
open
Dolmen
open
Printf
(* generate dimacs files *)
let
generate_dimacs
oc
horn
variables
clauses
=
Random
.
self_init
()
;
fprintf
oc
"p cnf %d %d
\n
"
variables
clauses
;
for
_
=
1
to
clauses
do
let
nb_var
=
1
+
Random
.
int
variables
in
if
horn
then
(
for
_
=
1
to
nb_var
-
1
do
let
var
=
1
+
Random
.
int
variables
in
fprintf
oc
"%d "
(
-
var
)
done
;
let
concl
=
Random
.
int
5
in
if
concl
!=
0
||
nb_var
==
1
then
let
var
=
1
+
Random
.
int
variables
in
fprintf
oc
"%d "
var
)
else
(
for
_
=
1
to
nb_var
do
let
var
=
1
+
Random
.
int
variables
in
let
sign
=
2
*
(
Random
.
int
2
)
-
1
in
fprintf
oc
"%d "
(
sign
*
var
)
done
);
fprintf
oc
"0
\n
"
done
(* open and print the content of a file *)
let
print_file
name
=
print_endline
name
;
let
ic
=
open_in
name
in
try
while
true
do
print_endline
(
input_line
ic
)
done
with
End_of_file
->
close_in
ic
(* polymorphic function to remove duplicates from lists *)
let
remove_duplicates
(
type
a
)
(
l
:
a
list
)
=
let
module
S
=
Set
.
Make
(
struct
type
t
=
a
let
compare
=
compare
end
)
in
let
rec
remove
acc
seen_set
=
function
|
[]
->
List
.
rev
acc
|
a
::
rest
when
S
.
mem
a
seen_set
->
remove
acc
seen_set
rest
|
a
::
rest
->
remove
(
a
::
acc
)
(
S
.
add
a
seen_set
)
rest
in
remove
[]
S
.
empty
l
(* print a list *)
let
print_list
print
l
=
let
buffer
=
Buffer
.
create
100
in
Buffer
.
add_char
buffer
'
[
'
;
let
rec
aux
=
function
|
[]
->
Buffer
.
add_char
buffer
'
]
'
|
[
x
]
->
Buffer
.
add_string
buffer
(
print
x
);
Buffer
.
add_char
buffer
'
]
'
|
x
::
l
->
Buffer
.
add_string
buffer
(
print
x
);
Buffer
.
add_char
buffer
'
;
'
;
aux
l
in
aux
l
;
Buffer
.
contents
buffer
(** naive XOR to cnf formula conversion **)
type
formula
=
Neg
of
formula
|
Or
of
formula
*
formula
|
And
of
formula
*
formula
|
Var
of
int
|
Xor
of
formula
*
formula
let
rec
print_formula
=
function
|
Neg
f
->
print_string
"~("
;
print_formula
f
;
print_string
")"
|
Or
(
a
,
b
)
->
print_string
"("
;
print_formula
a
;
print_string
" or "
;
print_formula
b
;
print_string
")"
|
And
(
a
,
b
)
->
print_string
"("
;
print_formula
a
;
print_string
" and "
;
print_formula
b
;
print_string
")"
|
Xor
(
a
,
b
)
->
print_string
"("
;
print_formula
a
;
print_string
" xor "
;
print_formula
b
;
print_string
")"
|
Var
x
->
print_int
x
let
rec
remove_xor
=
function
|
Xor
(
a
,
b
)
->
let
a
=
remove_xor
a
and
b
=
remove_xor
b
in
(
And
(
Or
(
a
,
b
)
,
Or
(
Neg
a
,
Neg
b
)))
|
Or
(
a
,
b
)
->
Or
(
remove_xor
a
,
remove_xor
b
)
|
And
(
a
,
b
)
->
And
(
remove_xor
a
,
remove_xor
b
)
|
Neg
a
->
Neg
(
remove_xor
a
)
|
Var
x
->
Var
x
let
rec
to_cnf
=
function
|
Neg
(
Var
i
)
->
Var
(
-
i
)
|
Neg
(
Neg
(
a
))
->
to_cnf
a
|
Neg
(
And
(
a
,
b
))
->
to_cnf
(
Or
(
Neg
a
,
Neg
b
))
|
Neg
(
Or
(
a
,
b
))
->
to_cnf
(
And
(
Neg
a
,
Neg
b
))
|
Or
(
And
(
a
,
b
)
,
c
)
->
to_cnf
(
And
(
Or
(
a
,
c
)
,
Or
(
b
,
c
)))
|
Or
(
c
,
And
(
a
,
b
))
->
to_cnf
(
And
(
Or
(
a
,
c
)
,
Or
(
b
,
c
)))
|
And
(
a
,
b
)
->
And
(
to_cnf
a
,
to_cnf
b
)
|
Or
(
a
,
b
)
->
let
a
=
to_cnf
a
and
b
=
to_cnf
b
in
(
match
(
a
,
b
)
with
|
And
_
,
_
|
_
,
And
_
->
to_cnf
(
Or
(
a
,
b
))
|
_
->
Or
(
a
,
b
)
)
|
Var
i
->
Var
i
|
_
->
failwith
"cannot happen"
let
cnf_to_int_list
form
=
let
res
=
ref
[]
in
let
rec
clause
c
=
function
|
Or
(
a
,
b
)
->
clause
c
a
;
clause
c
b
|
Var
i
->
c
:=
i
::
!
c
|
_
->
failwith
"cannot happen"
in
let
rec
conjonction
=
function
|
And
(
a
,
b
)
->
conjonction
a
;
conjonction
b
|
Or
(
a
,
b
)
->
let
c
=
ref
[]
in
clause
c
a
;
clause
c
b
;
res
:=
!
c
::
!
res
|
Var
i
->
res
:=
[
i
]
::
!
res
|
_
->
failwith
"cannot happen"
in
conjonction
form
;
!
res
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
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
=
int
list
=
struct
type
location
=
Std
.
Loc
.
t
type
term
=
int
type
t
=
int
list
let
p_cnf
?
loc
nb_var
nb_clause
=
let
_
=
loc
in
[
nb_var
;
nb_clause
]
let
clause
?
loc
l
=
let
_
=
loc
in
l
end
module
M
=
Dimacs
.
Make
(
Std
.
Loc
)(
Term
)(
Statement
(
Term
))
let
convert_xorsat
file
=
match
snd
(
M
.
parse_file
file
)
with
|
[
nb_var
;
nb_clause
]
::
statements
->
let
statements
=
List
.
concat_map
(
fun
l
->
cnf_to_int_list
(
to_cnf
(
remove_xor
(
(
List
.
fold_left
(
fun
form
x
->
Xor
(
form
,
Var
x
))
(
Var
(
List
.
hd
l
))
(
List
.
tl
l
))))))
statements
in
let
oc
=
open_out
"conversion.cnf"
in
Printf
.
fprintf
oc
"p cnf %d %d
\n
"
nb_var
nb_clause
;
List
.
iter
(
fun
clause
->
List
.
iter
(
fun
x
->
Printf
.
fprintf
oc
"%d "
x
)
clause
;
Printf
.
fprintf
oc
"0
\n
"
)
statements
;
close_out
oc
|
_
->
failwith
"cannot happen"
Loading