Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Check for placeholder nodes in proof verification #61
Check for placeholder nodes in proof verification #61
Changes from 6 commits
0f8d2d4
c96dcaf
d91ed00
d2555d7
ac9a7b8
a1f90d0
8450bb8
8a4b4d9
05b8a53
548b3f0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Looking at the failing test cases, I think this math is wrong.
Assume there are 2 children, those would have position 0, and 1.
For position 0, I would get 2-1-0 = 1 left children (but should be 0)
For position 1, I would get 2-1-1 = 0 left children. (but should be 1)
I think
leftChildren := idx
would be correctThere 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.
Yeah, this makes more sense. I was thinking about this backwards semantically, such that
branch
meant, "the index over here" rather than, "the index corresponding to sibling data with this shape"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.
Shouldn't this also be
isRight: true
? there is no suffixThere 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.
Likewise, this is leftmost from the previous definition
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.
Expect: IsRight: true
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.
Expect: IsLeft: true
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.
Expect: IsRight: true
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.
Expect: IsLeft: true
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.
Expected: IsRight: true
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.
Expected IsLeft: true
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.
Hmm, you are calling
leftBranchesAreEmpty
notIsLeftMost
, so maybe my comments are wrong above.However if there are no left branch, I would assume that
leftBranchesAreEmpty
would be trueThere 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 think this is an error of naming and intended meaning. The field should probably have been
IsLeftPlaceholder
, since I meant for this to only be true for ops that contain an empty subtree on the left side.It didn't make sense to me to call
leftBranchesAreEmpty
on the InnerOp describing a left branch, since by definition its left branch is non empty. So, I mistakenly used the branch index to instead get the padding for the branch on the opposite side (which of course works only when there are 2 children. I made it worse by hard coding the branch to make it work).Even with your fix though, I would argue that these functions should not pass on Ops that describe a non-empty branch on the corresponding side. They only pass trivially now because the padding is empty, which I'd consider a bug.
So, I propose renaming the field to
IsLeftPlaceholder
, and changing the behavior so the functions fail when there is no padding to check for the corresponding side so e.g.leftBranchesAreEmpty(..., branch=0)
is always false.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.
Since you will be the largest user if this, I can accept it. I am still not convinced this is the best or most maintainable way to write it.
I would like the function to say "isLeftmost" regardless of empty children to the left and replace the current padding check with just this function. Rather than check if it is actually the leftmost, and then check if it is not leftmost, but all (non-zero) left siblings are empty.
I think doing this logic in one piece would avoid confusion later. But I won't block this pr more.
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.
Okay, I started to write a patch and see another error... you hardcode 0 and 1 as positions. Let's use the real position it has from padding.