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.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +70 -71
  4. data/data/functions/agg/boolean.yaml +6 -2
  5. data/data/functions/agg/numeric.yaml +32 -16
  6. data/data/functions/agg/string.yaml +4 -3
  7. data/data/functions/core/arithmetic.yaml +62 -14
  8. data/data/functions/core/boolean.yaml +12 -6
  9. data/data/functions/core/comparison.yaml +25 -13
  10. data/data/functions/core/constructor.yaml +16 -8
  11. data/data/functions/core/select.yaml +3 -1
  12. data/data/functions/core/stencil.yaml +14 -5
  13. data/data/functions/core/string.yaml +9 -4
  14. data/data/kernels/ruby/agg/numeric.yaml +1 -1
  15. data/docs/UNSAT_DETECTION.md +83 -0
  16. data/golden/array_element/expected/nast.txt +1 -1
  17. data/golden/array_element/expected/schema_ruby.rb +1 -1
  18. data/golden/array_index/expected/nast.txt +7 -7
  19. data/golden/array_index/expected/schema_ruby.rb +1 -1
  20. data/golden/array_operations/expected/nast.txt +2 -2
  21. data/golden/array_operations/expected/schema_ruby.rb +1 -1
  22. data/golden/array_operations/expected/snast.txt +3 -3
  23. data/golden/cascade_logic/expected/schema_ruby.rb +1 -1
  24. data/golden/cascade_logic/expected/snast.txt +2 -2
  25. data/golden/chained_fusion/expected/nast.txt +2 -2
  26. data/golden/chained_fusion/expected/schema_ruby.rb +1 -1
  27. data/golden/element_arrays/expected/nast.txt +2 -2
  28. data/golden/element_arrays/expected/schema_ruby.rb +1 -1
  29. data/golden/element_arrays/expected/snast.txt +1 -1
  30. data/golden/empty_and_null_inputs/expected/nast.txt +3 -3
  31. data/golden/empty_and_null_inputs/expected/schema_ruby.rb +1 -1
  32. data/golden/function_overload/expected/ast.txt +29 -0
  33. data/golden/function_overload/expected/input_plan.txt +4 -0
  34. data/golden/function_overload/expected/lir_00_unoptimized.txt +18 -0
  35. data/golden/function_overload/expected/lir_01_hoist_scalar_references.txt +18 -0
  36. data/golden/function_overload/expected/lir_02_inlined.txt +20 -0
  37. data/golden/function_overload/expected/lir_03_cse.txt +20 -0
  38. data/golden/function_overload/expected/lir_04_1_loop_fusion.txt +20 -0
  39. data/golden/function_overload/expected/lir_04_loop_invcm.txt +20 -0
  40. data/golden/function_overload/expected/lir_06_const_prop.txt +20 -0
  41. data/golden/function_overload/expected/nast.txt +22 -0
  42. data/golden/function_overload/expected/schema_javascript.mjs +12 -0
  43. data/golden/function_overload/expected/schema_ruby.rb +39 -0
  44. data/golden/function_overload/expected/snast.txt +22 -0
  45. data/golden/function_overload/input.json +8 -0
  46. data/golden/function_overload/schema.kumi +19 -0
  47. data/golden/game_of_life/expected/lir_00_unoptimized.txt +4 -4
  48. data/golden/game_of_life/expected/lir_01_hoist_scalar_references.txt +4 -4
  49. data/golden/game_of_life/expected/lir_02_inlined.txt +16 -16
  50. data/golden/game_of_life/expected/lir_03_cse.txt +20 -16
  51. data/golden/game_of_life/expected/lir_04_1_loop_fusion.txt +20 -16
  52. data/golden/game_of_life/expected/lir_04_loop_invcm.txt +20 -16
  53. data/golden/game_of_life/expected/lir_06_const_prop.txt +20 -16
  54. data/golden/game_of_life/expected/nast.txt +4 -4
  55. data/golden/game_of_life/expected/schema_javascript.mjs +4 -2
  56. data/golden/game_of_life/expected/schema_ruby.rb +5 -3
  57. data/golden/game_of_life/expected/snast.txt +10 -10
  58. data/golden/hash_keys/expected/schema_ruby.rb +1 -1
  59. data/golden/hash_value/expected/nast.txt +1 -1
  60. data/golden/hash_value/expected/schema_ruby.rb +1 -1
  61. data/golden/hash_value/expected/snast.txt +1 -1
  62. data/golden/hierarchical_complex/expected/nast.txt +3 -3
  63. data/golden/hierarchical_complex/expected/schema_ruby.rb +1 -1
  64. data/golden/hierarchical_complex/expected/snast.txt +3 -3
  65. data/golden/inline_rename_scope_leak/expected/nast.txt +3 -3
  66. data/golden/inline_rename_scope_leak/expected/schema_ruby.rb +1 -1
  67. data/golden/input_reference/expected/nast.txt +2 -2
  68. data/golden/input_reference/expected/schema_ruby.rb +1 -1
  69. data/golden/interleaved_fusion/expected/nast.txt +2 -2
  70. data/golden/interleaved_fusion/expected/schema_ruby.rb +1 -1
  71. data/golden/let_inline/expected/nast.txt +4 -4
  72. data/golden/let_inline/expected/schema_ruby.rb +1 -1
  73. data/golden/loop_fusion/expected/nast.txt +1 -1
  74. data/golden/loop_fusion/expected/schema_ruby.rb +1 -1
  75. data/golden/min_reduce_scope/expected/nast.txt +3 -3
  76. data/golden/min_reduce_scope/expected/schema_ruby.rb +1 -1
  77. data/golden/min_reduce_scope/expected/snast.txt +1 -1
  78. data/golden/mixed_dimensions/expected/nast.txt +2 -2
  79. data/golden/mixed_dimensions/expected/schema_ruby.rb +1 -1
  80. data/golden/multirank_hoisting/expected/nast.txt +7 -7
  81. data/golden/multirank_hoisting/expected/schema_ruby.rb +1 -1
  82. data/golden/nested_hash/expected/nast.txt +1 -1
  83. data/golden/nested_hash/expected/schema_ruby.rb +1 -1
  84. data/golden/reduction_broadcast/expected/nast.txt +3 -3
  85. data/golden/reduction_broadcast/expected/schema_ruby.rb +1 -1
  86. data/golden/reduction_broadcast/expected/snast.txt +1 -1
  87. data/golden/roll/expected/schema_ruby.rb +1 -1
  88. data/golden/shift/expected/schema_ruby.rb +1 -1
  89. data/golden/shift_2d/expected/schema_ruby.rb +1 -1
  90. data/golden/simple_math/expected/lir_00_unoptimized.txt +1 -1
  91. data/golden/simple_math/expected/lir_01_hoist_scalar_references.txt +1 -1
  92. data/golden/simple_math/expected/lir_02_inlined.txt +1 -1
  93. data/golden/simple_math/expected/lir_03_cse.txt +1 -1
  94. data/golden/simple_math/expected/lir_04_1_loop_fusion.txt +1 -1
  95. data/golden/simple_math/expected/lir_04_loop_invcm.txt +1 -1
  96. data/golden/simple_math/expected/lir_06_const_prop.txt +1 -1
  97. data/golden/simple_math/expected/nast.txt +5 -5
  98. data/golden/simple_math/expected/schema_ruby.rb +1 -1
  99. data/golden/simple_math/expected/snast.txt +2 -2
  100. data/golden/streaming_basics/expected/nast.txt +8 -8
  101. data/golden/streaming_basics/expected/schema_ruby.rb +1 -1
  102. data/golden/streaming_basics/expected/snast.txt +1 -1
  103. data/golden/tuples/expected/lir_00_unoptimized.txt +5 -5
  104. data/golden/tuples/expected/lir_01_hoist_scalar_references.txt +5 -5
  105. data/golden/tuples/expected/lir_02_inlined.txt +5 -5
  106. data/golden/tuples/expected/lir_03_cse.txt +5 -5
  107. data/golden/tuples/expected/lir_04_1_loop_fusion.txt +5 -5
  108. data/golden/tuples/expected/lir_04_loop_invcm.txt +5 -5
  109. data/golden/tuples/expected/lir_06_const_prop.txt +5 -5
  110. data/golden/tuples/expected/nast.txt +4 -4
  111. data/golden/tuples/expected/schema_ruby.rb +1 -1
  112. data/golden/tuples/expected/snast.txt +6 -6
  113. data/golden/tuples_and_arrays/expected/lir_00_unoptimized.txt +1 -1
  114. data/golden/tuples_and_arrays/expected/lir_01_hoist_scalar_references.txt +1 -1
  115. data/golden/tuples_and_arrays/expected/lir_02_inlined.txt +2 -2
  116. data/golden/tuples_and_arrays/expected/lir_03_cse.txt +2 -2
  117. data/golden/tuples_and_arrays/expected/lir_04_1_loop_fusion.txt +2 -2
  118. data/golden/tuples_and_arrays/expected/lir_04_loop_invcm.txt +2 -2
  119. data/golden/tuples_and_arrays/expected/lir_06_const_prop.txt +2 -2
  120. data/golden/tuples_and_arrays/expected/nast.txt +3 -3
  121. data/golden/tuples_and_arrays/expected/schema_ruby.rb +1 -1
  122. data/golden/tuples_and_arrays/expected/snast.txt +2 -2
  123. data/golden/us_tax_2024/expected/ast.txt +63 -670
  124. data/golden/us_tax_2024/expected/input_plan.txt +8 -45
  125. data/golden/us_tax_2024/expected/lir_00_unoptimized.txt +253 -863
  126. data/golden/us_tax_2024/expected/lir_01_hoist_scalar_references.txt +253 -863
  127. data/golden/us_tax_2024/expected/lir_02_inlined.txt +1215 -5139
  128. data/golden/us_tax_2024/expected/lir_03_cse.txt +587 -2460
  129. data/golden/us_tax_2024/expected/lir_04_1_loop_fusion.txt +632 -2480
  130. data/golden/us_tax_2024/expected/lir_04_loop_invcm.txt +587 -2460
  131. data/golden/us_tax_2024/expected/lir_06_const_prop.txt +587 -2460
  132. data/golden/us_tax_2024/expected/nast.txt +123 -826
  133. data/golden/us_tax_2024/expected/schema_javascript.mjs +127 -581
  134. data/golden/us_tax_2024/expected/schema_ruby.rb +135 -610
  135. data/golden/us_tax_2024/expected/snast.txt +155 -858
  136. data/golden/us_tax_2024/expected.json +120 -1
  137. data/golden/us_tax_2024/input.json +18 -9
  138. data/golden/us_tax_2024/schema.kumi +48 -178
  139. data/golden/with_constants/expected/lir_00_unoptimized.txt +1 -1
  140. data/golden/with_constants/expected/lir_01_hoist_scalar_references.txt +1 -1
  141. data/golden/with_constants/expected/lir_02_inlined.txt +1 -1
  142. data/golden/with_constants/expected/lir_03_cse.txt +1 -1
  143. data/golden/with_constants/expected/lir_04_1_loop_fusion.txt +1 -1
  144. data/golden/with_constants/expected/lir_04_loop_invcm.txt +1 -1
  145. data/golden/with_constants/expected/lir_06_const_prop.txt +1 -1
  146. data/golden/with_constants/expected/nast.txt +2 -2
  147. data/golden/with_constants/expected/schema_ruby.rb +1 -1
  148. data/golden/with_constants/expected/snast.txt +2 -2
  149. data/lib/kumi/analyzer.rb +12 -12
  150. data/lib/kumi/core/analyzer/passes/formal_constraint_propagator.rb +236 -0
  151. data/lib/kumi/core/analyzer/passes/input_collector.rb +22 -4
  152. data/lib/kumi/core/analyzer/passes/nast_dimensional_analyzer_pass.rb +64 -18
  153. data/lib/kumi/core/analyzer/passes/normalize_to_nast_pass.rb +9 -4
  154. data/lib/kumi/core/analyzer/passes/snast_pass.rb +3 -1
  155. data/lib/kumi/core/analyzer/passes/unsat_detector.rb +172 -198
  156. data/lib/kumi/core/error_reporter.rb +36 -1
  157. data/lib/kumi/core/errors.rb +33 -1
  158. data/lib/kumi/core/functions/function_spec.rb +5 -4
  159. data/lib/kumi/core/functions/loader.rb +17 -1
  160. data/lib/kumi/core/functions/overload_resolver.rb +164 -0
  161. data/lib/kumi/core/functions/type_error_reporter.rb +118 -0
  162. data/lib/kumi/core/functions/type_rules.rb +155 -35
  163. data/lib/kumi/core/types/inference.rb +29 -22
  164. data/lib/kumi/core/types/normalizer.rb +29 -45
  165. data/lib/kumi/core/types/validator.rb +16 -27
  166. data/lib/kumi/core/types/value_objects.rb +116 -0
  167. data/lib/kumi/core/types.rb +45 -37
  168. data/lib/kumi/registry_v2/loader.rb +90 -0
  169. data/lib/kumi/registry_v2.rb +18 -1
  170. data/lib/kumi/version.rb +1 -1
  171. metadata +21 -7
  172. data/lib/kumi/core/analyzer/unsat_constant_evaluator.rb +0 -59
  173. data/lib/kumi/core/atom_unsat_solver.rb +0 -396
  174. data/lib/kumi/core/constraint_relationship_solver.rb +0 -641
  175. data/lib/kumi/core/types/builder.rb +0 -23
  176. data/lib/kumi/core/types/compatibility.rb +0 -96
  177. 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,6 +1,6 @@
1
1
  (NAST
2
2
  (VALUE v_sum_y
3
- (Call :"agg.sum"
3
+ (Call :sum
4
4
  (InputRef [:x, :y, :v])
5
5
  )
6
6
  )
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_9728a32b2ef1c73739b44f006d54b23230821bda76275eb804cd9ec4c91c3089
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 :"core.array_size"
3
+ (Call :array_size
4
4
  (InputRef [:x, :y])
5
5
  )
6
6
  )
7
7
  (VALUE box
8
- (Call :"core.add"
9
- (Call :"core.mul"
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 :"core.add"
18
- (Call :"core.mul"
17
+ (Call :add
18
+ (Call :multiply
19
19
  #<struct Kumi::Core::NAST::IndexRef id=91, loc=nil, meta={}>
20
- (Call :"core.array_size"
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 :"core.add"
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::KUMI_b0b7f061a7a0eedb52d282a806e7e102921f6ab3042667bd6fc6fc7f3a1018e2
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 :"core.mul"
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 :"core.mul"
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::KUMI_f6e8984aaae6be8cee0041865907ace29c189473e461ccf9db4a6bec97465dab
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
- (TRAIT is_valid_quantity
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
- (TRAIT expensive_items
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
- (TRAIT electronics
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::KUMI_68bc018c477a94cdfe07ac690bfacdebc9208a590b464f22d499aee7aafafd19
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
- (TRAIT y_positive
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
- (TRAIT x_positive
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 :"agg.sum"
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 :"agg.max"
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::KUMI_d345f8b5098b438aa322a7ee8d0a4d26f7c84aa9e453db79a0466b672d60fe36
2
+ module Kumi::Compiled::KUMI_e5b30cb23c39d5d7959274f41cf2d6a7e4ec0016dc7e19c0bef5c08d67ee1933
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -27,8 +27,8 @@
27
27
  )
28
28
  )
29
29
  (VALUE count_over_limit
30
- (Call :"agg.sum"
31
- (Call :"agg.sum"
30
+ (Call :sum
31
+ (Call :sum
32
32
  (Call :sum
33
33
  (Call :__select__
34
34
  (Ref cell_over_limit)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_2861f5d1d1e2c819036f9450880c9c966a10cf904bae70971a4845415ebaacf9
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
- (TRAIT cell_over_limit
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 :"agg.sum"
3
+ (Call :sum
4
4
  (InputRef [:regions, :region, :sales, :sale, :amount])
5
5
  )
6
6
  )
7
7
  (VALUE total_sales
8
- (Call :"agg.sum"
8
+ (Call :sum
9
9
  (Ref regional_sales)
10
10
  )
11
11
  )
12
12
  (VALUE adjusted_total
13
- (Call :"core.add"
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::KUMI_948ef2383d338bae98f165855c5c82984da1d3f936bcaca00b80221e19f34c6a
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,4 @@
1
+ name: string
2
+ items: array (array) access_mode=element
3
+ └─> value: element_access
4
+ value: integer
@@ -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,12 @@
1
+ export function _summary(input) {
2
+ let t8 = input["name"];
3
+ let t9 = t8.length;
4
+ let t10 = input["items"];
5
+ let t11 = t10.length;
6
+ let t7 = {
7
+ "name_length": t9,
8
+ "item_count": t11
9
+ };
10
+ return t7;
11
+ }
12
+
@@ -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,8 @@
1
+ {
2
+ "name": "test",
3
+ "items": [
4
+ { "value": 1 },
5
+ { "value": 2 },
6
+ { "value": 3 }
7
+ ]
8
+ }
@@ -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