Skip to content

Conversation

@mocenigo
Copy link

@mocenigo mocenigo commented Apr 5, 2025

As the name says, I added the use of variable names other than 'x'.
Any letter except 'c' and 'p' can be used.
I am also skipping underscores so a(2), a2, and a_2 should be equivalent,

Clauses that begin like q_0 = a_xb_x should be equivalent to q_0 + a_xb_x , unless I have misunderstood the syntax.

Finally, I outout a ".resolve" file that explains the correspondences between variables and numbers.

Note that at the moment I am adding 2 to the variable count because I am leaving "0 signifies 0" and "1 signifies 1" that the Courtois converter generated. If these are actually not used/needed, I can amend it.

msoos and others added 3 commits October 25, 2024 12:19
Added support for single letter variables names different from x
@msoos
Copy link
Collaborator

msoos commented Apr 5, 2025

Thanks, looks nice! I'll review tomorrow, but it looks good to me :)

@msoos
Copy link
Collaborator

msoos commented Apr 6, 2025

Hi,

I have now made the GitHub actions work, and build a binary for linux amd64 and arm64, and mac arm64. It now also runs a test suite. You can find the tests under tests/anf-tests -- they specify what needs to run and what the output should mostly look like. It's a very simple system. Please check it out and adjust your PR to match them. Sorry for the system being in such a sorry state before. With this change, I think your PR will also be a lot more impactful, as Bosphorus will finally be available for different architectures, etc.

Once your PR is merged, I will create a new release, and attach the auto-generated binaries, e.g. the ones at the bottom of this page here:

https://github.com/meelgroup/bosphorus/actions/runs/14292531540

but of course after your PR is merged.

Sorry for this delay. I worked on this for a few hours, so hopefully it'll now be a lot easier to release things and to build them for different target architectures.

Mate

@mocenigo
Copy link
Author

mocenigo commented Apr 6, 2025

HI, I am not sure what you mean by "Please check it out and adjust your PR to match them" (them = the tests).

@msoos
Copy link
Collaborator

msoos commented Apr 6, 2025

Hi! I just meant that I saw you added some test cases -- I was just trying to ask you to adjust your test cases to the pattern that's in that directory. I think it should be easy, but let me know if you have any trouble! Thank you a lot!

@mocenigo
Copy link
Author

mocenigo commented Apr 6, 2025

Hi! I just meant that I saw you added some test cases -- I was just trying to ask you to adjust your test cases to the pattern that's in that directory. I think it should be easy, but let me know if you have any trouble! Thank you a lot!

Oh, interesting, I am not sure how those ended up there. I may have mixed up things.
They seem to be all tests that were in this repo previously (at leat last year). I however pulled the latest before branching for my changes, so they must be yours.

@mocenigo
Copy link
Author

mocenigo commented Apr 6, 2025

bosphorus --anfread substitute_carefully.anf --cnfwrite substitute_carefully.cnf
crashes:
libc++abi: terminating due to uncaught exception of type polybori::PBoRiError: Variable index out of bounds.
(but also the master from your repo, I think)

FOUND the issue in ANF::readFileForMaxVar — need to handle ()_ better.

test.cnf Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with test.anf

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with test.anf

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with test.anf

@msoos
Copy link
Collaborator

msoos commented Apr 7, 2025 via email

@mocenigo
Copy link
Author

mocenigo commented Apr 7, 2025

Let’s not make it work for special characters :) Instead, let’s emit an error of that happens.

Anyway, since there are then 26 characters (up to lower case/upper case equivalence) I would keep the array of 26 values.
note that I am keeping counts of the variables and already adding +1 there, so I removed this addition from bosphorus.cpp .

Omitting "c" and "p" means that there are only 24 valid characters, I am not sure that allowing "C" and "P" are good ideas, so I am not allowing them. This means that their maxes counters will remain zero.

@mocenigo mocenigo requested a review from msoos April 7, 2025 10:19
@mocenigo
Copy link
Author

mocenigo commented Apr 9, 2025

HI @msoos it is not clear to me what I should change. Since we only use latin alphabet letters for the variables, the 26-element array for the counts is sufficient, I have decuded to keep it and I have added a comment. I ran some tests, and added a test using a "ü" — what else should I do?

Copy link
Collaborator

@msoos msoos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI,

Thanks, looking a lot better! Can you please delete the CNF files from the test directory? Also, all .anf files need to have RUN and CHECK directives that you are adding. I also don't understand the .resolve file. This sounds like maybe some old remnant? Maybe we just need to rebase this PR, let me try doing that.

src/anf.cpp Outdated
size_t maxVar = 0;

// Only 26 because we allow only a-z and A-Z as variable names (case insensitive) (note we skip c, p)
size_t maxes[26] = {0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Can we rename this variable? "maxes" is something I don't really understand, doesn't seem intuitive

src/anf.cpp Outdated
int index = (varLetter-'a'); // variables are zero based
//printf("%c %zu ", varLetter, var);
if (maxes[index] <= var) {
maxes[index] = var+1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe maxVarForLetter or something?

src/anf.cpp Outdated
{
// Read in the file line by line
vector<std::string> text_file;
size_t maxes[26] = {0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, does that zero out maxes? I am still very unhappy about this being a statically sized array. Can we make it into a

vector<uint32_t> maxVarForLetter(26,0)

Please? To me that's a lot easier to deal with. The performance hit is basically zero, but it's a lot easier to deal with.

src/anf.cpp Outdated
size_t maxes[26] = {0};

size_t maxVar = 0;
size_t currentVar = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why it starts at 2? Is there a reason?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long absence, I have had some work emergencies and also a family one. And after that a few days with a fever. The addition of 2 was due to a program that needs 0 and 1 for 0 and 1 instead of variables, but we should just renumber variables progressively.

Additionally, the "bad_char.anf.resolve" files where just the mappings from new variables to the old names, since some programs need that to reconstruct the original problem. I will fix them instead and start from 0.

In the future I might modify this to accept variables made of letters + (optional)"_" + numbers, but at the moment a single letter different from c should be fine.

@msoos
Copy link
Collaborator

msoos commented Apr 10, 2025

Can't seem to be able to rebase to remove those ANF and CNF and RESOLVE files. Can you please remove them from your PR?

@mocenigo
Copy link
Author

mocenigo commented Apr 11, 2025 via email

@mocenigo
Copy link
Author

mocenigo commented May 4, 2025

I have now made the GitHub actions work, and build a binary for linux amd64 and arm64, and mac arm64. It now also runs a test suite. You can find the tests under tests/anf-tests -- they specify what needs to run and what the output should mostly look like. It's a very simple system. Please check it out and adjust your PR to match them. Sorry for the system being in such a sorry state before. With this change, I think your PR will also be a lot more impactful, as Bosphorus will finally be available for different architectures, etc.

Sadly, I do not understand how the test system works. Anyway, I changed the name of the "maxes" array and used the vector<uint32_t> you suggested instead. I changed the ending of the "resolve" files to mapping, so that one can used them to map back to the original variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants