howestim
2019-12-21 17:49:59

@howestim has joined the channel


wanderley.guimaraes
2019-12-21 18:22:44

I wrote it by hand but I thought about Rossete. I’ve watched one presentation about Rossete (that is the max I know) and I remember the presenter saying that it is possible that satisfy a predicate and is optimized for size. I definitely need to check it out.


wanderley.guimaraes
2019-12-21 18:23:39

I have to catch up! Missed the last two days and I just finished day 21. I will work on 20 and then finish the second part of day 19.


wanderley.guimaraes
2019-12-21 19:00:44

By the way, is it possible to express any Boolean expression in springscript?


wanderley.guimaraes
2019-12-21 19:03:08

I think we can’t, but I might not be thinking correctly about the problem.

(not A and not B) or (not C and not D)

I don’t see how I could write a springscript (with only two writable registers) to express this expression.


wanderley.guimaraes
2019-12-21 19:03:29

Is there a way?


sorawee
2019-12-21 23:24:14

I just realized I probably should have posted stuff here to prevent spoiling people. Sorry about that.


sorawee
2019-12-21 23:24:29

@wanderley.guimaraes here’s a Rosette code to generate a springscript equivalent to (not A and not B) or (not C and not D)


sorawee
2019-12-21 23:25:04

sorawee
2019-12-21 23:25:14

And the springscript output from the above program is

OR C J OR A T OR D J OR B T AND J T NOT T J which uses 6 instructions. Note that when I tried 5 instructions Rosette says there’s no solution, so 6 is the shortest program.


sorawee
2019-12-21 23:25:24

We just synthesize De Morgan’s law, pretty much :slightly_smiling_face:


sorawee
2019-12-21 23:25:35

Can you express any propositional formula in springscript? Answer yes.

Proof: Any propositional formula can be converted to CNF. It is enough to use the temporary register for one CNF clause. Therefore, we can accumulate results from each clause into the output register.

Claim: It is enough to use the temporary register for one CNF clause

Proof: For a CNF clause (or A1 … An (not B1) … (not Bm)) , emit the instructions

NOT B1 T NOT T T which sets T to B1 .

Then, conjoin it with the rest of Bi , and then use De Morgan’s law to obtain (or (not B1) ... (not Bm)).

AND B2 T ... AND Bm T NOT T T And now disjoin it with the rest of Ai .

OR A1 T ... OR An T which gives us the desired result.


wanderley.guimaraes
2019-12-22 00:07:08

Thanks for the code example and the proof!


sorawee
2019-12-22 00:20:34

One thing to keep in mind is the the usual CNF conversion — Tseitin transformation — doesn’t work here


sorawee
2019-12-22 00:21:13

because Tseitin transformation doesn’t maintain logical equivalence. It only maintains equi-satisfiability.


sorawee
2019-12-22 00:23:39

So you need a much more expensive CNF conversion. The point of Tseitin transformation is that it can be done in polynomial (in fact linear) time, but converting to CNF while maintaining logical equivalence is not known to be possible in polynomial time. This is in fact equivalent to asking whether P =? NP