[miaou] Implement description of irreflexive tests#1696
Open
fsestini wants to merge 1 commit intoherd:masterfrom
Open
[miaou] Implement description of irreflexive tests#1696fsestini wants to merge 1 commit intoherd:masterfrom
irreflexive tests#1696fsestini wants to merge 1 commit intoherd:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR extends
miaou7to be able to generate English prose descriptions of memory model requirements expressed in the form ofirreflexivetest in the cat file.Not all such irreflexivity tests are supported. This extension specifically targets cat tests corresponding to the prose requirements from the Arm ARM Section B2.3.1, in the definition of Reads-from-memory and the definition of Coherence-Before, Coherence-after. In the current cat model, these are the
irreflexivetestscoRW1-Exp,coRW1-MTE,coWW-Exp,coWR-Exp, andcoWR-MTE. For these tests, the extendedmiaou7will generate a description that closely matches the currently handwritten prose from the Arm ARM. For example:Heuristic for identifying premises and conclusion
The generated prose follows an “if [precondition] then [postcondition]” structure. However, the corresponding cat expressions do not carry an intrinsic notion of “precondition” vs “postcondition”.
The extended
miaou7applies a heuristic to determine which parts of the cat expression are interpreted as premises and which as the conclusion. Specifically, it looks forirreflexivetests of one of the following forms:irreflexive r₁; r₂; …; r, whereris not an identity relation ([...]), orirreflexive [e]; r₁; r₂; …; r; [e₁]; [e₂]; …; [en], again withrnot anidentity.
In both cases, the final non-identity relation
ris interpreted as the postcondition, and all relations preceding it are interpreted as the precondition. This matches howirreflexivetests such ascoRW1-Exp, etc., are written in the cat model and hand-described in B2.3.Note that as a result of this heuristic, any trailing identity relations after
rare ignored. The assumption is that, in a test of the formthe set
eande₁ & ... & enare expected to be the same, in which case the test above is equivalent to(I believe the equivalence should also hold if the set
eis a strict subset ofe₁ & ... & en, but not the other way around.)This assumption is not currently checked by the tool, although it is consistent with the current state of the memory model. If needed,
miaou7could be strengthened to verify that this condition holds.Ideas for future tweaks to the cat model
Ideally, we would like
miaou7to generate identical prose for equivalent cat statements.For example, the following two statements should yield the same description:
miaou7already handles this case by internally normalising the first form into the second, as described above. However, other patterns are not yet handled. For example:Since
po & same-locis an internal relation,camust also be internal for the overall relation to be potentially reflexive. In other words,ca & extalways yields an irreflexive relation, and therefore does not represent an interesting "irreflexivity" test.The above can therefore be simplified to:
This PR does not introduce such simplification (in the cat model or in
miaou7's internals). Consequently, the generated prose will include a description of theintcomponent:While we can certainly continue to make
miaou7smarter, another option is to apply light simplifications to the formal memory model itself (for example, rewritingca & inttocain irreflexivity tests), so that tools likemiaou7can assume the input cat model is already “pre-normalised” by convention.I believe @relokin is overall in agreement with this idea; it would be great to also get @artkhyzha ’s opinion. In any case, please note that no changes to the cat files are planned for this particular PR.