That must statement will have no affect as leaf “a” will have been deleted when you set leaf “b” before the must statement check.
I believe you are looking for something like this:
leaf a {
type string;
}
leaf b {
type string;
when 'not(../a)';
}