synalog 2.6.0__tar.gz → 2.7.0__tar.gz

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 (197) hide show
  1. {synalog-2.6.0 → synalog-2.7.0}/Cargo.lock +2 -2
  2. {synalog-2.6.0 → synalog-2.7.0}/Cargo.toml +1 -1
  3. {synalog-2.6.0 → synalog-2.7.0}/PKG-INFO +1 -1
  4. {synalog-2.6.0 → synalog-2.7.0}/docs/assertions.md +1 -0
  5. {synalog-2.6.0 → synalog-2.7.0}/pyproject.toml +1 -1
  6. {synalog-2.6.0 → synalog-2.7.0}/src/assertion/translate.rs +62 -0
  7. {synalog-2.6.0 → synalog-2.7.0}/uv.lock +1 -1
  8. {synalog-2.6.0 → synalog-2.7.0}/verified/Cargo.toml +1 -1
  9. {synalog-2.6.0 → synalog-2.7.0}/.gitignore +0 -0
  10. {synalog-2.6.0 → synalog-2.7.0}/LICENSE +0 -0
  11. {synalog-2.6.0 → synalog-2.7.0}/NOTICE +0 -0
  12. {synalog-2.6.0 → synalog-2.7.0}/README.md +0 -0
  13. {synalog-2.6.0 → synalog-2.7.0}/docs/assets/synalog-dark.svg +0 -0
  14. {synalog-2.6.0 → synalog-2.7.0}/docs/assets/synalog-light.svg +0 -0
  15. {synalog-2.6.0 → synalog-2.7.0}/docs/assets/synalog_favicon.png +0 -0
  16. {synalog-2.6.0 → synalog-2.7.0}/docs/benchmark/results.json +0 -0
  17. {synalog-2.6.0 → synalog-2.7.0}/docs/benchmark/speedup_by_engine.png +0 -0
  18. {synalog-2.6.0 → synalog-2.7.0}/docs/benchmark/speedup_distribution.png +0 -0
  19. {synalog-2.6.0 → synalog-2.7.0}/docs/benchmark/summary.md +0 -0
  20. {synalog-2.6.0 → synalog-2.7.0}/docs/benchmark/summary.png +0 -0
  21. {synalog-2.6.0 → synalog-2.7.0}/docs/benchmark/time_comparison.png +0 -0
  22. {synalog-2.6.0 → synalog-2.7.0}/docs/benchmark/verify_by_engine.png +0 -0
  23. {synalog-2.6.0 → synalog-2.7.0}/docs/benchmark.md +0 -0
  24. {synalog-2.6.0 → synalog-2.7.0}/docs/cli.md +0 -0
  25. {synalog-2.6.0 → synalog-2.7.0}/docs/development.md +0 -0
  26. {synalog-2.6.0 → synalog-2.7.0}/docs/differences-datalog.md +0 -0
  27. {synalog-2.6.0 → synalog-2.7.0}/docs/differences.md +0 -0
  28. {synalog-2.6.0 → synalog-2.7.0}/docs/engines.md +0 -0
  29. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/aggregation.l +0 -0
  30. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/aggregation.log +0 -0
  31. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/directives.l +0 -0
  32. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/directives.log +0 -0
  33. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/functions.l +0 -0
  34. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/functions.log +0 -0
  35. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/functors.l +0 -0
  36. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/functors.log +0 -0
  37. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/getting_started.l +0 -0
  38. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/getting_started.log +0 -0
  39. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/knowledge_graphs.l +0 -0
  40. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/knowledge_graphs.log +0 -0
  41. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/recursion.l +0 -0
  42. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/recursion.log +0 -0
  43. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/run.py +0 -0
  44. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/shop/concepts/customer.l +0 -0
  45. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/shop/concepts/order_status.l +0 -0
  46. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/shop/data/orders.csv +0 -0
  47. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/shop/layer.toml +0 -0
  48. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/shop/rules/customer_revenue.l +0 -0
  49. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/shop/rules/orders_by_status.l +0 -0
  50. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/shop/rules/top_customers.l +0 -0
  51. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/shop/tables/orders.l +0 -0
  52. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/shop.log +0 -0
  53. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/smoke/concepts/device.l +0 -0
  54. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/smoke/concepts/test_status.l +0 -0
  55. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/smoke/data/smoke_tests.csv +0 -0
  56. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/smoke/layer.toml +0 -0
  57. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/smoke/rules/failures_by_device.l +0 -0
  58. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/smoke/rules/runs_per_day.l +0 -0
  59. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/smoke/tables/smoke_tests.l +0 -0
  60. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/smoke.log +0 -0
  61. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/syntax.l +0 -0
  62. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/syntax.log +0 -0
  63. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/temporal.l +0 -0
  64. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/temporal.log +0 -0
  65. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/temporal_graph.l +0 -0
  66. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/temporal_graph.log +0 -0
  67. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/verification.l +0 -0
  68. {synalog-2.6.0 → synalog-2.7.0}/docs/examples/verification.log +0 -0
  69. {synalog-2.6.0 → synalog-2.7.0}/docs/getting-started.md +0 -0
  70. {synalog-2.6.0 → synalog-2.7.0}/docs/index.md +0 -0
  71. {synalog-2.6.0 → synalog-2.7.0}/docs/javascripts/playground.js +0 -0
  72. {synalog-2.6.0 → synalog-2.7.0}/docs/javascripts/summarize.js +0 -0
  73. {synalog-2.6.0 → synalog-2.7.0}/docs/javascripts/synalog-highlight.js +0 -0
  74. {synalog-2.6.0 → synalog-2.7.0}/docs/knowledge-graphs.md +0 -0
  75. {synalog-2.6.0 → synalog-2.7.0}/docs/language/aggregation.md +0 -0
  76. {synalog-2.6.0 → synalog-2.7.0}/docs/language/directives.md +0 -0
  77. {synalog-2.6.0 → synalog-2.7.0}/docs/language/functions.md +0 -0
  78. {synalog-2.6.0 → synalog-2.7.0}/docs/language/functors.md +0 -0
  79. {synalog-2.6.0 → synalog-2.7.0}/docs/language/index.md +0 -0
  80. {synalog-2.6.0 → synalog-2.7.0}/docs/language/recursion.md +0 -0
  81. {synalog-2.6.0 → synalog-2.7.0}/docs/language/syntax.md +0 -0
  82. {synalog-2.6.0 → synalog-2.7.0}/docs/language/temporal.md +0 -0
  83. {synalog-2.6.0 → synalog-2.7.0}/docs/playground/vendor/codemirror.js +0 -0
  84. {synalog-2.6.0 → synalog-2.7.0}/docs/playground.md +0 -0
  85. {synalog-2.6.0 → synalog-2.7.0}/docs/python-api.md +0 -0
  86. {synalog-2.6.0 → synalog-2.7.0}/docs/stylesheets/extra.css +0 -0
  87. {synalog-2.6.0 → synalog-2.7.0}/docs/verification.md +0 -0
  88. {synalog-2.6.0 → synalog-2.7.0}/docs/why.md +0 -0
  89. {synalog-2.6.0 → synalog-2.7.0}/img/synalog-dark.svg +0 -0
  90. {synalog-2.6.0 → synalog-2.7.0}/img/synalog-light.svg +0 -0
  91. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/__init__.py +0 -0
  92. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/__main__.py +0 -0
  93. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/checking.py +0 -0
  94. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/cli.py +0 -0
  95. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/config.py +0 -0
  96. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/execution.py +0 -0
  97. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/introspect.py +0 -0
  98. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/project.py +0 -0
  99. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/runners.py +0 -0
  100. {synalog-2.6.0 → synalog-2.7.0}/python/synalog/writes.py +0 -0
  101. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/SKILL.md +0 -0
  102. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/company/concepts/department.l +0 -0
  103. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/company/concepts/person.l +0 -0
  104. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/company/concepts/works_in.l +0 -0
  105. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/company/data/departments.csv +0 -0
  106. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/company/data/employees.csv +0 -0
  107. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/company/layer.toml +0 -0
  108. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/company/rules/team_mate.l +0 -0
  109. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/company/tables/departments.l +0 -0
  110. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/company/tables/employees.l +0 -0
  111. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/org/concepts/all_managers.l +0 -0
  112. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/org/data/employees.csv +0 -0
  113. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/org/layer.toml +0 -0
  114. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/org/tables/employees.l +0 -0
  115. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/sales/concepts/region.l +0 -0
  116. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/sales/data/sales.csv +0 -0
  117. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/sales/layer.toml +0 -0
  118. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/sales/rules/monthly_sales.l +0 -0
  119. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/sales/rules/top_region.l +0 -0
  120. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/sales/rules/total_by_region.l +0 -0
  121. {synalog-2.6.0 → synalog-2.7.0}/skills/synalog/examples/sales/tables/sales.l +0 -0
  122. {synalog-2.6.0 → synalog-2.7.0}/src/assertion/mod.rs +0 -0
  123. {synalog-2.6.0 → synalog-2.7.0}/src/assertion/parse.rs +0 -0
  124. {synalog-2.6.0 → synalog-2.7.0}/src/assertion/report.rs +0 -0
  125. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/annotations.rs +0 -0
  126. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/annotations_test.rs +0 -0
  127. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/dialects.rs +0 -0
  128. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/dialects_test.rs +0 -0
  129. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/expr_translate.rs +0 -0
  130. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/expr_translate_test.rs +0 -0
  131. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/functors.rs +0 -0
  132. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/functors_test.rs +0 -0
  133. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/home_guard.rs +0 -0
  134. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/home_guard_test.rs +0 -0
  135. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/mod.rs +0 -0
  136. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/rule_translate.rs +0 -0
  137. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/rule_translate_test.rs +0 -0
  138. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/type_inference/builder.rs +0 -0
  139. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/type_inference/built_in.rs +0 -0
  140. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/type_inference/edge.rs +0 -0
  141. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/type_inference/expression.rs +0 -0
  142. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/type_inference/graph.rs +0 -0
  143. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/type_inference/inference.rs +0 -0
  144. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/type_inference/intersection.rs +0 -0
  145. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/type_inference/mod.rs +0 -0
  146. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/type_inference/types.rs +0 -0
  147. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/universe.rs +0 -0
  148. {synalog-2.6.0 → synalog-2.7.0}/src/compiler/universe_test.rs +0 -0
  149. {synalog-2.6.0 → synalog-2.7.0}/src/errors.rs +0 -0
  150. {synalog-2.6.0 → synalog-2.7.0}/src/lib.rs +0 -0
  151. {synalog-2.6.0 → synalog-2.7.0}/src/parser/json.rs +0 -0
  152. {synalog-2.6.0 → synalog-2.7.0}/src/parser/json_test.rs +0 -0
  153. {synalog-2.6.0 → synalog-2.7.0}/src/parser/mod.rs +0 -0
  154. {synalog-2.6.0 → synalog-2.7.0}/src/parser/names.rs +0 -0
  155. {synalog-2.6.0 → synalog-2.7.0}/src/parser/parse.rs +0 -0
  156. {synalog-2.6.0 → synalog-2.7.0}/src/parser/parse_test.rs +0 -0
  157. {synalog-2.6.0 → synalog-2.7.0}/src/parser/rewrite.rs +0 -0
  158. {synalog-2.6.0 → synalog-2.7.0}/src/parser/rewrite_test.rs +0 -0
  159. {synalog-2.6.0 → synalog-2.7.0}/src/parser/span.rs +0 -0
  160. {synalog-2.6.0 → synalog-2.7.0}/src/parser/span_test.rs +0 -0
  161. {synalog-2.6.0 → synalog-2.7.0}/src/parser/traverse.rs +0 -0
  162. {synalog-2.6.0 → synalog-2.7.0}/src/parser/traverse_test.rs +0 -0
  163. {synalog-2.6.0 → synalog-2.7.0}/src/python.rs +0 -0
  164. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/arity.rs +0 -0
  165. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/assertions.rs +0 -0
  166. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/cast.rs +0 -0
  167. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/contradiction.rs +0 -0
  168. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/dependencies.rs +0 -0
  169. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/directives.rs +0 -0
  170. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/front_matter.rs +0 -0
  171. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/functors.rs +0 -0
  172. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/mod.rs +0 -0
  173. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/orderby.rs +0 -0
  174. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/positional.rs +0 -0
  175. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/recursion.rs +0 -0
  176. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/reserved.rs +0 -0
  177. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/safety.rs +0 -0
  178. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/sqlexpr.rs +0 -0
  179. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/stratification.rs +0 -0
  180. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/undefined.rs +0 -0
  181. {synalog-2.6.0 → synalog-2.7.0}/src/verifier/vars.rs +0 -0
  182. {synalog-2.6.0 → synalog-2.7.0}/src/wasm.rs +0 -0
  183. {synalog-2.6.0 → synalog-2.7.0}/verified/src/arity.rs +0 -0
  184. {synalog-2.6.0 → synalog-2.7.0}/verified/src/cast.rs +0 -0
  185. {synalog-2.6.0 → synalog-2.7.0}/verified/src/contradiction.rs +0 -0
  186. {synalog-2.6.0 → synalog-2.7.0}/verified/src/convergence.rs +0 -0
  187. {synalog-2.6.0 → synalog-2.7.0}/verified/src/home.rs +0 -0
  188. {synalog-2.6.0 → synalog-2.7.0}/verified/src/lib.rs +0 -0
  189. {synalog-2.6.0 → synalog-2.7.0}/verified/src/membership.rs +0 -0
  190. {synalog-2.6.0 → synalog-2.7.0}/verified/src/page.rs +0 -0
  191. {synalog-2.6.0 → synalog-2.7.0}/verified/src/plan.rs +0 -0
  192. {synalog-2.6.0 → synalog-2.7.0}/verified/src/quote.rs +0 -0
  193. {synalog-2.6.0 → synalog-2.7.0}/verified/src/recursion.rs +0 -0
  194. {synalog-2.6.0 → synalog-2.7.0}/verified/src/safety.rs +0 -0
  195. {synalog-2.6.0 → synalog-2.7.0}/verified/src/strata.rs +0 -0
  196. {synalog-2.6.0 → synalog-2.7.0}/verified/src/types.rs +0 -0
  197. {synalog-2.6.0 → synalog-2.7.0}/zensical.toml +0 -0
@@ -300,7 +300,7 @@ dependencies = [
300
300
 
301
301
  [[package]]
302
302
  name = "synalog"
303
- version = "2.6.0"
303
+ version = "2.7.0"
304
304
  dependencies = [
305
305
  "anyhow",
306
306
  "indexmap",
@@ -316,7 +316,7 @@ dependencies = [
316
316
 
317
317
  [[package]]
318
318
  name = "synalog-verified"
319
- version = "2.6.0"
319
+ version = "2.7.0"
320
320
  dependencies = [
321
321
  "vstd",
322
322
  ]
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "synalog"
3
- version = "2.6.0"
3
+ version = "2.7.0"
4
4
  edition = "2024"
5
5
  description = "Logic programming for AI agents: Datalog-family language compiling to optimized SQL"
6
6
  license = "Apache-2.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: synalog
3
- Version: 2.6.0
3
+ Version: 2.7.0
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: 3
@@ -193,6 +193,7 @@ Each assertion has a status, which `assertions()` reports:
193
193
  | Error | Cause | Fix |
194
194
  |-------|-------|-----|
195
195
  | `Invalid assertion 'P.name': …` | The statement does not parse, or applies a predicate to the wrong number of arguments | Fix the statement; count the predicate's columns |
196
+ | `Invalid assertion 'P.name': variable 'v' is quantified by '∀' but never used …` | A `∀`, `∃` or `∑` names a variable its formula never uses | Remove the variable, or use it where it was meant to appear |
196
197
  | `Duplicate assertion 'P.name': …` | The same name is stated twice for a predicate | Give each property its own name |
197
198
  | `Malformed @Assert: …` | The annotation is not `@Assert(Predicate, name: "statement", ...)` | One named argument per property |
198
199
  | `Assertion 'P.name' is violated: …` | The data holds a counterexample | Fix the rule, or the assertion if it was wrong |
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "synalog"
7
- version = "2.6.0"
7
+ version = "2.7.0"
8
8
  description = "Logic programming for AI agents: Datalog-family language compiling to optimized SQL"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -95,6 +95,15 @@ enum Lit {
95
95
  /// Translate `statement` into the rules of its counterexamples. `prefix` names
96
96
  /// the counterexample predicate and prefixes its helpers.
97
97
  pub fn translate(statement: &Expr, schema: &Schema, prefix: &str) -> Result<Translation> {
98
+ // Checked first: no rule added later can make this statement checkable.
99
+ if let Some((quantifier, var)) = unused_quantified(statement) {
100
+ return Err(TranslateError::Invalid(format!(
101
+ "variable '{var}' is quantified by '{quantifier}' but never used in the statement, \
102
+ so it has no values to check; remove it from '{quantifier}', or use it where it was \
103
+ meant to appear (often a second predicate application that repeats the first one's \
104
+ variables instead)"
105
+ )));
106
+ }
98
107
  let missing: Vec<String> = predicates(statement).into_iter().filter(|p| !schema.contains_key(p)).collect();
99
108
  if !missing.is_empty() {
100
109
  return Err(TranslateError::Missing(missing));
@@ -316,6 +325,41 @@ fn free_vars(expr: &Expr) -> Vec<String> {
316
325
  out
317
326
  }
318
327
 
328
+ /// The first variable a `∀`, `∃` or `∑` introduces that its body never names,
329
+ /// with that quantifier. The parser leaves variables as names (`App`).
330
+ fn unused_quantified(expr: &Expr) -> Option<(&'static str, &str)> {
331
+ fn names(expr: &Expr, var: &str) -> bool {
332
+ match expr {
333
+ Expr::Forall(vars, body) | Expr::Exists(vars, body) | Expr::Sum(vars, body) => {
334
+ !vars.iter().any(|v| v == var) && names(body, var)
335
+ }
336
+ Expr::Not(inner) | Expr::Neg(inner) => names(inner, var),
337
+ Expr::Binary(_, left, right) => names(left, var) || names(right, var),
338
+ // Applied (`e x`) still names it: that misuse has its own, clearer error.
339
+ Expr::App(name, args) => name == var || args.iter().any(|a| names(a, var)),
340
+ Expr::Var(name) => name == var,
341
+ Expr::Num(_) | Expr::Str(_) => false,
342
+ }
343
+ }
344
+ match expr {
345
+ Expr::Forall(vars, body) | Expr::Exists(vars, body) | Expr::Sum(vars, body) => {
346
+ let quantifier = match expr {
347
+ Expr::Forall(..) => "∀",
348
+ Expr::Exists(..) => "∃",
349
+ _ => "∑",
350
+ };
351
+ vars.iter()
352
+ .find(|v| !names(body, v))
353
+ .map(|v| (quantifier, v.as_str()))
354
+ .or_else(|| unused_quantified(body))
355
+ }
356
+ Expr::Not(inner) | Expr::Neg(inner) => unused_quantified(inner),
357
+ Expr::Binary(_, left, right) => unused_quantified(left).or_else(|| unused_quantified(right)),
358
+ Expr::App(_, args) => args.iter().find_map(unused_quantified),
359
+ Expr::Var(_) | Expr::Num(_) | Expr::Str(_) => None,
360
+ }
361
+ }
362
+
319
363
  /// Negation normal form of `expr`, or of its negation when `negate`.
320
364
  fn nnf(expr: &Expr, negate: bool) -> Nnf {
321
365
  match expr {
@@ -849,6 +893,24 @@ mod tests {
849
893
  assert!(matches!(error("∀ x y, Parent x y → ∃ u, u ≠ x"), TranslateError::Unsupported(_)));
850
894
  }
851
895
 
896
+ #[test]
897
+ fn a_quantified_variable_never_used_is_invalid() {
898
+ // The layer case: `m2 mm2` declared, the second atom reuses `m mm`.
899
+ let TranslateError::Invalid(reason) = error("∀ x y1 x2 y2, Parent x y1 ∧ Parent x y2 → y1 = y2") else {
900
+ panic!("expected Invalid");
901
+ };
902
+ assert!(reason.contains("variable 'x2' is quantified by '∀' but never used"), "{reason}");
903
+ assert!(matches!(error("∀ x y, Parent x y → ∃ w, Parent x y"), TranslateError::Invalid(_)));
904
+ // A variable shadowed by an inner quantifier is not a use of the outer one.
905
+ assert!(matches!(error("∀ x y z, Parent x y → ∃ z, Parent y z"), TranslateError::Invalid(_)));
906
+ // Reported before a missing predicate, which would only make it pending.
907
+ assert!(matches!(error("∀ x y, Unknown x"), TranslateError::Invalid(_)));
908
+ // A variable applied as a function is used: its own error reports it.
909
+ assert!(!matches!(error("∀ x e, Parent x (e x)"), TranslateError::Invalid(r) if r.contains("never used")));
910
+ // Every variable used: unchanged.
911
+ rules("∀ x y1 y2, Parent x y1 ∧ Parent x y2 → y1 = y2");
912
+ }
913
+
852
914
  #[test]
853
915
  fn test_implication_chain() {
854
916
  assert_eq!(
@@ -3281,7 +3281,7 @@ wheels = [
3281
3281
 
3282
3282
  [[package]]
3283
3283
  name = "synalog"
3284
- version = "2.6.0"
3284
+ version = "2.7.0"
3285
3285
  source = { editable = "." }
3286
3286
  dependencies = [
3287
3287
  { name = "click" },
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "synalog-verified"
3
- version = "2.6.0"
3
+ version = "2.7.0"
4
4
  edition = "2024"
5
5
  description = "Synalog's graph algorithms, proved correct with Verus"
6
6
  license = "Apache-2.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes