kumi 0.0.25 → 0.0.26
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +70 -71
- data/data/functions/agg/boolean.yaml +6 -2
- data/data/functions/agg/numeric.yaml +32 -16
- data/data/functions/agg/string.yaml +4 -3
- data/data/functions/core/arithmetic.yaml +62 -14
- data/data/functions/core/boolean.yaml +12 -6
- data/data/functions/core/comparison.yaml +25 -13
- data/data/functions/core/constructor.yaml +16 -8
- data/data/functions/core/select.yaml +3 -1
- data/data/functions/core/stencil.yaml +14 -5
- data/data/functions/core/string.yaml +9 -4
- data/data/kernels/ruby/agg/numeric.yaml +1 -1
- data/docs/UNSAT_DETECTION.md +83 -0
- data/golden/array_element/expected/nast.txt +1 -1
- data/golden/array_element/expected/schema_ruby.rb +1 -1
- data/golden/array_index/expected/nast.txt +7 -7
- data/golden/array_index/expected/schema_ruby.rb +1 -1
- data/golden/array_operations/expected/nast.txt +2 -2
- data/golden/array_operations/expected/schema_ruby.rb +1 -1
- data/golden/array_operations/expected/snast.txt +3 -3
- data/golden/cascade_logic/expected/schema_ruby.rb +1 -1
- data/golden/cascade_logic/expected/snast.txt +2 -2
- data/golden/chained_fusion/expected/nast.txt +2 -2
- data/golden/chained_fusion/expected/schema_ruby.rb +1 -1
- data/golden/element_arrays/expected/nast.txt +2 -2
- data/golden/element_arrays/expected/schema_ruby.rb +1 -1
- data/golden/element_arrays/expected/snast.txt +1 -1
- data/golden/empty_and_null_inputs/expected/nast.txt +3 -3
- data/golden/empty_and_null_inputs/expected/schema_ruby.rb +1 -1
- data/golden/function_overload/expected/ast.txt +29 -0
- data/golden/function_overload/expected/input_plan.txt +4 -0
- data/golden/function_overload/expected/lir_00_unoptimized.txt +18 -0
- data/golden/function_overload/expected/lir_01_hoist_scalar_references.txt +18 -0
- data/golden/function_overload/expected/lir_02_inlined.txt +20 -0
- data/golden/function_overload/expected/lir_03_cse.txt +20 -0
- data/golden/function_overload/expected/lir_04_1_loop_fusion.txt +20 -0
- data/golden/function_overload/expected/lir_04_loop_invcm.txt +20 -0
- data/golden/function_overload/expected/lir_06_const_prop.txt +20 -0
- data/golden/function_overload/expected/nast.txt +22 -0
- data/golden/function_overload/expected/schema_javascript.mjs +12 -0
- data/golden/function_overload/expected/schema_ruby.rb +39 -0
- data/golden/function_overload/expected/snast.txt +22 -0
- data/golden/function_overload/input.json +8 -0
- data/golden/function_overload/schema.kumi +19 -0
- data/golden/game_of_life/expected/lir_00_unoptimized.txt +4 -4
- data/golden/game_of_life/expected/lir_01_hoist_scalar_references.txt +4 -4
- data/golden/game_of_life/expected/lir_02_inlined.txt +16 -16
- data/golden/game_of_life/expected/lir_03_cse.txt +20 -16
- data/golden/game_of_life/expected/lir_04_1_loop_fusion.txt +20 -16
- data/golden/game_of_life/expected/lir_04_loop_invcm.txt +20 -16
- data/golden/game_of_life/expected/lir_06_const_prop.txt +20 -16
- data/golden/game_of_life/expected/nast.txt +4 -4
- data/golden/game_of_life/expected/schema_javascript.mjs +4 -2
- data/golden/game_of_life/expected/schema_ruby.rb +5 -3
- data/golden/game_of_life/expected/snast.txt +10 -10
- data/golden/hash_keys/expected/schema_ruby.rb +1 -1
- data/golden/hash_value/expected/nast.txt +1 -1
- data/golden/hash_value/expected/schema_ruby.rb +1 -1
- data/golden/hash_value/expected/snast.txt +1 -1
- data/golden/hierarchical_complex/expected/nast.txt +3 -3
- data/golden/hierarchical_complex/expected/schema_ruby.rb +1 -1
- data/golden/hierarchical_complex/expected/snast.txt +3 -3
- data/golden/inline_rename_scope_leak/expected/nast.txt +3 -3
- data/golden/inline_rename_scope_leak/expected/schema_ruby.rb +1 -1
- data/golden/input_reference/expected/nast.txt +2 -2
- data/golden/input_reference/expected/schema_ruby.rb +1 -1
- data/golden/interleaved_fusion/expected/nast.txt +2 -2
- data/golden/interleaved_fusion/expected/schema_ruby.rb +1 -1
- data/golden/let_inline/expected/nast.txt +4 -4
- data/golden/let_inline/expected/schema_ruby.rb +1 -1
- data/golden/loop_fusion/expected/nast.txt +1 -1
- data/golden/loop_fusion/expected/schema_ruby.rb +1 -1
- data/golden/min_reduce_scope/expected/nast.txt +3 -3
- data/golden/min_reduce_scope/expected/schema_ruby.rb +1 -1
- data/golden/min_reduce_scope/expected/snast.txt +1 -1
- data/golden/mixed_dimensions/expected/nast.txt +2 -2
- data/golden/mixed_dimensions/expected/schema_ruby.rb +1 -1
- data/golden/multirank_hoisting/expected/nast.txt +7 -7
- data/golden/multirank_hoisting/expected/schema_ruby.rb +1 -1
- data/golden/nested_hash/expected/nast.txt +1 -1
- data/golden/nested_hash/expected/schema_ruby.rb +1 -1
- data/golden/reduction_broadcast/expected/nast.txt +3 -3
- data/golden/reduction_broadcast/expected/schema_ruby.rb +1 -1
- data/golden/reduction_broadcast/expected/snast.txt +1 -1
- data/golden/roll/expected/schema_ruby.rb +1 -1
- data/golden/shift/expected/schema_ruby.rb +1 -1
- data/golden/shift_2d/expected/schema_ruby.rb +1 -1
- data/golden/simple_math/expected/lir_00_unoptimized.txt +1 -1
- data/golden/simple_math/expected/lir_01_hoist_scalar_references.txt +1 -1
- data/golden/simple_math/expected/lir_02_inlined.txt +1 -1
- data/golden/simple_math/expected/lir_03_cse.txt +1 -1
- data/golden/simple_math/expected/lir_04_1_loop_fusion.txt +1 -1
- data/golden/simple_math/expected/lir_04_loop_invcm.txt +1 -1
- data/golden/simple_math/expected/lir_06_const_prop.txt +1 -1
- data/golden/simple_math/expected/nast.txt +5 -5
- data/golden/simple_math/expected/schema_ruby.rb +1 -1
- data/golden/simple_math/expected/snast.txt +2 -2
- data/golden/streaming_basics/expected/nast.txt +8 -8
- data/golden/streaming_basics/expected/schema_ruby.rb +1 -1
- data/golden/streaming_basics/expected/snast.txt +1 -1
- data/golden/tuples/expected/lir_00_unoptimized.txt +5 -5
- data/golden/tuples/expected/lir_01_hoist_scalar_references.txt +5 -5
- data/golden/tuples/expected/lir_02_inlined.txt +5 -5
- data/golden/tuples/expected/lir_03_cse.txt +5 -5
- data/golden/tuples/expected/lir_04_1_loop_fusion.txt +5 -5
- data/golden/tuples/expected/lir_04_loop_invcm.txt +5 -5
- data/golden/tuples/expected/lir_06_const_prop.txt +5 -5
- data/golden/tuples/expected/nast.txt +4 -4
- data/golden/tuples/expected/schema_ruby.rb +1 -1
- data/golden/tuples/expected/snast.txt +6 -6
- data/golden/tuples_and_arrays/expected/lir_00_unoptimized.txt +1 -1
- data/golden/tuples_and_arrays/expected/lir_01_hoist_scalar_references.txt +1 -1
- data/golden/tuples_and_arrays/expected/lir_02_inlined.txt +2 -2
- data/golden/tuples_and_arrays/expected/lir_03_cse.txt +2 -2
- data/golden/tuples_and_arrays/expected/lir_04_1_loop_fusion.txt +2 -2
- data/golden/tuples_and_arrays/expected/lir_04_loop_invcm.txt +2 -2
- data/golden/tuples_and_arrays/expected/lir_06_const_prop.txt +2 -2
- data/golden/tuples_and_arrays/expected/nast.txt +3 -3
- data/golden/tuples_and_arrays/expected/schema_ruby.rb +1 -1
- data/golden/tuples_and_arrays/expected/snast.txt +2 -2
- data/golden/us_tax_2024/expected/ast.txt +63 -670
- data/golden/us_tax_2024/expected/input_plan.txt +8 -45
- data/golden/us_tax_2024/expected/lir_00_unoptimized.txt +253 -863
- data/golden/us_tax_2024/expected/lir_01_hoist_scalar_references.txt +253 -863
- data/golden/us_tax_2024/expected/lir_02_inlined.txt +1215 -5139
- data/golden/us_tax_2024/expected/lir_03_cse.txt +587 -2460
- data/golden/us_tax_2024/expected/lir_04_1_loop_fusion.txt +632 -2480
- data/golden/us_tax_2024/expected/lir_04_loop_invcm.txt +587 -2460
- data/golden/us_tax_2024/expected/lir_06_const_prop.txt +587 -2460
- data/golden/us_tax_2024/expected/nast.txt +123 -826
- data/golden/us_tax_2024/expected/schema_javascript.mjs +127 -581
- data/golden/us_tax_2024/expected/schema_ruby.rb +135 -610
- data/golden/us_tax_2024/expected/snast.txt +155 -858
- data/golden/us_tax_2024/expected.json +120 -1
- data/golden/us_tax_2024/input.json +18 -9
- data/golden/us_tax_2024/schema.kumi +48 -178
- data/golden/with_constants/expected/lir_00_unoptimized.txt +1 -1
- data/golden/with_constants/expected/lir_01_hoist_scalar_references.txt +1 -1
- data/golden/with_constants/expected/lir_02_inlined.txt +1 -1
- data/golden/with_constants/expected/lir_03_cse.txt +1 -1
- data/golden/with_constants/expected/lir_04_1_loop_fusion.txt +1 -1
- data/golden/with_constants/expected/lir_04_loop_invcm.txt +1 -1
- data/golden/with_constants/expected/lir_06_const_prop.txt +1 -1
- data/golden/with_constants/expected/nast.txt +2 -2
- data/golden/with_constants/expected/schema_ruby.rb +1 -1
- data/golden/with_constants/expected/snast.txt +2 -2
- data/lib/kumi/analyzer.rb +12 -12
- data/lib/kumi/core/analyzer/passes/formal_constraint_propagator.rb +236 -0
- data/lib/kumi/core/analyzer/passes/input_collector.rb +22 -4
- data/lib/kumi/core/analyzer/passes/nast_dimensional_analyzer_pass.rb +64 -18
- data/lib/kumi/core/analyzer/passes/normalize_to_nast_pass.rb +9 -4
- data/lib/kumi/core/analyzer/passes/snast_pass.rb +3 -1
- data/lib/kumi/core/analyzer/passes/unsat_detector.rb +172 -198
- data/lib/kumi/core/error_reporter.rb +36 -1
- data/lib/kumi/core/errors.rb +33 -1
- data/lib/kumi/core/functions/function_spec.rb +5 -4
- data/lib/kumi/core/functions/loader.rb +17 -1
- data/lib/kumi/core/functions/overload_resolver.rb +164 -0
- data/lib/kumi/core/functions/type_error_reporter.rb +118 -0
- data/lib/kumi/core/functions/type_rules.rb +155 -35
- data/lib/kumi/core/types/inference.rb +29 -22
- data/lib/kumi/core/types/normalizer.rb +29 -45
- data/lib/kumi/core/types/validator.rb +16 -27
- data/lib/kumi/core/types/value_objects.rb +116 -0
- data/lib/kumi/core/types.rb +45 -37
- data/lib/kumi/registry_v2/loader.rb +90 -0
- data/lib/kumi/registry_v2.rb +18 -1
- data/lib/kumi/version.rb +1 -1
- metadata +21 -7
- data/lib/kumi/core/analyzer/unsat_constant_evaluator.rb +0 -59
- data/lib/kumi/core/atom_unsat_solver.rb +0 -396
- data/lib/kumi/core/constraint_relationship_solver.rb +0 -641
- data/lib/kumi/core/types/builder.rb +0 -23
- data/lib/kumi/core/types/compatibility.rb +0 -96
- data/lib/kumi/core/types/formatter.rb +0 -26
@@ -0,0 +1,83 @@
|
|
1
|
+
# UNSAT Detection & Constraint Analysis
|
2
|
+
|
3
|
+
Kumi includes static analysis to detect **unsatisfiable constraints**—impossible conditions that can never be true given input domains.
|
4
|
+
|
5
|
+
## How It Works
|
6
|
+
|
7
|
+
### Direct Contradictions
|
8
|
+
Kumi detects when the same variable is constrained to multiple different values:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
schema do
|
12
|
+
input { integer :x }
|
13
|
+
|
14
|
+
# ✓ Detected as UNSAT: x cannot be both 5 and 10
|
15
|
+
trait :impossible, fn(:and, input.x == 5, input.x == 10)
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
### Domain Violations
|
20
|
+
Kumi checks when constraints violate input domains:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
schema do
|
24
|
+
input { integer :age, domain: 0..150 }
|
25
|
+
|
26
|
+
# ✓ Detected as UNSAT: age can never be 200
|
27
|
+
trait :impossible_age, input.age == 200
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
### Constraint Propagation (Phase 2)
|
32
|
+
Kumi propagates constraints through operations to detect derived impossibilities:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
schema do
|
36
|
+
input { integer :x, domain: 0..10 }
|
37
|
+
|
38
|
+
value :doubled, fn(:mul, input.x, 2) # doubled ∈ [0, 20]
|
39
|
+
|
40
|
+
# ✓ Detected as UNSAT: doubled can never be 50
|
41
|
+
trait :impossible_doubled, doubled == 50
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
**Reverse propagation** derives input constraints from output constraints:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
schema do
|
49
|
+
input { integer :x, domain: 0..10 }
|
50
|
+
|
51
|
+
value :result, fn(:add, input.x, 100) # result ∈ [100, 110]
|
52
|
+
|
53
|
+
# ✓ Detected as UNSAT: result == 50 would require x == -50 (outside domain)
|
54
|
+
trait :impossible_result, result == 50
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
## Error Messages
|
59
|
+
|
60
|
+
Impossible constraints raise `Kumi::Core::Errors::SemanticError`:
|
61
|
+
|
62
|
+
```
|
63
|
+
conjunction `impossible_doubled` is impossible
|
64
|
+
```
|
65
|
+
|
66
|
+
This message appears at schema compilation time, catching bugs before execution.
|
67
|
+
|
68
|
+
## When UNSAT Detection Runs
|
69
|
+
|
70
|
+
UNSAT detection is performed during the **HIR-to-LIR compilation phase**, after:
|
71
|
+
- Function IDs are resolved
|
72
|
+
- Type information is inferred
|
73
|
+
- Dimensional metadata is computed
|
74
|
+
|
75
|
+
This ensures detection has access to complete operation semantics.
|
76
|
+
|
77
|
+
## Future Enhancements
|
78
|
+
|
79
|
+
- **Multi-level propagation**: Chain constraints through multiple operations
|
80
|
+
- **Inequality constraints**: Handle `<`, `>`, `<=`, `>=` constraints
|
81
|
+
- **Combined constraints**: Detect contradictions across multiple traits
|
82
|
+
|
83
|
+
See `spec/integration/unsat_with_propagation_spec.rb` for examples and pending tests.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autogenerated by Kumi Codegen
|
2
|
-
module Kumi::Compiled::
|
2
|
+
module Kumi::Compiled::KUMI_1cd98cf56c50f763cab5055e1275d07ac58aaee708cbd081d7773ac43c8d9d33
|
3
3
|
def self.from(input_data = nil)
|
4
4
|
instance = Object.new
|
5
5
|
instance.extend(self)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
(NAST
|
2
2
|
(VALUE W
|
3
|
-
(Call :
|
3
|
+
(Call :array_size
|
4
4
|
(InputRef [:x, :y])
|
5
5
|
)
|
6
6
|
)
|
7
7
|
(VALUE box
|
8
|
-
(Call :
|
9
|
-
(Call :
|
8
|
+
(Call :add
|
9
|
+
(Call :multiply
|
10
10
|
#<struct Kumi::Core::NAST::IndexRef id=83, loc=nil, meta={}>
|
11
11
|
(Ref W)
|
12
12
|
)
|
@@ -14,10 +14,10 @@
|
|
14
14
|
)
|
15
15
|
)
|
16
16
|
(VALUE col_major
|
17
|
-
(Call :
|
18
|
-
(Call :
|
17
|
+
(Call :add
|
18
|
+
(Call :multiply
|
19
19
|
#<struct Kumi::Core::NAST::IndexRef id=91, loc=nil, meta={}>
|
20
|
-
(Call :
|
20
|
+
(Call :array_size
|
21
21
|
(InputRef [:x])
|
22
22
|
)
|
23
23
|
)
|
@@ -25,7 +25,7 @@
|
|
25
25
|
)
|
26
26
|
)
|
27
27
|
(VALUE sum_ij
|
28
|
-
(Call :
|
28
|
+
(Call :add
|
29
29
|
#<struct Kumi::Core::NAST::IndexRef id=100, loc=nil, meta={}>
|
30
30
|
#<struct Kumi::Core::NAST::IndexRef id=102, loc=nil, meta={}>
|
31
31
|
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autogenerated by Kumi Codegen
|
2
|
-
module Kumi::Compiled::
|
2
|
+
module Kumi::Compiled::KUMI_f0ed06608ce6a4d5050abd38d6642055bd22c10f7ed1ba5c5b32a1c61c78736d
|
3
3
|
def self.from(input_data = nil)
|
4
4
|
instance = Object.new
|
5
5
|
instance.extend(self)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
(NAST
|
2
2
|
(VALUE subtotals
|
3
|
-
(Call :
|
3
|
+
(Call :multiply
|
4
4
|
(InputRef [:items, :item, :price])
|
5
5
|
(InputRef [:items, :item, :quantity])
|
6
6
|
)
|
7
7
|
)
|
8
8
|
(VALUE discounted_price
|
9
|
-
(Call :
|
9
|
+
(Call :multiply
|
10
10
|
(InputRef [:items, :item, :price])
|
11
11
|
(Const 0.9)
|
12
12
|
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autogenerated by Kumi Codegen
|
2
|
-
module Kumi::Compiled::
|
2
|
+
module Kumi::Compiled::KUMI_98624b0772f11031b22df384c3c7f33db6dd17485e3f9cf2f69c17ad1d79a9d9
|
3
3
|
def self.from(input_data = nil)
|
4
4
|
instance = Object.new
|
5
5
|
instance.extend(self)
|
@@ -11,19 +11,19 @@
|
|
11
11
|
(Const 0.9) :: [] -> float
|
12
12
|
) :: [items] -> float
|
13
13
|
) :: [items] -> float
|
14
|
-
(
|
14
|
+
(VALUE is_valid_quantity
|
15
15
|
(Call :core.gt
|
16
16
|
(InputRef items.item.quantity key_chain=[]) :: [items] -> integer
|
17
17
|
(Const 0) :: [] -> integer
|
18
18
|
) :: [items] -> boolean
|
19
19
|
) :: [items] -> boolean
|
20
|
-
(
|
20
|
+
(VALUE expensive_items
|
21
21
|
(Call :core.gt
|
22
22
|
(InputRef items.item.price key_chain=[]) :: [items] -> float
|
23
23
|
(Const 100.0) :: [] -> float
|
24
24
|
) :: [items] -> boolean
|
25
25
|
) :: [items] -> boolean
|
26
|
-
(
|
26
|
+
(VALUE electronics
|
27
27
|
(Call :core.eq
|
28
28
|
(InputRef items.item.category key_chain=[]) :: [items] -> string
|
29
29
|
(Const "electronics") :: [] -> string
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autogenerated by Kumi Codegen
|
2
|
-
module Kumi::Compiled::
|
2
|
+
module Kumi::Compiled::KUMI_a359b484890e040a5fdd419b92800fddad006edffc49f277f28525eef4e3d9bd
|
3
3
|
def self.from(input_data = nil)
|
4
4
|
instance = Object.new
|
5
5
|
instance.extend(self)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
(SNAST
|
2
|
-
(
|
2
|
+
(VALUE y_positive
|
3
3
|
(Call :core.gt
|
4
4
|
(InputRef y key_chain=[]) :: [] -> integer
|
5
5
|
(Const 0) :: [] -> integer
|
6
6
|
) :: [] -> boolean
|
7
7
|
) :: [] -> boolean
|
8
|
-
(
|
8
|
+
(VALUE x_positive
|
9
9
|
(Call :core.gt
|
10
10
|
(InputRef x key_chain=[]) :: [] -> integer
|
11
11
|
(Const 0) :: [] -> integer
|
@@ -1,6 +1,6 @@
|
|
1
1
|
(NAST
|
2
2
|
(VALUE total_payroll
|
3
|
-
(Call :
|
3
|
+
(Call :sum
|
4
4
|
(InputRef [:departments, :dept, :employees, :emp, :salary])
|
5
5
|
)
|
6
6
|
)
|
@@ -29,7 +29,7 @@
|
|
29
29
|
)
|
30
30
|
)
|
31
31
|
(VALUE max_salary
|
32
|
-
(Call :
|
32
|
+
(Call :max
|
33
33
|
(InputRef [:departments, :dept, :employees, :emp, :salary])
|
34
34
|
)
|
35
35
|
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autogenerated by Kumi Codegen
|
2
|
-
module Kumi::Compiled::
|
2
|
+
module Kumi::Compiled::KUMI_e5b30cb23c39d5d7959274f41cf2d6a7e4ec0016dc7e19c0bef5c08d67ee1933
|
3
3
|
def self.from(input_data = nil)
|
4
4
|
instance = Object.new
|
5
5
|
instance.extend(self)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autogenerated by Kumi Codegen
|
2
|
-
module Kumi::Compiled::
|
2
|
+
module Kumi::Compiled::KUMI_a2c21afb35a86d67d51bfe12d6bb29d2ef5886500b42431cad974924e3677fa3
|
3
3
|
def self.from(input_data = nil)
|
4
4
|
instance = Object.new
|
5
5
|
instance.extend(self)
|
@@ -11,7 +11,7 @@
|
|
11
11
|
(VALUE cell
|
12
12
|
(InputRef cube.layer.row.cell key_chain=[]) :: [cube, layer, row] -> integer
|
13
13
|
) :: [cube, layer, row] -> integer
|
14
|
-
(
|
14
|
+
(VALUE cell_over_limit
|
15
15
|
(Call :core.gt
|
16
16
|
(InputRef cube.layer.row.cell key_chain=[]) :: [cube, layer, row] -> integer
|
17
17
|
(Const 100) :: [] -> integer
|
@@ -1,16 +1,16 @@
|
|
1
1
|
(NAST
|
2
2
|
(VALUE regional_sales
|
3
|
-
(Call :
|
3
|
+
(Call :sum
|
4
4
|
(InputRef [:regions, :region, :sales, :sale, :amount])
|
5
5
|
)
|
6
6
|
)
|
7
7
|
(VALUE total_sales
|
8
|
-
(Call :
|
8
|
+
(Call :sum
|
9
9
|
(Ref regional_sales)
|
10
10
|
)
|
11
11
|
)
|
12
12
|
(VALUE adjusted_total
|
13
|
-
(Call :
|
13
|
+
(Call :add
|
14
14
|
(Ref total_sales)
|
15
15
|
(InputRef [:adjustment])
|
16
16
|
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autogenerated by Kumi Codegen
|
2
|
-
module Kumi::Compiled::
|
2
|
+
module Kumi::Compiled::KUMI_ad6e7ee5524d611f2ec03728b7e9f8c097e1308dbaf49da390610067b59c4145
|
3
3
|
def self.from(input_data = nil)
|
4
4
|
instance = Object.new
|
5
5
|
instance.extend(self)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
(Root
|
2
|
+
inputs: [
|
3
|
+
(InputDeclaration :name :string)
|
4
|
+
(InputDeclaration :items :array
|
5
|
+
[
|
6
|
+
(InputDeclaration :value :integer)
|
7
|
+
]
|
8
|
+
)
|
9
|
+
]
|
10
|
+
values: [
|
11
|
+
(ValueDeclaration :name_len
|
12
|
+
(CallExpression :size
|
13
|
+
(InputReference :name)
|
14
|
+
)
|
15
|
+
)
|
16
|
+
(ValueDeclaration :items_count
|
17
|
+
(CallExpression :size
|
18
|
+
(InputReference :items)
|
19
|
+
)
|
20
|
+
)
|
21
|
+
(ValueDeclaration :summary
|
22
|
+
(HashExpression
|
23
|
+
((Literal :name_length) (DeclarationReference :name_len))
|
24
|
+
((Literal :item_count) (DeclarationReference :items_count))
|
25
|
+
)
|
26
|
+
)
|
27
|
+
]
|
28
|
+
traits: []
|
29
|
+
)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
(LIR
|
2
|
+
(Declaration name_len
|
3
|
+
%t1 = load_input "name" :: string
|
4
|
+
%t2 = call core.length(%t1) :: integer
|
5
|
+
yield %t2
|
6
|
+
)
|
7
|
+
(Declaration items_count
|
8
|
+
%t3 = load_input "items" :: array
|
9
|
+
%t4 = call core.array_size(%t3) :: integer
|
10
|
+
yield %t4
|
11
|
+
)
|
12
|
+
(Declaration summary
|
13
|
+
%t5 = load_decl name_len :: integer
|
14
|
+
%t6 = load_decl items_count :: integer
|
15
|
+
%t7 = make_object{name_length: %t5, item_count: %t6} :: object
|
16
|
+
yield %t7
|
17
|
+
)
|
18
|
+
)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
(LIR
|
2
|
+
(Declaration name_len
|
3
|
+
%t1 = load_input "name" :: string
|
4
|
+
%t2 = call core.length(%t1) :: integer
|
5
|
+
yield %t2
|
6
|
+
)
|
7
|
+
(Declaration items_count
|
8
|
+
%t3 = load_input "items" :: array
|
9
|
+
%t4 = call core.array_size(%t3) :: integer
|
10
|
+
yield %t4
|
11
|
+
)
|
12
|
+
(Declaration summary
|
13
|
+
%t5 = load_decl name_len :: integer
|
14
|
+
%t6 = load_decl items_count :: integer
|
15
|
+
%t7 = make_object{name_length: %t5, item_count: %t6} :: object
|
16
|
+
yield %t7
|
17
|
+
)
|
18
|
+
)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
(LIR
|
2
|
+
(Declaration name_len
|
3
|
+
%t1 = load_input "name" :: string
|
4
|
+
%t2 = call core.length(%t1) :: integer
|
5
|
+
yield %t2
|
6
|
+
)
|
7
|
+
(Declaration items_count
|
8
|
+
%t3 = load_input "items" :: array
|
9
|
+
%t4 = call core.array_size(%t3) :: integer
|
10
|
+
yield %t4
|
11
|
+
)
|
12
|
+
(Declaration summary
|
13
|
+
%t8 = load_input "name" :: string
|
14
|
+
%t9 = call core.length(%t8) :: integer
|
15
|
+
%t10 = load_input "items" :: array
|
16
|
+
%t11 = call core.array_size(%t10) :: integer
|
17
|
+
%t7 = make_object{name_length: %t9, item_count: %t11} :: object
|
18
|
+
yield %t7
|
19
|
+
)
|
20
|
+
)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
(LIR
|
2
|
+
(Declaration name_len
|
3
|
+
%t1 = load_input "name" :: string
|
4
|
+
%t2 = call core.length(%t1) :: integer
|
5
|
+
yield %t2
|
6
|
+
)
|
7
|
+
(Declaration items_count
|
8
|
+
%t3 = load_input "items" :: array
|
9
|
+
%t4 = call core.array_size(%t3) :: integer
|
10
|
+
yield %t4
|
11
|
+
)
|
12
|
+
(Declaration summary
|
13
|
+
%t8 = load_input "name" :: string
|
14
|
+
%t9 = call core.length(%t8) :: integer
|
15
|
+
%t10 = load_input "items" :: array
|
16
|
+
%t11 = call core.array_size(%t10) :: integer
|
17
|
+
%t7 = make_object{name_length: %t9, item_count: %t11} :: object
|
18
|
+
yield %t7
|
19
|
+
)
|
20
|
+
)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
(LIR
|
2
|
+
(Declaration name_len
|
3
|
+
%t1 = load_input "name" :: string
|
4
|
+
%t2 = call core.length(%t1) :: integer
|
5
|
+
yield %t2
|
6
|
+
)
|
7
|
+
(Declaration items_count
|
8
|
+
%t3 = load_input "items" :: array
|
9
|
+
%t4 = call core.array_size(%t3) :: integer
|
10
|
+
yield %t4
|
11
|
+
)
|
12
|
+
(Declaration summary
|
13
|
+
%t8 = load_input "name" :: string
|
14
|
+
%t9 = call core.length(%t8) :: integer
|
15
|
+
%t10 = load_input "items" :: array
|
16
|
+
%t11 = call core.array_size(%t10) :: integer
|
17
|
+
%t7 = make_object{name_length: %t9, item_count: %t11} :: object
|
18
|
+
yield %t7
|
19
|
+
)
|
20
|
+
)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
(LIR
|
2
|
+
(Declaration name_len
|
3
|
+
%t1 = load_input "name" :: string
|
4
|
+
%t2 = call core.length(%t1) :: integer
|
5
|
+
yield %t2
|
6
|
+
)
|
7
|
+
(Declaration items_count
|
8
|
+
%t3 = load_input "items" :: array
|
9
|
+
%t4 = call core.array_size(%t3) :: integer
|
10
|
+
yield %t4
|
11
|
+
)
|
12
|
+
(Declaration summary
|
13
|
+
%t8 = load_input "name" :: string
|
14
|
+
%t9 = call core.length(%t8) :: integer
|
15
|
+
%t10 = load_input "items" :: array
|
16
|
+
%t11 = call core.array_size(%t10) :: integer
|
17
|
+
%t7 = make_object{name_length: %t9, item_count: %t11} :: object
|
18
|
+
yield %t7
|
19
|
+
)
|
20
|
+
)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
(LIR
|
2
|
+
(Declaration name_len
|
3
|
+
%t1 = load_input "name" :: string
|
4
|
+
%t2 = call core.length(%t1) :: integer
|
5
|
+
yield %t2
|
6
|
+
)
|
7
|
+
(Declaration items_count
|
8
|
+
%t3 = load_input "items" :: array
|
9
|
+
%t4 = call core.array_size(%t3) :: integer
|
10
|
+
yield %t4
|
11
|
+
)
|
12
|
+
(Declaration summary
|
13
|
+
%t8 = load_input "name" :: string
|
14
|
+
%t9 = call core.length(%t8) :: integer
|
15
|
+
%t10 = load_input "items" :: array
|
16
|
+
%t11 = call core.array_size(%t10) :: integer
|
17
|
+
%t7 = make_object{name_length: %t9, item_count: %t11} :: object
|
18
|
+
yield %t7
|
19
|
+
)
|
20
|
+
)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
(NAST
|
2
|
+
(VALUE name_len
|
3
|
+
(Call :size
|
4
|
+
(InputRef [:name])
|
5
|
+
)
|
6
|
+
)
|
7
|
+
(VALUE items_count
|
8
|
+
(Call :size
|
9
|
+
(InputRef [:items])
|
10
|
+
)
|
11
|
+
)
|
12
|
+
(VALUE summary
|
13
|
+
(Hash
|
14
|
+
(Pair name_length
|
15
|
+
(Ref name_len)
|
16
|
+
)
|
17
|
+
(Pair item_count
|
18
|
+
(Ref items_count)
|
19
|
+
)
|
20
|
+
)
|
21
|
+
)
|
22
|
+
)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Autogenerated by Kumi Codegen
|
2
|
+
module Kumi::Compiled::KUMI_fc278e6d9fc513388aad074ca6f0853cd6bfc39df05818173f50fb354060cd30
|
3
|
+
def self.from(input_data = nil)
|
4
|
+
instance = Object.new
|
5
|
+
instance.extend(self)
|
6
|
+
instance.instance_variable_set(:@input, input_data)
|
7
|
+
instance
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.__kumi_executable__
|
11
|
+
instance = Object.new
|
12
|
+
instance.extend(self)
|
13
|
+
instance
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(input_data)
|
17
|
+
@input = @input.merge(input_data)
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](name)
|
22
|
+
case name
|
23
|
+
when :summary then _summary
|
24
|
+
else raise KeyError, "Unknown declaration"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def _summary(input = @input)
|
29
|
+
t8 = input["name"] || input[:name]
|
30
|
+
t9 = t8.length
|
31
|
+
t10 = input["items"] || input[:items]
|
32
|
+
t11 = t10.length
|
33
|
+
t7 = {
|
34
|
+
"name_length" => t9,
|
35
|
+
"item_count" => t11
|
36
|
+
}
|
37
|
+
t7
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
(SNAST
|
2
|
+
(VALUE name_len
|
3
|
+
(Call :core.length
|
4
|
+
(InputRef name key_chain=[]) :: [] -> string
|
5
|
+
) :: [] -> integer
|
6
|
+
) :: [] -> integer
|
7
|
+
(VALUE items_count
|
8
|
+
(Call :core.array_size
|
9
|
+
(InputRef items key_chain=[]) :: [] -> array
|
10
|
+
) :: [] -> integer
|
11
|
+
) :: [] -> integer
|
12
|
+
(VALUE summary
|
13
|
+
(Hash
|
14
|
+
(Pair name_length
|
15
|
+
(Ref name_len) :: [] -> integer
|
16
|
+
) :: [] -> pair
|
17
|
+
(Pair item_count
|
18
|
+
(Ref items_count) :: [] -> integer
|
19
|
+
) :: [] -> pair
|
20
|
+
) :: [] -> hash
|
21
|
+
) :: [] -> hash
|
22
|
+
)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
schema do
|
2
|
+
input do
|
3
|
+
string :name
|
4
|
+
array :items do
|
5
|
+
integer :value
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
# Should resolve to core.length (string -> integer)
|
10
|
+
let :name_len, fn(:size, input.name)
|
11
|
+
|
12
|
+
# Should resolve to core.array_size (array -> integer)
|
13
|
+
let :items_count, fn(:size, input.items)
|
14
|
+
|
15
|
+
value :summary, {
|
16
|
+
name_length: name_len,
|
17
|
+
item_count: items_count
|
18
|
+
}
|
19
|
+
end
|
@@ -267,8 +267,8 @@
|
|
267
267
|
%t240 = load_decl ne axes=[rows, col] :: integer
|
268
268
|
%t241 = load_decl sw axes=[rows, col] :: integer
|
269
269
|
%t242 = load_decl se axes=[rows, col] :: integer
|
270
|
-
%t243 = make_tuple(%t235, %t236, %t237, %t238, %t239, %t240, %t241, %t242) :: tuple<integer>
|
271
|
-
%t244 = fold %t243 fn="agg.sum" ::
|
270
|
+
%t243 = make_tuple(%t235, %t236, %t237, %t238, %t239, %t240, %t241, %t242) :: tuple<integer, integer, integer, integer, integer, integer, integer, integer>
|
271
|
+
%t244 = fold %t243 fn="agg.sum" :: tuple<integer, integer, integer, integer, integer, integer, integer, integer>
|
272
272
|
yield %t244
|
273
273
|
end_loop
|
274
274
|
end_loop
|
@@ -288,7 +288,7 @@
|
|
288
288
|
%t253 = load_input "rows" :: array
|
289
289
|
loop rows id=L23 in %t253 as el=%rows_el_254, idx=%rows_i_255
|
290
290
|
loop col id=L24 in %rows_el_254 as el=%col_el_256, idx=%col_i_257
|
291
|
-
%t258 = load_decl neighbors axes=[rows, col] ::
|
291
|
+
%t258 = load_decl neighbors axes=[rows, col] :: tuple<integer, integer, integer, integer, integer, integer, integer, integer>
|
292
292
|
%t259 = const 3 :: integer
|
293
293
|
%t260 = call core.eq(%t258, %t259) :: boolean
|
294
294
|
yield %t260
|
@@ -299,7 +299,7 @@
|
|
299
299
|
%t261 = load_input "rows" :: array
|
300
300
|
loop rows id=L25 in %t261 as el=%rows_el_262, idx=%rows_i_263
|
301
301
|
loop col id=L26 in %rows_el_262 as el=%col_el_264, idx=%col_i_265
|
302
|
-
%t266 = load_decl neighbors axes=[rows, col] ::
|
302
|
+
%t266 = load_decl neighbors axes=[rows, col] :: tuple<integer, integer, integer, integer, integer, integer, integer, integer>
|
303
303
|
%t267 = const 2 :: integer
|
304
304
|
%t268 = call core.eq(%t266, %t267) :: boolean
|
305
305
|
yield %t268
|