@eagleoutice/flowr 2.4.5 → 2.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -22
- package/abstract-interpretation/data-frame/absint-visitor.js +2 -3
- package/abstract-interpretation/data-frame/dataframe-domain.d.ts +40 -0
- package/abstract-interpretation/data-frame/dataframe-domain.js +62 -0
- package/abstract-interpretation/data-frame/domain.js +1 -1
- package/abstract-interpretation/domains/abstract-domain.d.ts +56 -0
- package/abstract-interpretation/domains/abstract-domain.js +19 -0
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +43 -0
- package/abstract-interpretation/domains/bounded-set-domain.js +121 -0
- package/abstract-interpretation/domains/interval-domain.d.ts +61 -0
- package/abstract-interpretation/domains/interval-domain.js +208 -0
- package/abstract-interpretation/domains/lattice.d.ts +62 -0
- package/abstract-interpretation/domains/lattice.js +12 -0
- package/abstract-interpretation/domains/positive-interval-domain.d.ts +32 -0
- package/abstract-interpretation/domains/positive-interval-domain.js +91 -0
- package/abstract-interpretation/domains/product-domain.d.ts +37 -0
- package/abstract-interpretation/domains/product-domain.js +133 -0
- package/abstract-interpretation/domains/set-bounded-set-domain.d.ts +43 -0
- package/abstract-interpretation/domains/set-bounded-set-domain.js +164 -0
- package/abstract-interpretation/domains/singleton-domain.d.ts +38 -0
- package/abstract-interpretation/domains/singleton-domain.js +115 -0
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +32 -0
- package/abstract-interpretation/domains/state-abstract-domain.js +179 -0
- package/package.json +1 -1
- package/util/version.js +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ It offers a wide variety of features, for example:
|
|
|
24
24
|
|
|
25
25
|
```shell
|
|
26
26
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
27
|
-
flowR repl using flowR v2.4.
|
|
27
|
+
flowR repl using flowR v2.4.6, R v4.5.0 (r-shell engine)
|
|
28
28
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ It offers a wide variety of features, for example:
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
```text
|
|
36
|
-
Query: [;1mlinter[0m (
|
|
36
|
+
Query: [;1mlinter[0m (2 ms)
|
|
37
37
|
╰ **Deprecated Functions** (deprecated-functions):
|
|
38
38
|
╰ _Metadata_: <code>{"totalDeprecatedCalls":0,"totalDeprecatedFunctionDefinitions":0,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
39
39
|
╰ **File Path Validity** (file-path-validity):
|
|
@@ -45,7 +45,7 @@ It offers a wide variety of features, for example:
|
|
|
45
45
|
╰ **Absolute Paths** (absolute-file-paths):
|
|
46
46
|
╰ certain:
|
|
47
47
|
╰ Path `/root/x.txt` at 1.1-23
|
|
48
|
-
╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":
|
|
48
|
+
╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
49
49
|
╰ **Unused Definitions** (unused-definitions):
|
|
50
50
|
╰ _Metadata_: <code>{"totalConsidered":0,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
51
51
|
╰ **Naming Convention** (naming-convention):
|
|
@@ -56,7 +56,7 @@ It offers a wide variety of features, for example:
|
|
|
56
56
|
╰ _Metadata_: <code>{"consideredNodes":5,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
57
57
|
╰ **Useless Loops** (useless-loop):
|
|
58
58
|
╰ _Metadata_: <code>{"numOfUselessLoops":0,"searchTimeMs":0,"processTimeMs":0}</code>
|
|
59
|
-
[;3mAll queries together required ≈
|
|
59
|
+
[;3mAll queries together required ≈2 ms (1ms accuracy, total 8 ms)[0m[0m
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
|
|
@@ -78,34 +78,34 @@ It offers a wide variety of features, for example:
|
|
|
78
78
|
|
|
79
79
|
_Results (prettified and summarized):_
|
|
80
80
|
|
|
81
|
-
Query: **linter** (
|
|
81
|
+
Query: **linter** (13 ms)\
|
|
82
82
|
╰ **Deprecated Functions** (deprecated-functions):\
|
|
83
83
|
╰ _Metadata_: <code>{"totalDeprecatedCalls":0,"totalDeprecatedFunctionDefinitions":0,"searchTimeMs":2,"processTimeMs":0}</code>\
|
|
84
84
|
╰ **File Path Validity** (file-path-validity):\
|
|
85
85
|
╰ certain:\
|
|
86
86
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
87
|
-
╰ _Metadata_: <code>{"totalReads":1,"totalUnknown":0,"totalWritesBeforeAlways":0,"totalValid":0,"searchTimeMs":
|
|
87
|
+
╰ _Metadata_: <code>{"totalReads":1,"totalUnknown":0,"totalWritesBeforeAlways":0,"totalValid":0,"searchTimeMs":4,"processTimeMs":1}</code>\
|
|
88
88
|
╰ **Seeded Randomness** (seeded-randomness):\
|
|
89
|
-
╰ _Metadata_: <code>{"consumerCalls":0,"callsWithFunctionProducers":0,"callsWithAssignmentProducers":0,"callsWithNonConstantProducers":0,"searchTimeMs":
|
|
89
|
+
╰ _Metadata_: <code>{"consumerCalls":0,"callsWithFunctionProducers":0,"callsWithAssignmentProducers":0,"callsWithNonConstantProducers":0,"searchTimeMs":0,"processTimeMs":0}</code>\
|
|
90
90
|
╰ **Absolute Paths** (absolute-file-paths):\
|
|
91
91
|
╰ certain:\
|
|
92
92
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
93
93
|
╰ _Metadata_: <code>{"totalConsidered":1,"totalUnknown":0,"searchTimeMs":2,"processTimeMs":0}</code>\
|
|
94
94
|
╰ **Unused Definitions** (unused-definitions):\
|
|
95
|
-
╰ _Metadata_: <code>{"totalConsidered":0,"searchTimeMs":0,"processTimeMs":
|
|
95
|
+
╰ _Metadata_: <code>{"totalConsidered":0,"searchTimeMs":0,"processTimeMs":1}</code>\
|
|
96
96
|
╰ **Naming Convention** (naming-convention):\
|
|
97
|
-
╰ _Metadata_: <code>{"numMatches":0,"numBreak":0,"searchTimeMs":0,"processTimeMs":
|
|
97
|
+
╰ _Metadata_: <code>{"numMatches":0,"numBreak":0,"searchTimeMs":0,"processTimeMs":0}</code>\
|
|
98
98
|
╰ **Dataframe Access Validation** (dataframe-access-validation):\
|
|
99
99
|
╰ _Metadata_: <code>{"numOperations":0,"numAccesses":0,"totalAccessed":0,"searchTimeMs":0,"processTimeMs":2}</code>\
|
|
100
100
|
╰ **Dead Code** (dead-code):\
|
|
101
101
|
╰ _Metadata_: <code>{"consideredNodes":5,"searchTimeMs":1,"processTimeMs":0}</code>\
|
|
102
102
|
╰ **Useless Loops** (useless-loop):\
|
|
103
103
|
╰ _Metadata_: <code>{"numOfUselessLoops":0,"searchTimeMs":0,"processTimeMs":0}</code>\
|
|
104
|
-
_All queries together required ≈
|
|
104
|
+
_All queries together required ≈13 ms (1ms accuracy, total 210 ms)_
|
|
105
105
|
|
|
106
106
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
107
107
|
|
|
108
|
-
The analysis required
|
|
108
|
+
The analysis required _210.1 ms_ (including parsing and normalization and the query) within the generation environment.
|
|
109
109
|
|
|
110
110
|
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
|
|
111
111
|
Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
|
|
@@ -144,8 +144,8 @@ It offers a wide variety of features, for example:
|
|
|
144
144
|
"totalUnknown": 0,
|
|
145
145
|
"totalWritesBeforeAlways": 0,
|
|
146
146
|
"totalValid": 0,
|
|
147
|
-
"searchTimeMs":
|
|
148
|
-
"processTimeMs":
|
|
147
|
+
"searchTimeMs": 4,
|
|
148
|
+
"processTimeMs": 1
|
|
149
149
|
}
|
|
150
150
|
},
|
|
151
151
|
"seeded-randomness": {
|
|
@@ -155,7 +155,7 @@ It offers a wide variety of features, for example:
|
|
|
155
155
|
"callsWithFunctionProducers": 0,
|
|
156
156
|
"callsWithAssignmentProducers": 0,
|
|
157
157
|
"callsWithNonConstantProducers": 0,
|
|
158
|
-
"searchTimeMs":
|
|
158
|
+
"searchTimeMs": 0,
|
|
159
159
|
"processTimeMs": 0
|
|
160
160
|
}
|
|
161
161
|
},
|
|
@@ -184,7 +184,7 @@ It offers a wide variety of features, for example:
|
|
|
184
184
|
".meta": {
|
|
185
185
|
"totalConsidered": 0,
|
|
186
186
|
"searchTimeMs": 0,
|
|
187
|
-
"processTimeMs":
|
|
187
|
+
"processTimeMs": 1
|
|
188
188
|
}
|
|
189
189
|
},
|
|
190
190
|
"naming-convention": {
|
|
@@ -193,7 +193,7 @@ It offers a wide variety of features, for example:
|
|
|
193
193
|
"numMatches": 0,
|
|
194
194
|
"numBreak": 0,
|
|
195
195
|
"searchTimeMs": 0,
|
|
196
|
-
"processTimeMs":
|
|
196
|
+
"processTimeMs": 0
|
|
197
197
|
}
|
|
198
198
|
},
|
|
199
199
|
"dataframe-access-validation": {
|
|
@@ -224,11 +224,11 @@ It offers a wide variety of features, for example:
|
|
|
224
224
|
}
|
|
225
225
|
},
|
|
226
226
|
".meta": {
|
|
227
|
-
"timing":
|
|
227
|
+
"timing": 13
|
|
228
228
|
}
|
|
229
229
|
},
|
|
230
230
|
".meta": {
|
|
231
|
-
"timing":
|
|
231
|
+
"timing": 13
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
```
|
|
@@ -295,7 +295,7 @@ It offers a wide variety of features, for example:
|
|
|
295
295
|
|
|
296
296
|
```shell
|
|
297
297
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
298
|
-
flowR repl using flowR v2.4.
|
|
298
|
+
flowR repl using flowR v2.4.6, R v4.5.0 (r-shell engine)
|
|
299
299
|
R> :slicer test/testfiles/example.R --criterion "11@sum"
|
|
300
300
|
```
|
|
301
301
|
|
|
@@ -342,7 +342,7 @@ It offers a wide variety of features, for example:
|
|
|
342
342
|
|
|
343
343
|
|
|
344
344
|
* 🚀 **fast data- and control-flow graphs**\
|
|
345
|
-
Within just <i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
345
|
+
Within just <i><span title="This measurement is automatically fetched from the latest benchmark!">135.6 ms</span></i> (as of Aug 20, 2025),
|
|
346
346
|
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
|
|
347
347
|
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for more details on the dataflow graph.
|
|
348
348
|
|
|
@@ -378,7 +378,7 @@ It offers a wide variety of features, for example:
|
|
|
378
378
|
|
|
379
379
|
```shell
|
|
380
380
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
381
|
-
flowR repl using flowR v2.4.
|
|
381
|
+
flowR repl using flowR v2.4.6, R v4.5.0 (r-shell engine)
|
|
382
382
|
R> :dataflow* test/testfiles/example.R
|
|
383
383
|
```
|
|
384
384
|
|
|
@@ -679,7 +679,7 @@ It offers a wide variety of features, for example:
|
|
|
679
679
|
```
|
|
680
680
|
|
|
681
681
|
|
|
682
|
-
(The analysis required _14.
|
|
682
|
+
(The analysis required _14.2 ms_ (including parse and normalize, using the [r-shell](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment.)
|
|
683
683
|
|
|
684
684
|
|
|
685
685
|
|
|
@@ -137,7 +137,7 @@ class DataFrameShapeInferenceVisitor extends semantic_cfg_guided_visitor_1.Seman
|
|
|
137
137
|
}
|
|
138
138
|
/** Get all AST nodes for the predecessor vertices that are leaf nodes and exit vertices */
|
|
139
139
|
getPredecessorNodes(vertexId) {
|
|
140
|
-
return this.config.controlFlow.graph.outgoingEdges(vertexId)?.keys() // outgoing dependency edges are incoming CFG edges
|
|
140
|
+
return [...this.config.controlFlow.graph.outgoingEdges(vertexId)?.keys() ?? []] // outgoing dependency edges are incoming CFG edges
|
|
141
141
|
.map(id => this.getCfgVertex(id))
|
|
142
142
|
.flatMap(vertex => {
|
|
143
143
|
if (vertex === undefined) {
|
|
@@ -150,8 +150,7 @@ class DataFrameShapeInferenceVisitor extends semantic_cfg_guided_visitor_1.Seman
|
|
|
150
150
|
return [this.getNormalizedAst((0, control_flow_graph_1.getVertexRootId)(vertex))];
|
|
151
151
|
}
|
|
152
152
|
})
|
|
153
|
-
.filter(assert_1.isNotUndefined)
|
|
154
|
-
.toArray() ?? [];
|
|
153
|
+
.filter(assert_1.isNotUndefined);
|
|
155
154
|
}
|
|
156
155
|
shouldWiden(vertex) {
|
|
157
156
|
return (this.visited.get(vertex.id) ?? 0) >= this.config.flowrConfig.abstractInterpretation.dataFrame.wideningThreshold;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AbstractDomain } from '../domains/abstract-domain';
|
|
2
|
+
import { PosIntervalDomain } from '../domains/positive-interval-domain';
|
|
3
|
+
import { ProductDomain } from '../domains/product-domain';
|
|
4
|
+
import { SetBoundedSetDomain } from '../domains/set-bounded-set-domain';
|
|
5
|
+
import { StateAbstractDomain } from '../domains/state-abstract-domain';
|
|
6
|
+
/** The type of the abstract product representing the shape of data frames */
|
|
7
|
+
export type AbstractDataFrameShape = {
|
|
8
|
+
colnames: SetBoundedSetDomain<string>;
|
|
9
|
+
cols: PosIntervalDomain;
|
|
10
|
+
rows: PosIntervalDomain;
|
|
11
|
+
};
|
|
12
|
+
/** The type of abstract values of a sub abstract domain (shape property) of the data frame shape product */
|
|
13
|
+
type DataFrameShapeProperty<Property extends keyof AbstractDataFrameShape> = AbstractDataFrameShape[Property] extends AbstractDomain<unknown, unknown, unknown, unknown, infer Lift> ? Lift : never;
|
|
14
|
+
/**
|
|
15
|
+
* The data frame abstract domain as product domain of a column names domain, column count domain, and row count domain.
|
|
16
|
+
*/
|
|
17
|
+
export declare class DataFrameDomain extends ProductDomain<AbstractDataFrameShape> {
|
|
18
|
+
constructor(value: AbstractDataFrameShape, maxColNames?: number);
|
|
19
|
+
create(value: AbstractDataFrameShape, maxColNames?: number): DataFrameDomain;
|
|
20
|
+
/**
|
|
21
|
+
* The current abstract value of the column names domain.
|
|
22
|
+
*/
|
|
23
|
+
get colnames(): DataFrameShapeProperty<'colnames'>;
|
|
24
|
+
/**
|
|
25
|
+
* The current abstract value of the column count domain.
|
|
26
|
+
*/
|
|
27
|
+
get cols(): DataFrameShapeProperty<'cols'>;
|
|
28
|
+
/**
|
|
29
|
+
* The current abstract value of the row count domain.
|
|
30
|
+
*/
|
|
31
|
+
get rows(): DataFrameShapeProperty<'rows'>;
|
|
32
|
+
static bottom(maxColNames?: number): DataFrameDomain;
|
|
33
|
+
static top(maxColNames?: number): DataFrameDomain;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The data frame state abstract domain as state abstract domain mapping AST node IDs to inferred abstract data frame shapes.
|
|
37
|
+
*/
|
|
38
|
+
export declare class DateFrameStateDomain extends StateAbstractDomain<DataFrameDomain> {
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateFrameStateDomain = exports.DataFrameDomain = void 0;
|
|
4
|
+
const positive_interval_domain_1 = require("../domains/positive-interval-domain");
|
|
5
|
+
const product_domain_1 = require("../domains/product-domain");
|
|
6
|
+
const set_bounded_set_domain_1 = require("../domains/set-bounded-set-domain");
|
|
7
|
+
const state_abstract_domain_1 = require("../domains/state-abstract-domain");
|
|
8
|
+
/**
|
|
9
|
+
* The data frame abstract domain as product domain of a column names domain, column count domain, and row count domain.
|
|
10
|
+
*/
|
|
11
|
+
class DataFrameDomain extends product_domain_1.ProductDomain {
|
|
12
|
+
constructor(value, maxColNames) {
|
|
13
|
+
super({
|
|
14
|
+
colnames: new set_bounded_set_domain_1.SetBoundedSetDomain(value.colnames.value, maxColNames),
|
|
15
|
+
cols: new positive_interval_domain_1.PosIntervalDomain(value.cols.value),
|
|
16
|
+
rows: new positive_interval_domain_1.PosIntervalDomain(value.rows.value)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
create(value, maxColNames) {
|
|
20
|
+
return new DataFrameDomain(value, maxColNames);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The current abstract value of the column names domain.
|
|
24
|
+
*/
|
|
25
|
+
get colnames() {
|
|
26
|
+
return this.value.colnames.value;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The current abstract value of the column count domain.
|
|
30
|
+
*/
|
|
31
|
+
get cols() {
|
|
32
|
+
return this.value.cols.value;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The current abstract value of the row count domain.
|
|
36
|
+
*/
|
|
37
|
+
get rows() {
|
|
38
|
+
return this.value.rows.value;
|
|
39
|
+
}
|
|
40
|
+
static bottom(maxColNames) {
|
|
41
|
+
return new DataFrameDomain({
|
|
42
|
+
colnames: set_bounded_set_domain_1.SetBoundedSetDomain.bottom(maxColNames),
|
|
43
|
+
cols: positive_interval_domain_1.PosIntervalDomain.bottom(),
|
|
44
|
+
rows: positive_interval_domain_1.PosIntervalDomain.bottom()
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
static top(maxColNames) {
|
|
48
|
+
return new DataFrameDomain({
|
|
49
|
+
colnames: set_bounded_set_domain_1.SetBoundedSetDomain.top(maxColNames),
|
|
50
|
+
cols: positive_interval_domain_1.PosIntervalDomain.top(),
|
|
51
|
+
rows: positive_interval_domain_1.PosIntervalDomain.top()
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.DataFrameDomain = DataFrameDomain;
|
|
56
|
+
/**
|
|
57
|
+
* The data frame state abstract domain as state abstract domain mapping AST node IDs to inferred abstract data frame shapes.
|
|
58
|
+
*/
|
|
59
|
+
class DateFrameStateDomain extends state_abstract_domain_1.StateAbstractDomain {
|
|
60
|
+
}
|
|
61
|
+
exports.DateFrameStateDomain = DateFrameStateDomain;
|
|
62
|
+
//# sourceMappingURL=dataframe-domain.js.map
|
|
@@ -105,7 +105,7 @@ function subtractColNames(set1, set2) {
|
|
|
105
105
|
* However, this speeds up the iteration in larger loops significantly, as we are over-approximating the column names much earlier.
|
|
106
106
|
*/
|
|
107
107
|
function wideningColNames(set1, set2) {
|
|
108
|
-
return leqColNames(
|
|
108
|
+
return leqColNames(set2, set1) ? set1 : exports.ColNamesTop;
|
|
109
109
|
}
|
|
110
110
|
/** Checks whether an abstract value of the column names domain satisfies a column name */
|
|
111
111
|
function satisfiesColsNames(set, value) {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Bottom, Lattice, Top } from './lattice';
|
|
2
|
+
/**
|
|
3
|
+
* The default limit of inferred constraints in {@link AbstractDomain|AbstractDomains}.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_INFERENCE_LIMIT = 50;
|
|
6
|
+
/**
|
|
7
|
+
* An abstract domain as complete lattice with a widening operator, narrowing operator, concretization function, and abstraction function.
|
|
8
|
+
* @template Concrete - Type of an concrete element of the concrete domain for the abstract domain
|
|
9
|
+
* @template Abstract - Type of an abstract element of the abstract domain representing possible elements (may exclude `Top` and `Bot`)
|
|
10
|
+
* @template Top - Type of the Top element of the abstract domain representing all possible elements (defaults to {@link Top})
|
|
11
|
+
* @template Bot - Type of the Bottom element of the abstract domain representing no possible elements (defaults to {@link Bottom})
|
|
12
|
+
* @template Lift - Type of the abstract elements of the abstract domain (defaults to `Abstract` or `Top` or `Bot`)
|
|
13
|
+
*/
|
|
14
|
+
export interface AbstractDomain<Concrete, Abstract, Top = typeof Top, Bot = typeof Bottom, Lift extends Abstract | Top | Bot = Abstract | Top | Bot> extends Lattice<Abstract, Top, Bot, Lift> {
|
|
15
|
+
/**
|
|
16
|
+
* Widens the current abstract value with another abstract value as a sound over-approximation of the join (least upper bound) for fixpoint iteration acceleration.
|
|
17
|
+
*/
|
|
18
|
+
widen(other: AbstractDomain<Concrete, Abstract, Top, Bot>): AbstractDomain<Concrete, Abstract, Top, Bot>;
|
|
19
|
+
/**
|
|
20
|
+
* Narrows the current abstract value with another abstract value as a sound over-approximation of the meet (greatest lower bound) to refine the value after widening.
|
|
21
|
+
*/
|
|
22
|
+
narrow(other: AbstractDomain<Concrete, Abstract, Top, Bot>): AbstractDomain<Concrete, Abstract, Top, Bot>;
|
|
23
|
+
/**
|
|
24
|
+
* Maps the current abstract value into a set of possible concrete values as concretization function of the abstract domain.
|
|
25
|
+
* The result should be `Top` if the number of concrete values would reach the `limit` or the resulting set would have infinite many elements.
|
|
26
|
+
*/
|
|
27
|
+
concretize(limit?: number): ReadonlySet<Concrete> | typeof Top;
|
|
28
|
+
/**
|
|
29
|
+
* Maps a set of possible concrete values into an abstract value as abstraction function of the abstract domain (should additionally be provided as static function).
|
|
30
|
+
*/
|
|
31
|
+
abstract(concrete: ReadonlySet<Concrete> | typeof Top): AbstractDomain<Concrete, Abstract, Top, Bot>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The type of the concrete domain of an abstract domain.
|
|
35
|
+
* @template Domain - The abstract domain to get the concrete domain type for
|
|
36
|
+
*/
|
|
37
|
+
export type ConcreteDomain<Domain extends AbstractDomain<unknown, unknown, unknown, unknown>> = Domain extends AbstractDomain<infer Concrete, unknown, unknown, unknown> ? Concrete : never;
|
|
38
|
+
/**
|
|
39
|
+
* The type of the Top element (greatest element) of an abstract domain.
|
|
40
|
+
* @template Domain - The abstract domain to get the Top element type for
|
|
41
|
+
*/
|
|
42
|
+
export type AbstractDomainTop<Domain extends AbstractDomain<unknown, unknown, unknown, unknown>> = Domain extends AbstractDomain<unknown, unknown, infer Top, unknown> ? Top : never;
|
|
43
|
+
/**
|
|
44
|
+
* The type of the Bottom element (least element) of an abstract domain.
|
|
45
|
+
* @template Domain - The abstract domain to get the Bottom element type for
|
|
46
|
+
*/
|
|
47
|
+
export type AbstractDomainBottom<Domain extends AbstractDomain<unknown, unknown, unknown, unknown>> = Domain extends AbstractDomain<unknown, unknown, unknown, infer Bot> ? Bot : never;
|
|
48
|
+
/**
|
|
49
|
+
* The type of the abstract values of an abstract domain (including the Top and Bottom element).
|
|
50
|
+
* @template Domain - The abstract domain to get the abstract value type for
|
|
51
|
+
*/
|
|
52
|
+
export type AbstractDomainValue<Domain extends AbstractDomain<unknown, unknown, unknown, unknown>> = Domain extends AbstractDomain<unknown, infer Value, infer Top, infer Bot> ? Value | Top | Bot : never;
|
|
53
|
+
/**
|
|
54
|
+
* Converts an element of an abstract domain into a string.
|
|
55
|
+
*/
|
|
56
|
+
export declare function domainElementToString(value: AbstractDomain<unknown, unknown, unknown, unknown> | unknown): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_INFERENCE_LIMIT = void 0;
|
|
4
|
+
exports.domainElementToString = domainElementToString;
|
|
5
|
+
/**
|
|
6
|
+
* The default limit of inferred constraints in {@link AbstractDomain|AbstractDomains}.
|
|
7
|
+
*/
|
|
8
|
+
exports.DEFAULT_INFERENCE_LIMIT = 50;
|
|
9
|
+
/**
|
|
10
|
+
* Converts an element of an abstract domain into a string.
|
|
11
|
+
*/
|
|
12
|
+
function domainElementToString(value) {
|
|
13
|
+
if (typeof value === 'object' && value !== null && value.toString !== Object.prototype.toString) {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
15
|
+
return value.toString();
|
|
16
|
+
}
|
|
17
|
+
return JSON.stringify(value);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=abstract-domain.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AbstractDomain } from './abstract-domain';
|
|
2
|
+
import { Top } from './lattice';
|
|
3
|
+
/** The type of the actual values of the bounded set domain as set */
|
|
4
|
+
export type BoundedSetValue<T> = ReadonlySet<T>;
|
|
5
|
+
/** The type of the Top element of the bounded set domain as {@link Top} symbol */
|
|
6
|
+
export type BoundedSetTop = typeof Top;
|
|
7
|
+
/** The type of the Bottom element of the bounded set domain as empty set */
|
|
8
|
+
export type BoundedSetBottom = ReadonlySet<never>;
|
|
9
|
+
/** The type of the abstract values of the bounded set domain that are Top, Bottom, or actual values */
|
|
10
|
+
export type BoundedSetLift<T> = BoundedSetValue<T> | BoundedSetTop | BoundedSetBottom;
|
|
11
|
+
/**
|
|
12
|
+
* The bounded set abstract domain as sets of possible values bounded by a `limit` indicating the maximum number of inferred values.
|
|
13
|
+
* The Bottom element is defined as the empty set and the Top element is defined as {@link Top} symbol.
|
|
14
|
+
* @template T - Type of the values in the abstract domain
|
|
15
|
+
* @template Value - Type of the constraint in the abstract domain (Top, Bottom, or an actual value)
|
|
16
|
+
*/
|
|
17
|
+
export declare class BoundedSetDomain<T, Value extends BoundedSetLift<T> = BoundedSetLift<T>> implements AbstractDomain<T, BoundedSetValue<T>, BoundedSetTop, BoundedSetBottom, Value> {
|
|
18
|
+
private readonly limit;
|
|
19
|
+
private _value;
|
|
20
|
+
constructor(value: Value, limit?: number);
|
|
21
|
+
get value(): Value;
|
|
22
|
+
static top<T>(limit?: number): BoundedSetDomain<T, BoundedSetTop>;
|
|
23
|
+
static bottom<T>(limit?: number): BoundedSetDomain<T, BoundedSetBottom>;
|
|
24
|
+
static abstract<T>(concrete: ReadonlySet<T> | typeof Top, limit?: number): BoundedSetDomain<T>;
|
|
25
|
+
top(): BoundedSetDomain<T, BoundedSetTop>;
|
|
26
|
+
bottom(): BoundedSetDomain<T, BoundedSetBottom>;
|
|
27
|
+
equals(other: BoundedSetDomain<T>): boolean;
|
|
28
|
+
leq(other: BoundedSetDomain<T>): boolean;
|
|
29
|
+
join(...values: BoundedSetDomain<T>[]): BoundedSetDomain<T>;
|
|
30
|
+
meet(...values: BoundedSetDomain<T>[]): BoundedSetDomain<T>;
|
|
31
|
+
/**
|
|
32
|
+
* Subtracts another abstract value from the current abstract value by removing all elements of the other abstract value from the current abstract value.
|
|
33
|
+
*/
|
|
34
|
+
subtract(other: BoundedSetDomain<T>): BoundedSetDomain<T>;
|
|
35
|
+
widen(other: BoundedSetDomain<T>): BoundedSetDomain<T>;
|
|
36
|
+
narrow(other: BoundedSetDomain<T>): BoundedSetDomain<T>;
|
|
37
|
+
concretize(limit?: number): ReadonlySet<T> | typeof Top;
|
|
38
|
+
abstract(concrete: ReadonlySet<T> | typeof Top): BoundedSetDomain<T>;
|
|
39
|
+
toString(): string;
|
|
40
|
+
isTop(): this is BoundedSetDomain<T, BoundedSetTop>;
|
|
41
|
+
isBottom(): this is BoundedSetDomain<T, BoundedSetBottom>;
|
|
42
|
+
isValue(): this is BoundedSetDomain<T, BoundedSetValue<T>>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BoundedSetDomain = void 0;
|
|
4
|
+
const set_1 = require("../../util/collections/set");
|
|
5
|
+
const abstract_domain_1 = require("./abstract-domain");
|
|
6
|
+
const lattice_1 = require("./lattice");
|
|
7
|
+
/**
|
|
8
|
+
* The bounded set abstract domain as sets of possible values bounded by a `limit` indicating the maximum number of inferred values.
|
|
9
|
+
* The Bottom element is defined as the empty set and the Top element is defined as {@link Top} symbol.
|
|
10
|
+
* @template T - Type of the values in the abstract domain
|
|
11
|
+
* @template Value - Type of the constraint in the abstract domain (Top, Bottom, or an actual value)
|
|
12
|
+
*/
|
|
13
|
+
class BoundedSetDomain {
|
|
14
|
+
limit;
|
|
15
|
+
_value;
|
|
16
|
+
constructor(value, limit = abstract_domain_1.DEFAULT_INFERENCE_LIMIT) {
|
|
17
|
+
if (value !== lattice_1.Top) {
|
|
18
|
+
this._value = (value.size > limit ? lattice_1.Top : new Set(value));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this._value = value;
|
|
22
|
+
}
|
|
23
|
+
this.limit = limit;
|
|
24
|
+
}
|
|
25
|
+
get value() {
|
|
26
|
+
return this._value;
|
|
27
|
+
}
|
|
28
|
+
static top(limit) {
|
|
29
|
+
return new BoundedSetDomain(lattice_1.Top, limit);
|
|
30
|
+
}
|
|
31
|
+
static bottom(limit) {
|
|
32
|
+
return new BoundedSetDomain(new Set(), limit);
|
|
33
|
+
}
|
|
34
|
+
static abstract(concrete, limit) {
|
|
35
|
+
return new BoundedSetDomain(concrete, limit);
|
|
36
|
+
}
|
|
37
|
+
top() {
|
|
38
|
+
return BoundedSetDomain.top(this.limit);
|
|
39
|
+
}
|
|
40
|
+
bottom() {
|
|
41
|
+
return BoundedSetDomain.bottom(this.limit);
|
|
42
|
+
}
|
|
43
|
+
equals(other) {
|
|
44
|
+
return this.value === other.value || (this.isValue() && other.isValue() && (0, set_1.setEquals)(this.value, other.value));
|
|
45
|
+
}
|
|
46
|
+
leq(other) {
|
|
47
|
+
return other.value === lattice_1.Top || (this.isValue() && this.value.isSubsetOf(other.value));
|
|
48
|
+
}
|
|
49
|
+
join(...values) {
|
|
50
|
+
const result = new BoundedSetDomain(this.value, this.limit);
|
|
51
|
+
for (const other of values) {
|
|
52
|
+
if (result.value === lattice_1.Top || other.value === lattice_1.Top) {
|
|
53
|
+
result._value = lattice_1.Top;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const join = result.value.union(other.value);
|
|
57
|
+
result._value = join.size > this.limit ? lattice_1.Top : join;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
meet(...values) {
|
|
63
|
+
const result = new BoundedSetDomain(this.value, this.limit);
|
|
64
|
+
for (const other of values) {
|
|
65
|
+
if (result.value === lattice_1.Top) {
|
|
66
|
+
result._value = other.value;
|
|
67
|
+
}
|
|
68
|
+
else if (other.value === lattice_1.Top) {
|
|
69
|
+
result._value = result.value;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
result._value = result.value.intersection(other.value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Subtracts another abstract value from the current abstract value by removing all elements of the other abstract value from the current abstract value.
|
|
79
|
+
*/
|
|
80
|
+
subtract(other) {
|
|
81
|
+
if (this.value === lattice_1.Top) {
|
|
82
|
+
return this.top();
|
|
83
|
+
}
|
|
84
|
+
else if (other.value === lattice_1.Top) {
|
|
85
|
+
return new BoundedSetDomain(this.value, this.limit);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return new BoundedSetDomain(this.value.difference(other.value), this.limit);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
widen(other) {
|
|
92
|
+
return other.leq(this) ? new BoundedSetDomain(this.value, this.limit) : this.top();
|
|
93
|
+
}
|
|
94
|
+
narrow(other) {
|
|
95
|
+
return this.isTop() ? other : this;
|
|
96
|
+
}
|
|
97
|
+
concretize(limit = this.limit) {
|
|
98
|
+
return this.value === lattice_1.Top || this.value.size > limit ? lattice_1.Top : this.value;
|
|
99
|
+
}
|
|
100
|
+
abstract(concrete) {
|
|
101
|
+
return BoundedSetDomain.abstract(concrete, this.limit);
|
|
102
|
+
}
|
|
103
|
+
toString() {
|
|
104
|
+
if (this.value === lattice_1.Top) {
|
|
105
|
+
return '⊤';
|
|
106
|
+
}
|
|
107
|
+
const string = this.value.values().map(abstract_domain_1.domainElementToString).toArray().join(', ');
|
|
108
|
+
return `{${string}}`;
|
|
109
|
+
}
|
|
110
|
+
isTop() {
|
|
111
|
+
return this.value === lattice_1.Top;
|
|
112
|
+
}
|
|
113
|
+
isBottom() {
|
|
114
|
+
return this.value !== lattice_1.Top && this.value.size === 0;
|
|
115
|
+
}
|
|
116
|
+
isValue() {
|
|
117
|
+
return this.value !== lattice_1.Top;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.BoundedSetDomain = BoundedSetDomain;
|
|
121
|
+
//# sourceMappingURL=bounded-set-domain.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type AbstractDomain } from './abstract-domain';
|
|
2
|
+
import { Bottom, Top } from './lattice';
|
|
3
|
+
/** The type of the actual values of the interval domain as tuple of the lower and upper bound */
|
|
4
|
+
export type IntervalValue = readonly [number, number];
|
|
5
|
+
/** The type of the Top element of the interval domain as interval [-∞, +∞] from -∞ to +∞ */
|
|
6
|
+
export type IntervalTop = readonly [typeof Infinity, typeof Infinity];
|
|
7
|
+
/** The type of the Bottom element of the interval domain as {@link Bottom} symbol */
|
|
8
|
+
export type IntervalBottom = typeof Bottom;
|
|
9
|
+
/** The type of the abstract values of the interval domain that are Top, Bottom, or actual values */
|
|
10
|
+
export type IntervalLift = IntervalValue | IntervalTop | IntervalBottom;
|
|
11
|
+
/**
|
|
12
|
+
* The interval abstract domain as intervals with possibly infinite bounds representing possible numeric values.
|
|
13
|
+
* The Bottom element is defined as {@link Bottom} symbol and the Top element is defined as the interval [-∞, +∞].
|
|
14
|
+
* @template Value - Type of the constraint in the abstract domain (Top, Bottom, or an actual value)
|
|
15
|
+
*/
|
|
16
|
+
export declare class IntervalDomain<Value extends IntervalLift = IntervalLift> implements AbstractDomain<number, IntervalValue, IntervalTop, IntervalBottom, Value> {
|
|
17
|
+
private _value;
|
|
18
|
+
constructor(value: Value);
|
|
19
|
+
get value(): Value;
|
|
20
|
+
static top(): IntervalDomain<IntervalTop>;
|
|
21
|
+
static bottom(): IntervalDomain<IntervalBottom>;
|
|
22
|
+
static abstract(concrete: ReadonlySet<number> | typeof Top): IntervalDomain;
|
|
23
|
+
top(): IntervalDomain<IntervalTop>;
|
|
24
|
+
bottom(): IntervalDomain<IntervalBottom>;
|
|
25
|
+
equals(other: IntervalDomain): boolean;
|
|
26
|
+
leq(other: IntervalDomain): boolean;
|
|
27
|
+
join(...values: IntervalDomain[]): IntervalDomain;
|
|
28
|
+
meet(...values: IntervalDomain[]): IntervalDomain;
|
|
29
|
+
widen(other: IntervalDomain): IntervalDomain;
|
|
30
|
+
narrow(other: IntervalDomain): IntervalDomain;
|
|
31
|
+
concretize(limit?: number): ReadonlySet<number> | typeof Top;
|
|
32
|
+
abstract(concrete: ReadonlySet<number> | typeof Top): IntervalDomain;
|
|
33
|
+
/**
|
|
34
|
+
* Adds another abstract value to the current abstract value by adding the two lower and upper bounds, respectively.
|
|
35
|
+
*/
|
|
36
|
+
add(other: IntervalDomain): IntervalDomain;
|
|
37
|
+
/**
|
|
38
|
+
* Subtracts another abstract value from the current abstract value by subtracting the two lower and upper bounds from each other, respectively.
|
|
39
|
+
*/
|
|
40
|
+
subtract(other: IntervalDomain): IntervalDomain;
|
|
41
|
+
/**
|
|
42
|
+
* Creates the minimum between the current abstract value and another abstract value by creating the minimum of the two lower and upper bounds, respectively.
|
|
43
|
+
*/
|
|
44
|
+
min(other: IntervalDomain): IntervalDomain;
|
|
45
|
+
/**
|
|
46
|
+
* Creates the maximum between the current abstract value and another abstract value by creating the maximum of the two lower and upper bounds, respectively.
|
|
47
|
+
*/
|
|
48
|
+
max(other: IntervalDomain): IntervalDomain;
|
|
49
|
+
/**
|
|
50
|
+
* Extends the lower bound of the current abstract value down to -∞.
|
|
51
|
+
*/
|
|
52
|
+
extendDown(): IntervalDomain;
|
|
53
|
+
/**
|
|
54
|
+
* Extends the upper bound of the current abstract value up to +∞.
|
|
55
|
+
*/
|
|
56
|
+
extendUp(): IntervalDomain;
|
|
57
|
+
toString(): string;
|
|
58
|
+
isTop(): this is IntervalDomain<IntervalTop>;
|
|
59
|
+
isBottom(): this is IntervalDomain<IntervalBottom>;
|
|
60
|
+
isValue(): this is IntervalDomain<IntervalValue>;
|
|
61
|
+
}
|