Skip to content

loop normal form properties #7518

Open
Open
@remi-delmas-3000

Description

@remi-delmas-3000

@thomasspriggs @martin-cs Here is a summary of the properties of loop normal form for goto programs:

Viewing a GOTO program as both the sequence of its instructions as the control flow graph induced by the sequence structure and its GOTO statements: each instruction is a node, there's an edge n1->n2 iff n2 is the successor of n1 in the sequence, or if n1 is a GOTO instruction with n2 as jump target. The entry point of the graph is the node of the first instruction.

A loop in the CFG is a set of strongly connected nodes. The loop is natural iff there is a node in the loop, the header, that dominates the other nodes of the loop. An edge going from an instruction of the loop to the header node is called a back-edge. A node that has a back edge is called a latch node.

A node is an exiting node if it has at least one successor that is not in the loop. That successor outside of the loop is called an exit node of the loop.

The properties of a normalised natural loop are:

  • The header node is the only node with predecessors that are not in the loop
  • The header node has a unique predecessor called the pre-header node
  • The predecessors of exit nodes are all in the loop (i.e. control can only reach an exit node without actually going through the loop instructions first)
  • The loop has a single latch node

We say that a natural loop is densely packed in the goto program iff the sub-sequence of instructions starting at the loop header instruction and ending at the loop latch instruction only contains instructions of the loop and iff the preheader node is right before the header node in the sequence.

A goto-program is loop normal form iff all the loops it contains are natural, densely packed and if the only edges that jump to an instruction with a lower index in the sequence are back-edges of natural loops.

These notions are captured in two functions:

  • a checker function that checks if the loop normal form properties holds on a goto program, and returns either success or an error value describing why it does not hold, e.g. "exit node 'n' of loop 'l' has a predecessor that is not in 'l'", "there is a backwards jump in the sequence that is not a natural loop back-edge")
  • a normalisation function that rewrites a goto program's instruction sequence to loop normal form, and returns either success if the operation succeeds, or an error value describing the reason for failure.
  • the normalisation function should be idempotent, i.e. should not modify a program that is already in loop normal form (it can use the checker function to decide wether there is work to do or not).

Metadata

Metadata

Labels

awsBugs or features of importance to AWS CBMC usersfeature request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions