Skip to content

Commit 24db579

Browse files
committed
refactor(core): parameterize mkSeqBoundsPrecond seq input name
Add `seqName : String := "s"` parameter so the helper no longer hardcodes the input variable name in a string literal three definitions away from the call sites that depend on it. All four current callers (`Sequence.{select,update,take,drop}`) name their `Sequence a` input `"s"` and use the default. A future partial Sequence op with a different input name need only pass it explicitly rather than rely on the hidden literal. Mismatches between a function's declared inputs and the names used in its preconditions remain caught at elaboration by `polyUneval`'s `h_precond` free-vars check; this change only reduces the code-distance between cause and effect. Cherry-pick target: PR #1100. The change sits inside #1100's `mkSeqBoundsPrecond`, so it belongs there. When #1100 lands and this branch rebases on main, the commit will be deduplicated automatically.
1 parent c85bec1 commit 24db579

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

Strata/Languages/Core/Factory.lean

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,19 @@ private def SeqBoundKind.upperOpExpr : SeqBoundKind → LExpr CoreLParams.mono
521521
| .Lt => (intLtFunc (T := CoreLParams)).opExpr
522522
| .Le => (intLeFunc (T := CoreLParams)).opExpr
523523

524-
/-- Precondition `0 <= varName && varName `k.upperOpExpr` Sequence.length(s)`.
525-
526-
Assumes the enclosing function names its `Sequence a` input `"s"`.
527-
Mismatches are caught at elaboration by `polyUneval`'s `h_precond`
528-
free-vars check. -/
524+
/-- Precondition `0 <= varName && varName `k.upperOpExpr` Sequence.length(seqName)`.
525+
526+
`seqName` defaults to `"s"` since all four current call sites
527+
(`Sequence.select`/`update`/`take`/`drop`) name their `Sequence a` input
528+
that way. The parameter exists so a future partial Sequence op with a
529+
different input name need only pass it explicitly rather than rely on a
530+
hidden string literal. Either way, mismatches between the function's
531+
declared inputs and the names used here are caught at elaboration by
532+
`polyUneval`'s `h_precond` free-vars check. -/
529533
private def mkSeqBoundsPrecond
530-
(varName : String) (k : SeqBoundKind) :
534+
(varName : String) (k : SeqBoundKind) (seqName : String := "s") :
531535
Strata.DL.Util.FuncPrecondition (LExpr CoreLParams.mono) CoreLParams.Metadata :=
532-
let sVar : LExpr CoreLParams.mono := .fvar default "s" (some (seqTy mty[%a]))
536+
let sVar : LExpr CoreLParams.mono := .fvar default seqName (some (seqTy mty[%a]))
533537
let xVar : LExpr CoreLParams.mono := .fvar default varName (some mty[int])
534538
let zero : LExpr CoreLParams.mono := .intConst default 0
535539
let lenS : LExpr CoreLParams.mono := .app default seqLengthFunc.opExpr sVar

0 commit comments

Comments
 (0)