Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve
post2exePipeline: Recover 15 Refused Specs and Fix 8 Compilation FailuresSummary & Impact
Existing code generated executable checkers for 772/1007 problems using the direct backend, 69/1007 using the macro backend (
exec_spec_unverified), and failed for 166/1007 problems. By fixing systematic converter refusals, the direct backend now successfully generates executable code for 787/1007 problems, reducing failures from 166/1007 to 151/1007 (+15 problems recovered).Additionally, among the 772 directly generated executable checkers previously, 12 failed with compilation errors during test case evaluation. After fixing the root causes of these errors, compilation failures have been reduced from 12/772 down to just 4/787 (783/787 now compile cleanly, and all 15 newly generated checkers compile).
Key Metrics
Total code changes across
post2exe/gen_post2exe.pyandpost2exe/gen_test_post.py: +508 / -36 lines.High-Level Fix Overview
Detailed Fix Breakdown
1. Converter Refusal Fix (Fix F1)
Fix F1: Structural Recognition of Occurrence Counters & Multiset Lowering
F1unbounded forall binder v: i32(14 problems)unbounded forall binder v: int(1 problem)a.len() == b.len() && forall|v| count(a, v) == count(b, v)). Checking an unbounded quantifier over all"perm"/"multiset"and its body to contain the literal substring"count(". Only 1 problem in the corpus was namedcount; the other 15 usedcount_occ,count_int, orcount_char._occurrence_count_params,_occurrence_indicator_end,_occurrence_recursion_end). Loweredforall|v| count(a, v) == count(b, v)directly into Rust multiset equality (seq_to_multiset(a) == seq_to_multiset(b)).lc561,lc905,lc912,lc922,lc1122,lc1356,lc1460,lc1465,lc1502,lc1561,lc1589,lc1637,lc1984,lc2032,lc3285post2exe/gen_post2exe.py):_occurrence_count_params: lines 1836–1883_occurrence_indicator_end: lines 1711–1730_occurrence_recursion_end: lines 1731–1747_multiset_equality: lines 4539–4581_translate_function_impl2. Rust Compilation Fixes (Fixes F2 – F6)
Fix F2: Verus Operator Normalization ($\to$
=~~==~=)F2error: ~ cannot be used as a unary operator=~~=was emitted verbatim into the Rust code. Since~is not a valid unary operator in Rust,rustcfailed during parsing.=~~=to=~=in_comparison_op. Both lower to Rust's==operator, whose derivedPartialEqon owned vectors is already element-wise deep equality.lc566post2exe/gen_post2exe.py):_comparison_op: lines 1396–1399Fix F3: Support for
spec constDeclarationsF3error[E0425]: cannot find value KM_PER_LITER_SPECconstandpub const, ignoringpub spec const. The constant was referenced in expressions but never emitted in the generated Rust.specmodifier support ((?:spec\s+)?) to constant collection and parsing regexes in both converter and test generator scripts.lc2739post2exe/gen_post2exe.py:_translate_direct_const_line, lines 4985–4987 (+3)post2exe/gen_test_post.py:extract_const_lines, line 320 (+1)Fix F4: Scoped Binder Typing in Quantifier Body Translation
F4error[E0308]: mismatched typesi32) against an untyped binder (int/i64) caused the translator to omit the widening cast (as i64), triggering Rust type mismatches.finallyblock.lc932,lc1389,lc3152,cf1759Bpost2exe/gen_post2exe.py):translate_quantifier: lines 4611–4620Fix F5: Function Return Type Cast Alignment
F5error[E0308]: mismatched typesi32value (e.g. index element subtractions[k+1] - s[k]) but declared ani64return type were emitted without an explicit cast._translate_function_impl, wrapping the body in an explicit({body}) as {ret_ty}cast when differing integer types are detected.lc1200post2exe/gen_post2exe.py):_translate_function_impl: lines 2800, 2805–2808Fix F6: Type Coercion for Bitwise Operators
F6error[E0308]: mismatched types+no implementation for i32 ^ i64&,|,^) were missing from numeric pair coercion, emitting mixed integer operations such asi32 ^ i64.&,|, and^to the operator set calling_coerce_numeric_pairintranslate_binary.lc2997post2exe/gen_post2exe.py):translate_binary: line 34953. Complexity & Performance Optimizations (Fixes F7 – F8)
Fix F7: Occurrence Counter Emission as$O(n)$ Histogram Lookup
F7seq_drop_lastto clone the entire vector at every recursion level, while memoization hashed the full sequence. Anseq_to_multiset) keyed on the sequenceRcpointer address (_render_occurrence_count_fn), enablinglc2404(peak memory dropped from 2 GB to 9 MB).post2exe/gen_post2exe.py):_render_occurrence_count_fn: lines 1793–1835_translate_function_impl: lines 2781–2788Fix F8: Index-Pair Quantifier Lowering & Allocation-Keyed Memoization
F8forall|i, j| 0 <= i < j < n ==> a[i] != a[j]) defaulted toRcpointer allocation identity rather than hashing elements.lc3175(execution dropped from >600 s timeout to 4 s).post2exe/gen_post2exe.py):_index_pair_property: lines 4464–4538_seq_params_passed_through: lines 1762–1792_self_call_nodes: lines 1748–1761SEQ_KEY_HELPER: lines 1261–12814. Shared Support Infrastructure
Two shared modules support the fixes above:
post2exe/gen_post2exe.py, lines 1628–1710_block_value_node,_strip_casts,_int_literal_value,_method_call,_seq_end_read,_seq_end_droppedF1,F7,F8post2exe/gen_post2exe.py, lines 4830–4878_int_const_value,_cast_narrow_int_literals_to_i64i64bounds (such asusize::MAX) during comparisons instead of overflowing to negative values, allowinglc566to evaluate 228/228 test cases.