Repository navigation
Conversation
Embed Fin n values as bounded Ints during preprocessing, including quantifiers and function input/output positions. Translate Nat casts to Int so embedded Fin values can be emitted as SMT integer terms. Add focused Fin regression tests and the expected output file for the intentional failures.
The Fin input rules rewrite `∀ f : … → Fin n → β, P f` only under `[NeZero n]`. For a symbolic `n` the instance cannot be synthesised, so the function keeps its `Fin n` argument; its applications then reach the solver as `ofIntFin n x h`, whose proof argument is cast through `Int.toNat_of_nonneg` and mentions the nonnegativity hypothesis that the Nat embedding introduces. `implies_congr_ctx` rejects that, and the solver sees an undeclared sort `n`. `forall_fin_in_as_int_inh₁` to `₅` rewrite such functions to functions over Int under `[Inhabited β]` instead: `extFin f b` is `f (ofIntFin n b hb)` where `0 ≤ b < n` and `default` elsewhere, and `extFin_cast` turns it back on embedded arguments. They hold for every `n`, including 0, and leave the `NeZero` rules in place. Test/Fin.lean adds five goals over a symbolic bound (a quantifier, a function input, a Nat-valued field, two arguments, an update preserving an invariant) and one that must fail. Assoc and Comm list the same counterexample in a different order.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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.
Fixes the SMT preprocessing failure in verse-lab/veil#173 for functions over
Fin nwhennis a variable, as in a Veil module withparam maxId : Natandfunction coverage : Fin maxId → Nat.What changes
Port of
Finembeddings in preprocessing ufmg-smite/lean-smt#229 (George Pîrlea'sFinembedding) onto this branch. Conflicts with the branch'smodulesystem andEmbeddingConfigwere resolved as follows:isFinTypeis gated byembedNat;modules.Symbolic bounds. The
Fininput rules require[NeZero n]. For a variablenthat instance is not found, so a functionf : Fin n → βkeeps itsFin nargument. Two errors follow:ofIntFin n x h, whose proof argument is cast throughInt.toNat_of_nonnegand mentions the Nat embedding'sn ≥ 0hypothesis.implies_congr_ctxthen rejects it ("Application type mismatch … expectedf ≥ 0 → ?q₁ = ?q₂");forall_fin_in_as_int_inh₁to₅rewrite such functions to functions overIntunder[Inhabited β]instead.extFin f bisf (ofIntFin n b hb)for0 ≤ b < nanddefaultelsewhere, andextFin_castturns it back on embedded arguments. The rules hold for everyn, including 0, and theNeZerorules are unchanged. Nosorry, nonative_decide.Tests
Test/Fin.leanadds six cases, each over a symbolic bound:lean --plugin=libcvc5_cvc5.so, comparing against.expected:lake script run test);Bool/AssocandBool/Commprint the same counterexample in a different order, and their.expectedfiles are updated, as inFinembeddings in preprocessing ufmg-smite/lean-smt#229.Fin maxId(the one in SMT preprocessing throws on Nat-valued fields over a Fin n domain veil#173):veil_smtandveil.smt.trust false;Finembeddings in preprocessing ufmg-smite/lean-smt#229 alone: 15 × the type mismatch above.Not covered
∀ i : Fin n, p i = p i, still fail in reconstruction withassumptionon⊢ n ≥ 0. That is a separate step.Fin nfor a variablenare not tested.