# US 2025/0147743 A1 · Generating Constraints In A Target Programming Language From Traces Of Operations Specified In An Input

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

- Number: US 2025/0147743 A1
- Document ID: US20250147743A1
- Status: Published application
- Kind: A1
- Application number: 18/770,219
- Filed: 2024-07-11
- Published: 2025-05-08
- Earliest claimed: 2023-11-08
- Assignees: Oracle International Corporation
- Applicants: Oracle International Corporation
- Inventors: Daniel Goodman
- Web page: https://patentgrep.com/patent/US20250147743A1

## CPC

- G06F 11/3636: {by tracing the execution of the program}
- G06F 8/30: Creation or generation of source code
- G06F 8/41: Compilation
- G06F 8/427: {Parsing}
- G06F 8/433: {Dependency analysis; Data or control flow analysis}
- G06F 8/447: {Target code generation}
- G06F 8/452: {Loops}
- G06F 8/75: Structural analysis for program understanding
- G06F 11/3684: {for test design, e.g. generating new test cases}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Constraints may be generated in a target programming language from traces of operations specified in a source input. Operations specified in an input, such as a data structure like a Directed Acyclic Graph (DAG) or source programming language, that access data may be traced. Based on the traces, a code template may be generated in a target programming language or data structure to test the operations of the traces to determine which traces are valid in order to add a portion of code in the target programing language that allow external code to be run only on valid traces.

## Claims

### Claim 1

A system, comprising:
at least one processor;
a memory, comprising program instructions that when executed by the at least one processor cause the at least one processor to:
generate a plurality of traces of a plurality of operations specified in an input that access data between a start node and an end node, wherein the plurality of operations comprise one or more put operations using a put index variable to set a value in an entry in an array and one or more get operations using a get index variable to obtain the value from the entry in the array;
based on the plurality of traces, generate a code template in a target programming language to test the plurality of operations of the plurality of traces, wherein the code template:
identifies a valid trace in the plurality of traces between the start node and the end node by pairing corresponding ones of the one or more put operations and the one or more get operations and testing for equivalence of index values calculated for the put index variable and the get index variable in respective contexts of the put operations and the get operations, wherein the pairing of the corresponding put operations and the get operations and the respective contexts are determined according to at least a forward pass and a backward pass respectively performed over individual ones of the plurality of traces to construct a set of loops and loop index substitutions that test for equivalence of the index values in the paired corresponding ones of the one or more put operations and the one or more get operations of the valid trace; and
for the identified valid trace, add a portion of code in the target programming language into the set of loops that prevents execution of further code placed in the code template for additional valid traces.

### Claim 2 (depends on 1)

The system of claim 1, wherein the input is a Directed Acyclic Graph (DAG).

### Claim 3 (depends on 1)

The system of claim 1, wherein the portion of code in the target language comprises one or more additional loops that act as guard loops.

### Claim 4 (depends on 1)

The system of claim 1, wherein the one or more additional loops are described in a guard description data object created as part of generating the code template.

### Claim 5 (depends on 4)

The system of claim 4, wherein a check is performed when creating the guard description object to determine whether more than one constraint trace exists.

### Claim 6 (depends on 1)

The system of claim 1, wherein to generate the code template in the target programming language, the program instructions cause the at least one processor to:
identify a put operation of the plurality of operations in a trace that updates a portion of shared state; and
instead of adding instructions to modify the shared state, add a local variable declaration to store the value the put operation would assign as local at one or more locations in the code template that correspond to when the value would be calculated; and
add instructions to read the local variable declarations instead of the portion of shared state.

### Claim 7 (depends on 1)

The system of claim 1, wherein to add the portion of code in the target programming language into the set of loops that prevents execution of further code placed in the code template for additional valid traces, the program instructions cause the at least one processor to:
adding a guard for a conditional assignment reached in the valid trace responsive to the conditional assignment being reached via an if statement of the conditional assignment; or
adding a negation of a guard for a conditional assignment reached in the valid trace responsive to the conditional assignment being reached via an else statement of the conditional assignment.

### Claim 8

A method, comprising:
generating a plurality of traces of a plurality of operations specified in an input that access data between a start node and an end node, wherein the plurality of operations comprise one or more put operations using a put index variable to set a value in an entry in an array and one or more get operations using a get index variable to obtain the value from the entry in the array;
based on the plurality of traces, generating a code template in a target programming language to test the plurality of operations of the plurality of traces, wherein the code template:
identifying a valid trace in the plurality of traces between the start node and the end node by pairing corresponding ones of the one or more put operations and the one or more get operations and testing for equivalence of index values calculated for the put index variable and the get index variable in respective contexts of the put operations and the get operations, wherein the pairing of the corresponding put operations and the get operations and the respective contexts are determined according to at least a forward pass and a backward pass respectively performed over individual ones of the plurality of traces to construct a set of loops and loop index substitutions that test for equivalence of the index values in the paired corresponding ones of the one or more put operations and the one or more get operations of the valid trace; and
for the identified valid trace, adding a portion of code in the target programming language into the set of loops that prevents execution of further code placed in the code template for additional valid traces.

### Claim 9 (depends on 8)

The method of claim 8, wherein the input is a probabilistic programming language and wherein the target programming language is a non-probabilistic programming language.

### Claim 10 (depends on 8)

The method of claim 8, wherein the portion of code in the target language comprises one or more additional loops that act as guard loops.

### Claim 11 (depends on 8)

The method of claim 8, wherein the one or more additional loops are described in guard description data object created as part of generating the code template.

### Claim 12 (depends on 11)

The method of claim 11, wherein a check is performed when creating the guard description object to determine whether more than one constraint trace exists.

### Claim 13 (depends on 8)

The method of claim 8, wherein generating the code template in the target programming language comprises:
identifying a put operation of the plurality of operations in a trace that updates a portion of shared state; and
instead of adding instructions to modify the shared state, adding a local variable declaration to store the value the put operation would assign as local at one or more locations in the code template that correspond to when the value would be calculated; and
adding instructions to read the local variable declarations instead of the portion of shared state.

### Claim 14 (depends on 8)

The method of claim 8, wherein adding the portion of code in the target programming language into the set of loops that prevents execution of further code placed in the code template for additional valid traces comprises:
adding a guard for a conditional assignment reached in the valid trace responsive to the conditional assignment being reached via an if statement of the conditional assignment; or
adding a negation of a guard for a conditional assignment reached in the valid trace responsive to the conditional assignment being reached via an else statement of the conditional assignment.

### Claim 15

One or more, non-transitory, computer-readable storage media, storing program instructions that when executed on or across one or more computing devices, cause the one or more computing devices to implement:
generating a plurality of traces of a plurality of operations specified in an input that access data between a start node and an end node, wherein the plurality of operations comprise one or more put operations using a put index variable to set a value in an entry in an array and one or more get operations using a get index variable to obtain the value from the entry in the array;
based on the plurality of traces, generating a code template in the target programming language to test the plurality of operations of the plurality of traces, wherein the code template:
identifying a valid trace in the plurality of traces between the start node and the end node by pairing corresponding ones of the one or more put operations and the one or more get operations and testing for equivalence of index values calculated for the put index variable and the get index variable in respective contexts of the put operations and the get operations, wherein the pairing of the corresponding put operations and the get operations and the respective contexts are determined according to at least a forward pass and a backward pass respectively performed over individual ones of the plurality of traces to construct a set of loops and loop index substitutions that test for equivalence of the index values in the paired corresponding ones of the one or more put operations and the one or more get operations of the valid trace; and
for the identified valid trace, adding a portion of code in the target programming language into the set of loops that prevents execution of further code placed in the code template for additional valid traces.

### Claim 16 (depends on 15)

The one or more non-transitory, computer-readable storage media of claim 15, wherein the input is a source programming language.

### Claim 17 (depends on 15)

The one or more non-transitory, computer-readable storage media of claim 15, wherein the portion of code in the target language comprises one or more additional loops that act as guard loops.

### Claim 18 (depends on 15)

The one or more non-transitory, computer-readable storage media of claim 15, wherein the one or more additional loops are described in guard description data object created as part of generating the code template.

### Claim 19 (depends on 15)

The one or more non-transitory, computer-readable storage media of claim 15, wherein, in generating the code template in the target programming language, the programming instructions cause the one or more computing devices to implement:
identifying a put operation of the plurality of operations in a trace that updates a portion of shared state; and
instead of adding instructions to modify the shared state, adding a local variable declaration to store the value the put operation would assign as local at one or more locations in the code template that correspond to when the value would be calculated; and
adding instructions to read the local variable declarations instead of the portion of shared state.

### Claim 20 (depends on 15)

The one or more non-transitory, computer-readable storage media of claim 15, wherein, in adding the portion of code in the target programming language into the set of loops that prevents execution of further code placed in the code template for additional valid traces, the program instructions cause the one or more computing devices to implement:
adding a guard for a conditional assignment reached in the valid trace responsive to the conditional assignment being reached via an if statement of the conditional assignment; or
adding a negation of a guard for a conditional assignment reached in the valid trace responsive to the conditional assignment being reached via an else statement of the conditional assignment.
