# US 2012/0254827 A1 · Verification of computer-executable code generated from a model

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2012/0254827 A1
- Document ID: US20120254827A1
- Status: Published application
- Kind: A1
- Application number: 13/250,590
- Filed: 2011-09-30
- Published: 2012-10-04
- Earliest claimed: 2009-09-14
- Assignees: The MathWorks, Inc.
- Inventors: Mirko CONRAD; Xiaocang LIN; Jun YAN; Peter SZPAK; Appa Rao NIRAKH; Jaya SHANKAR
- Web page: https://patentgrep.com/patent/US20120254827A1

## CPC

- G06F 8/35: model driven
- G06F 11/3604: Analysis of software for verifying properties of programs (testing of software G06F11/3668)
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

In an embodiment, a model is sliced into a plurality of slices. A slice in the plurality of slices is selected. A portion of code, that corresponds to the selected slice, is identified from code generated from the model. The identified code is verified to be equivalent to the selected slice. Equivalence may include equivalent functionality, equivalent data types, equivalent performance, and/or other forms of equivalence between the selected slice and the identified generated code.

## Claims

### Claim 1

One or more tangible non-transitory computer-readable storage media for storing computer-executable instructions executable by processing logic, the media storing one or more instructions for:
slicing a model into a plurality of slices;
selecting a slice from the plurality of slices;
identifying a portion of code, in code generated from the model, that corresponds to the selected slice; and
verifying that the identified code is equivalent to the selected slice.

### Claim 2 (depends on 1)

The media of claim 1, wherein the model is sliced based on at least one of:
one or more outputs of one or more portions of the model, or
whether one or more portions of the model are verifiable or unverifiable.

### Claim 3 (depends on 2)

The media of claim 2, wherein a portion of the model is treated as unverifiable if at least one of:
the portion of the model contains an unknown element, or
code that corresponds to an element, in the portion of the model, cannot be identified in the code generated from the model.

### Claim 4 (depends on 1)

The media of claim 1, further comprising one or more instructions for:
generating or receiving an intermediate representation (IR) of the selected slice;
generating or receiving an IR of the identified portion of code; and
determining whether the IR of the selected slice is equivalent to the IR of the identified portion of code.

### Claim 5 (depends on 1)

The media of claim 1, further comprising one or more instructions for:
generating a program dependency IR based on one or more data dependencies in the identified code and one or more control dependencies in the identified code; and
slicing the program dependency IR into a plurality of slices.

### Claim 6 (depends on 5)

The media of claim 5, wherein the program dependency IR includes a graph G(e, v), where e represents one or more edges and v represents a plurality of vertices, and wherein the program dependency IR is sliced based on:
given a vertex vi of the graph G(e, v), a slice of graph G(e, v) with respect to vi is a graph G′(e′, v′) containing one or more vertices of which vi has a transitive flow or a control dependency.

### Claim 7 (depends on 1)

The media of claim 1, further comprising one or more instructions for:
generating or receiving an IR of the identified portion of code; and
normalizing the IR of the identified portion of code.

### Claim 8 (depends on 1)

The media of claim 1, wherein the identified portion of code contains a statement and wherein the media further comprises one or more instructions for:
identifying a semantic equivalent for the statement in the identified portion of code; and
replacing the statement in the identified portion of code with the identified semantic equivalent.

### Claim 9 (depends on 1)

The media of claim 1, wherein the identified portion of code contains a plurality of statements and wherein the media further comprises one or more instructions for:
replacing the plurality of statements in the identified portion of code with a phi node, the phi node representing at least one of:
a control flow of the replaced plurality of statements, or
a data flow of the replaced plurality of statements.

### Claim 10 (depends on 1)

The media of claim 1, further comprising one or more instructions for:
generating or receiving an IR of the identified portion of code;
performing a transformation operation on the IR;
reporting a result of the transformation operation performed on the IR, the result including information related to a change made to the IR in response to performing the transformation operation on the IR.

### Claim 11 (depends on 1)

The media of claim 1, further comprising one or more instructions for:
identifying an element in the model for which corresponding code in the generated code cannot be identified; and
placing the element in a subsystem, apart from the selected slice, for separate verification.

### Claim 12 (depends on 1)

The media of claim 1, further comprising one or more instructions for:
identifying an element in the model which cannot be verified; and
indicating, in a block diagram display of the model, that the identified element cannot be verified.

### Claim 13 (depends on 1)

The media of claim 1, further comprising one or more instructions for:
identifying an element in the model which cannot be verified; and
modifying the identified element to make the identified element verifiable.

### Claim 14

A method comprising:
selecting a slice of a model from a plurality of slices of the model, the plurality of slices of the model being identified based on one or more criteria;
identifying a portion of code, in code generated for the model, that corresponds to the selected slice;
generating an intermediate representation (IR) of the selected slice of the model;
generating an IR of the identified portion of code; and
verifying that the IR of the selected slice of the model is equivalent to the generated IR of the identified portion of code.

### Claim 15 (depends on 14)

The method of claim 14, wherein the identified portion of code includes one or more data dependencies and one or more control dependencies, and wherein generating an IR of the identified portion of code further includes:
generating a program dependency graph that represents the one or more data dependencies and the one or more control dependencies; and
slicing the program dependency graph into a plurality of slices, wherein the program dependency graph includes a graph G(e, v), where e represents one or more edges and v represents a plurality of vertices, and wherein the program dependency graph is sliced based on: given a vertex vi of the graph G(e, v), a slice of graph G(e, v) with respect to vi is a graph G′(e′, v′) containing one or more vertices of which vi has a transitive flow or a control dependency.

### Claim 16 (depends on 14)

The method of claim 14, wherein the method further comprises:
normalizing at least one of:
the IR of the selected slice of the model, or
the IR of the identified portion of code.

### Claim 17 (depends on 16)

The method of claim 16, wherein normalizing the IR of the identified portion of code includes:
converting a portion of the IR of the identified portion of code that represents a control flow in the code to represent a data flow.

### Claim 18 (depends on 14)

The method of claim 14, wherein the identified portion of code contains a plurality of statements and wherein the method further comprises:
replacing the plurality of statements in the identified portion of code with a phi node, the phi node representing at least one of a control flow or a data flow of the replaced plurality of statements.

### Claim 19 (depends on 14)

The method of claim 14, wherein verifying further comprises:
reporting a change made to the IR of the identified portion of the code in response to performing a transformation on the IR of the identified portion of the code.

### Claim 20

One or more tangible non-transitory computer-readable storage media for storing computer-executable instructions executable by processing logic, the media storing one or more instructions for:
selecting a slice of a model from a plurality of slices of the model, the plurality of slices of the model being identified based on one or more criteria associated with the model, the selected slice containing a portion of the model that is verifiable;
identifying a portion of code, in code generated for the model, that corresponds to the verifiable portion of the model contained in the selected slice; and
verifying that the identified code is equivalent to the selected slice, the verifying including:
generating an intermediate representation (IR) of the portion of the model contained in the selected slice,
generating an IR of the identified code, and
verifying that the IR of the portion of the model and of IR of the identified code are equivalent.

### Claim 21 (depends on 20)

The medium of claim 20, wherein the one or more criteria includes at least one of:
state of a system represented by the model,
an output of the model,
an observable signal of the model, or
a portion of state of the model.

### Claim 22

One or more tangible non-transitory computer-readable storage media for storing computer-executable instructions executable by processing logic, the media storing one or more instructions for:
slicing a model into a plurality of slices based on at least one of:
whether a portion of a model is verifiable, or
whether the portion of the model contains an unknown element;
verifying a first slice in the plurality of slices, the first slice being associated with a portion of the model that is verifiable;
providing a first indication, in a block diagram of the model, that indicates the first slice is verified; and
providing a second indication, in the block diagram of the model, that a second slice, containing a portion of the model that is verifiable, in the plurality of slices is not verified.

### Claim 23 (depends on 22)

The media of claim 22, further comprising one or more instructions for:
identifying a portion of the model that is not part of any slice in the plurality of slices; and
providing a third indication, the block diagram of the model, that the identified portion is not part of any slice in the plurality of slices.

### Claim 24

One or more tangible non-transitory computer-readable storage media for storing computer-executable instructions executable by processing logic, the media storing one or more instructions for:
identifying a slice of code generated from a model;
identifying a slice of expected code for the model; and
verifying that the identified slice of generated code is equivalent to the identified slice of expected code.
