Open Stevengre opened 4 months ago
Merging Effect: Reduce the number of generated rules through anti-unification and minimize the splits caused by these rules.
Intuitive Understanding and Explanation: Automatically obtain a specification for a function from an external call perspective, thereby omitting the detailed implementation steps. For this purpose, each generated rule should ideally encompass as much depth as possible. Merging can combine the split edges to increase the depth density of each generated rule.
Initial Heuristic provided by @ehildenb :
def is_mergable(ct1: CTerm, ct2: CTerm) -> bool:
status_code_1 = ct1.cell('STATUSCODE_CELL')
status_code_2 = ct2.cell('STATUSCODE_CELL')
program_1 = ct1.cell('PROGRAM_CELL')
program_2 = ct2.cell('PROGRAM_CELL')
if type(status_code_1) is KApply and type(status_code_2) is KApply and type(program_1) is KToken and type(program_2) is KToken:
return status_code_1 == status_code_2 and program_1 == program_2:
raise ValueError(f'Attempted to merge nodes with non-concrete <statusCode> or <program>: {(ct1, ct2)}')
Heuristic Validation:
Case: ActivateNextStateTest.testActivateNextStateTermination
Validation Steps:
Further Exploration:
Check Heuristic:
Randomly select two branches (270 -> 67 and 271 -> 63) and examine the
67:
<statusCode> EVMC_SUCCESS </statusCode>
<program> test%kontrol%ActivateNextStateTest </program>
63:
<statusCode> EVMC_SUCCESS </statusCode>
<program> test%kontrol%ActivateNextStateTest </program>
270
<statusCode> EVMC_SUCCESS </statusCode>
<program> test%kontrol%ActivateNextStateTest </program>
<program> contracts%DualGovernance </program>
271
<statusCode> EVMC_SUCCESS </statusCode>
<program> test%kontrol%ActivateNextStateTest </program>
<program> contracts%DualGovernance </program>
Check Result:
I do not believe these are the nodes we want to merge for the following reasons:
Additionally, the
To make summarization and minimize_proof more useful, we need to ensure that the generated rules can be reused across contracts. This means that the generated rules should correspond to the functions of a contract, serving as either a mock or a specification for the contract. For example, a summarized kcfg should be either a summary of contracts%DualGovernance or a specific function within contracts%DualGovernance, rather than a summary of the test-suite.
For instance, for dualGovernance.activateNextState(), we should:
The method to obtain the rule in step 1 is as follows:
Currently, we have implemented a language-agnostic
merge_node
(K#4425). However, applying it to practical scenarios and solving problems like Kontrol#448 still requires addressing the following challenges:Some answers to the above issues:
Here are some small steps/tasks that I plan to complete next: