Source Code Logic Inference via AST Vectorization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing code analysis techniques face challenges in accurately understanding and extracting logic from source code, especially in legacy languages like COBOL, due to complexity and the lack of effective automation, leading to dependency on subject matter experts and increased time in modernization processes.
Innovation Solution
A machine learning-based system that parses source code into a language-independent repository, creates logical blocks, generates capsules based on leaf nodes and sequential distances, calculates optimized hyperparameters, trains a machine learning model, and predicts code functionality using vectorization techniques to infer code logic, reducing reliance on experts and enhancing automation.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If manual techniques are used for code analysis, then code understanding accuracy can be maintained through expert knowledge, but time consumption and error rates increase significantly
Solution Approach 1:
The system enables code analysis to be performed automatically by machine learning models without requiring manual expert intervention. The ML models process source code, generate abstract syntax trees, and extract logic independently, making the system self-sufficient while maintaining accuracy through trained algorithms rather than human experts.
Solution Approach 2:
The patent replaces manual mechanical analysis by experts with automated machine learning-based analysis. The system uses ML models to parse code, generate ASTs, and infer logic, substituting human cognitive processes with computational algorithms that operate faster and without fatigue.
2Loss of time
If automated code analysis systems are implemented, then time consumption is reduced, but accuracy deteriorates due to inability to understand complex coding styles and variable purposes
Solution Approach 1:
The system segments the code analysis process into distinct stages: parsing source code into abstract syntax trees, generating logical blocks from AST nodes, creating capsules representing code elements, and inferring logic through machine learning. This segmentation allows each component to specialize in specific aspects of code understanding, improving overall accuracy while maintaining automation.
Solution Approach 2:
The patent introduces abstract syntax trees as an intermediary representation between source code and logic inference. The AST serves as a structured intermediate form that captures code semantics while being machine-processable, bridging the gap between raw code and automated analysis, thereby improving accuracy without sacrificing automation.
3Measurement precision
If graph-based techniques are used to capture code semantics, then semantic information accuracy improves, but system complexity and noise during learning increase
Solution Approach 1:
The system extracts essential semantic information from code by generating abstract syntax trees that capture the hierarchical structure and logical relationships. Instead of using complex graph representations, the patent extracts and processes only the necessary semantic elements through AST nodes and logical blocks, reducing system complexity while maintaining semantic accuracy.
4Productivity
If tree-based convolutional neural networks are used for code processing, then processing efficiency improves, but semantic dependency capture accuracy deteriorates
Solution Approach 1:
The patent employs dynamic capsule routing mechanisms that adaptively process code elements based on their relationships. The system dynamically creates and routes capsules through multiple layers, allowing the network to flexibly capture semantic dependencies while maintaining efficient processing through the tree-based capsule architecture rather than static convolutional operations.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
The application source code generally does not have any uniformity, defined executional sequence or documented information on the underlying complexity. It varies based on the requirement, domain and from each developer to developer. The slightest mistake in analyzing / modifying it will have a huge impact for the existing functionalities and interfacing applications. A method and system for inferencing code logic out of an application source code has been provided. This starts with the conversion of the raw form of code into logically linked blocks. These logical blocks in-turn represent standard meaningful representation of the code logic and are processed into vectors. Further, the processed vectors are fed into pre-trained machine learning models from which the code logic is predicted. Further the system and method can also be extended to various other applications in application maintenance, aiding the SME, inducting a new resource, documentation etc.