-
Notifications
You must be signed in to change notification settings - Fork 19
Added the use of variable names other than 'x' #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Added support for single letter variables names different from x
|
Thanks, looks nice! I'll review tomorrow, but it looks good to me :) |
|
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 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 |
|
HI, I am not sure what you mean by "Please check it out and adjust your PR to match them" (them = the tests). |
|
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. |
|
FOUND the issue in ANF::readFileForMaxVar — need to handle ()_ better. |
test.cnf
Outdated
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
|
Let’s not make it work for special characters :) Instead, let’s emit an
error of that happens.
…On Mon 7. Apr 2025 at 11:35, mocenigo ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/anf.cpp
<#48 (comment)>:
> }
size_t ANF::readFile(const std::string& filename)
{
// Read in the file line by line
vector<std::string> text_file;
+ size_t maxes[26] = {0};
I was assuming that only a-z and A-Z can be used, but in this case I am
also making assumptions on their encoding (ASCII). Maybe using tolower and
a std::is better, so people can also use ö or δ. Why not?
—
Reply to this email directly, view it on GitHub
<#48 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKF4ON7IZKYFFS7JH5BAS32YJBHNAVCNFSM6AAAAAB2QWYMCKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDONBWGE4DCNRZG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Anyway, since there are then 26 characters (up to lower case/upper case equivalence) I would keep the array of 26 values. 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. |
|
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? |
msoos
left a comment
There was a problem hiding this 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}; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
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? |
|
Sorry, I did not have time to work on this today. I will try and find time tomorrow.
… On 10. Apr 2025, at 23:02, Mate Soos ***@***.***> wrote:
msoos
left a comment
(meelgroup/bosphorus#48)
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?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
<#48 (comment)> <https://github.com/notifications/unsubscribe-auth/ABFK7QOHW57I6VEP4GUUXLD2Y3L57AVCNFSM6AAAAAB2QWYMCKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOJVGE2TSOJQGM>
msoos
left a comment
(meelgroup/bosphorus#48)
<#48 (comment)>
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?
—
Reply to this email directly, view it on GitHub <#48 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABFK7QOHW57I6VEP4GUUXLD2Y3L57AVCNFSM6AAAAAB2QWYMCKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOJVGE2TSOJQGM>.
You are receiving this because you authored the thread.
|
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. |
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.