Skip to content

Commit d4e9d6a

Browse files
committed
Should be fixed
1 parent 0edeebd commit d4e9d6a

File tree

6 files changed

+49
-6
lines changed

6 files changed

+49
-6
lines changed

html/index.html

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ <h1>Arjun Functional Synthesis in Your Browser</h1>
9292
description is available <a
9393
href="https://jix.github.io/varisat/manual/0.2.0/formats/dimacs.html">here</a></div>
9494
You need to have "c p show ... 0" for all the variables that are inputs
95+
<div>
96+
<label for="extra-args">Extra command line arguments:</label>
97+
<input type="text" id="extra-args"
98+
value='--mstrategy "const(max_repairs=400),const(max_repairs=400,inv_learnt=1),bve"'
99+
style="width:100%;padding:8px;box-sizing:border-box;font-family:monospace;border:1px solid #ddd;border-radius:4px;">
100+
</div>
101+
95102
<div>
96103
<label for="input-content">CNF:</label>
97104
<textarea id="input-content">p cnf 3 3
@@ -167,7 +174,8 @@ <h1>Arjun Functional Synthesis in Your Browser</h1>
167174
try {
168175
console.log('Running with args:', e.data.args);
169176
Module.FS.writeFile('/input.cnf', e.data.input);
170-
Module.callMain(['--verb', '1', '--synth', '/input.cnf']);
177+
var args = ['--verb', '3', '--synth'].concat(e.data.extraArgs || []).concat(['/input.cnf']);
178+
Module.callMain(args);
171179
postMessage({ type: 'done' });
172180
} catch (e) {
173181
postMessage({ type: 'error', content: e.toString() });
@@ -181,9 +189,32 @@ <h1>Arjun Functional Synthesis in Your Browser</h1>
181189
}
182190

183191
// Main execution logic
192+
function parseExtraArgs(str) {
193+
// Shell-like tokenizer: handles "quoted strings" and unquoted tokens
194+
const args = [];
195+
let i = 0;
196+
while (i < str.length) {
197+
while (i < str.length && str[i] === ' ') i++;
198+
if (i >= str.length) break;
199+
if (str[i] === '"') {
200+
i++;
201+
let start = i;
202+
while (i < str.length && str[i] !== '"') i++;
203+
args.push(str.slice(start, i));
204+
if (i < str.length) i++; // skip closing quote
205+
} else {
206+
let start = i;
207+
while (i < str.length && str[i] !== ' ') i++;
208+
args.push(str.slice(start, i));
209+
}
210+
}
211+
return args;
212+
}
213+
184214
document.getElementById('run-button').addEventListener('click', async function() {
185215
const inputContent = document.getElementById('input-content').value;
186216
const outputDiv = document.getElementById('output');
217+
const extraArgs = parseExtraArgs(document.getElementById('extra-args').value);
187218

188219
if (!inputContent.trim()) {
189220
outputDiv.textContent = 'Error: Please enter input content';
@@ -211,7 +242,8 @@ <h1>Arjun Functional Synthesis in Your Browser</h1>
211242
//console.log('ready. Sending input:', inputContent);
212243
worker.postMessage({
213244
type: 'run',
214-
input: inputContent
245+
input: inputContent,
246+
extraArgs: extraArgs
215247
});
216248
break;
217249
case 'done':

scripts/build_no_extra_synth.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
rm -rf lib* Test* tests* include tests CM* cmake* arjun Makefile rjun-src
6+
cmake -DEXTRA_SYNTH=OFF -DENABLE_TESTING=OFF ..
7+
make -j26

src/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ void add_arjun_options() {
162162
myopt("--unate", do_unate, fc_int,"Perform unate analysis");
163163
myopt("--unatedef", do_unate_def, fc_int,"Perform definition-aware unate analysis");
164164
myopt("--autarky", etof_conf.do_autarky, fc_int,"Perform unate analysis");
165-
myopt("--mbve", mconf.manthan_base, fc_int,"Use BVE with constants instead of training");
166165
myopt("--monflyorder", mconf.manthan_on_the_fly_order, fc_int,"Use on-the-fly training order and post-training topological order");
167166
myopt("--moneperloop", mconf.one_repair_per_loop, fc_int,"One repair per CEX loop");
168167
myopt("--minvertlearn", mconf.inv_learnt, fc_int,"Invert learnt functions");

src/manthan.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#ifdef EXTRA_SYNTH
4949
#include <mlpack/methods/decision_tree/decision_tree.hpp>
5050
#include "EvalMaxSAT.h"
51+
#include "manthan_learn.h"
5152
#endif
5253

5354
using std::min;
@@ -823,7 +824,8 @@ SimplifiedCNF Manthan::do_manthan() {
823824

824825
if (mconf.manthan_base == 0) {
825826
#ifdef EXTRA_SYNTH
826-
full_train();
827+
ManthanLearn learn(*this, conf, mconf);
828+
learn.full_train();
827829
#else
828830
cout << "ERROR: manthan_base is set to 2 but we are not in EXTRA_SYNTH mode!" << endl;
829831
exit(EXIT_FAILURE);
@@ -1865,6 +1867,7 @@ bool Manthan::get_counterexample(sample& ctx) {
18651867
verb_print(2, COLYEL "[manthan] *** Counterexample found ***");
18661868
ctx = cex_solver.get_model();
18671869
compute_needs_repair(ctx);
1870+
assert(!needs_repair.empty() && "If we found a counterexample, there must be something to repair!");
18681871
return false;
18691872
} else {
18701873
assert(ret == l_False);

src/manthan.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
THE SOFTWARE.
2323
*/
2424

25+
#pragma once
26+
2527
#include "arjun.h"
2628
#include "config.h"
2729
#include "metasolver.h"

src/manthan_learn.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ using sample = vector<lbool>;
4141

4242
class ManthanLearn {
4343
public:
44-
ManthanLearn(Manthan& _manthan, const Config& _conf, const Arjun::ManthanConf& _mconf) :
44+
ManthanLearn(Manthan& _manthan, const Config& _conf, const ArjunNS::Arjun::ManthanConf& _mconf) :
4545
m(_manthan), conf(_conf), mconf(_mconf) {
4646
point_0.zeros(m.cnf.nVars());
4747
point_1.zeros(m.cnf.nVars());
@@ -56,5 +56,5 @@ class ManthanLearn {
5656

5757
Manthan& m;
5858
const Config& conf;
59-
const Arjun::ManthanConf& mconf;
59+
const ArjunNS::Arjun::ManthanConf& mconf;
6060
};

0 commit comments

Comments
 (0)