-
Notifications
You must be signed in to change notification settings - Fork 41
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
first tests for (mm0 parser, mmu parser, mm0+mmu proof checker) #79
base: master
Are you sure you want to change the base?
Conversation
tests/fail/parsingBoth/chars cannot be outside a subset of the ascii charset.mm0
Outdated
Show resolved
Hide resolved
tests/fail/parsingBoth/chars cannot be outside a subset of the ascii charset2.mm0
Outdated
Show resolved
Hide resolved
I pushed some changes.
By the way, if it helps any I'm taking https://github.com/leanprover-community/lean/tree/master/tests/lean for inspiration. I don't have |
Ok, I'll do it that way, to the best of my capabilities. when matching mm0 statement vs mmu directive, it's a bit like having an expected.out and checking it, I guess. |
Am I supposed to do something to merge those 2 tests (that you beautified) ? |
The existing tests are fine, but you can add more tests to this PR. You had quite a few more last time you showed me. |
ok, will do |
those good ? |
another batch |
these are good modulo |
I'll start working on the next batch then...and slowly resume implementing the improved kotlin patcher for mm0 (and a patch for set.mm.mm0) |
bad-math-string2.mm0 serves no purpose and should be removed :/ |
tests/mm0_mmu/pass/math-string.mm0
Outdated
@ A B C D E F G H I J K L M N O | ||
P Q R S T U V W X Y Z [ \ ] ^ _ | ||
` a b c d e f g h i j k l m n o | ||
p q r s t u v w x y z { | } ~ DEL $; |
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.
this delimiter list is terrifying. The multi-character delimiters are not necessarily supported on all verifiers (certainly not on any that I have written), so that would put this in the "not necessarily pass" category (I'm thinking of calling this run/
to mean "don't segfault but pass and fail are both okay")
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 might have to modify the spec to only allow printable ascii inside math strings, because low ascii is a vector for display bugs, which could be exploitable to produce misleading theorem statements.
I don't think there is anything wrong with bad-math-string2, that's a possible parsing error. Same with |
You are the boss, you know best. The list inside delimiter was to test the fact that math string may hold ANY ascii char except '$' Indeed, it wouldn't hurt to prevent the use of all those legacy and useless ascii (not printable) char. |
oh yeah, nice one. I'm still a bit confused about if/how I should/could test things. I made 3 attemps at developping parsers for mm0 (and 1 for metamath), So I tried a few things (some of them stupid), so I have some experience in doing dangerous things : like skipping unparsed balanced parentheses strings to parse them later in a different process. It gives me some ideas to help other developpers prevent the same pitfalls :
You probably have it easier with the mmb format where everything is (certainly) located in a convenient place and you do not have parsing (structure) issues. Here, that's me being jealous :) |
what about too big ints, what should developper do to have valid proofcheckers in this case ? Say, if there is no limit to ints, and a big int overflows yet the developper doesn't guard agains that. |
in the spec, shouldn't math-strings be called something else ? |
Regarding primitives, maybe we should test against balanced parenthesis... but I do not see yet how that could be done simply (maybe later when we get to dynamic parsing/proofs) For comments, we probably should test against weirdly place comments (in whitestuff inside statements/dirrectives) |
arhhhh line comment don't have to start a line !!!!!! because of that We can have line comments anywhere a space is ok so this is valid mm0 stuff sort-- comment inside a statement Which makes catching/storing/somewhat preserving line comments a complete headache (for a patcher/transformation tool) That's it...I'm crying ;_; |
mmh. So I got whitespace wrong from the start... |
As I do not know yet how to simply test balanced parenthesis stuff, |
for sort fail test, we should probably check the order of modifyers... |
I'm wondering if I should commit fail tests for 3 modifiers 4 * 5 = 20 tests :/ If we were thorough, yes... now, betting on what you'll want... :) |
Let's see. You are a world expert on logic, formalism and the whole point of mm0 is to make sure that there is more truth, less false truth, less bugs in software and maths (and who knows where else...)... I'll prepare the 43 additionnal tests, while waiting ^^ |
tests/mm0_mmu/fail/bad-int1.mm0
Outdated
@@ -0,0 +1,2 @@ | |||
-- V-- overflowing hazard | |||
prefix p : $+$ prec 4294967296; |
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.
this is a run
test, verifiers may or may not reject it
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.
what does it mean for the test, should we remove it ?
proof checking should fail on such a test (rejecting bad input), right ?
We can make it a very long int, like bigger than u128, if you fear that in the future someone will implement a proof checker with precedence as u128 ints...
But it would be nice if the tests made the developpers aware that they have to reject bad stuff, or bad things could happen
when you have this what names do you give to binders in the mmu file ? (because of alpha renaming, we can do as we want, but what do you suggest ?) |
Those binders are named |
There are two valid behaviors for large precedences (more than 2046).
That is, the verifier implementation gets to choose what the largest numerical precedence is (as long as it is at least 2046), and all numerical precedences in that range have to be ordered like numbers. If you use a fixed size integer type to hold precedences (which is reasonable and logical), then a reasonable choice for the largest precedence is either MAX or MAX-1, using MAX to hold the special non-numerical precedence |
I'm considering making this a
It's true that you can do lots of things with mathematics, but the name seems fine. It is similar to LaTeX "math mode" as the generic term for "when you are between
Yes, this is valid. You should be glad that line comments aren't allowed inside math-strings, I considered that for a while (it can be useful for huge multi-line definitions). But it's a lot harder to reserve This is part of why |
I think there are only 6 = 4 choose 2 out of order pairs to test: any out of order modifier list needs to contain an adjacent out of order modifier (of which there are 6 possibilities), or a duplicate modifier (of which there are 4 possibilities). There are 16 possible pass tests but I don't think it's important to have them all. But considering that the main goal here is to catch whether the verifier is using an algorithm that lets these pass, you should only check that the order is correct (by checking that s1234 passes) and that out of order is rejected (so s21, s22, s31, s32, s33, s41, s42, s43, s44 are rejected). I'm pretty sure you will find a bug in one of my parsers with that. |
Yes, surprising comments can definitely cause exploitable issues. (I recall something similar with surprising behavior of the C preprocessor where Here's an example of an issue that the current spec may not defend against:
the secret is that between the two lines is a |
Damn, I lost my bet :/ |
What is a "run" test ? On my machine, I run a test, it either fails or pass which is the expected behavior or not, I do not have other options |
I mentioned that in an earlier post as a third category besides A given implementation should generally be able to say for any given run test whether it is supposed to be a pass or fail, but keeping track of this information in the test suite is more difficult because of the implementation sensitivity. |
ok, I understand now |
4a8b328
to
97abfae
Compare
Please tell me what is wrong so that I can fix it and make the next prs behave better.
Best regards,
Olivier