3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-23 16:57:51 +00:00

Document Loop function semantics and fix review comments

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-04 22:02:58 +00:00 committed by Nikolaj Bjorner
parent 6d3fe721b7
commit 185a639027
3 changed files with 291 additions and 1 deletions

View file

@ -1860,6 +1860,12 @@ export function createApi(Z3: Z3Core): Z3HighLevel {
return new ReImpl<SeqSortRef>(check(Z3.mk_re_range(contextPtr, loSeq.ast, hiSeq.ast)));
}
/**
* Create a bounded repetition regex.
* @param re The regex to repeat
* @param lo Minimum number of repetitions
* @param hi Maximum number of repetitions (0 means unbounded, i.e., at least lo)
*/
function Loop<SeqSortRef extends SeqSort<Name>>(re: Re<Name, SeqSortRef>, lo: number, hi: number = 0): Re<Name, SeqSortRef> {
return new ReImpl<SeqSortRef>(check(Z3.mk_re_loop(contextPtr, re.ast, lo, hi)));
}
@ -4195,6 +4201,11 @@ export function createApi(Z3: Z3Core): Z3HighLevel {
return new ReImpl<SeqSortRef>(check(Z3.mk_re_concat(contextPtr, [this.ast, other.ast])));
}
/**
* Create a bounded repetition of this regex
* @param lo Minimum number of repetitions
* @param hi Maximum number of repetitions (0 means unbounded, i.e., at least lo)
*/
loop(lo: number, hi: number = 0): Re<Name, SeqSortRef> {
return new ReImpl<SeqSortRef>(check(Z3.mk_re_loop(contextPtr, this.ast, lo, hi)));
}

View file

@ -886,7 +886,13 @@ export interface Context<Name extends string = 'main'> {
/** @category RegularExpression */
Range<SeqSortRef extends SeqSort<Name>>(lo: Seq<Name, SeqSortRef> | string, hi: Seq<Name, SeqSortRef> | string): Re<Name, SeqSortRef>;
/** @category RegularExpression */
/**
* Create a bounded repetition regex
* @param re The regex to repeat
* @param lo Minimum number of repetitions
* @param hi Maximum number of repetitions (0 means unbounded, i.e., at least lo)
* @category RegularExpression
*/
Loop<SeqSortRef extends SeqSort<Name>>(re: Re<Name, SeqSortRef>, lo: number, hi?: number): Re<Name, SeqSortRef>;
/** @category RegularExpression */
@ -3254,6 +3260,11 @@ export interface Re<Name extends string = 'main', SeqSortRef extends SeqSort<Nam
concat(other: Re<Name, SeqSortRef>): Re<Name, SeqSortRef>;
/** @category Operations */
/**
* Create a bounded repetition of this regex
* @param lo Minimum number of repetitions
* @param hi Maximum number of repetitions (0 means unbounded, i.e., at least lo)
*/
loop(lo: number, hi?: number): Re<Name, SeqSortRef>;
/** @category Operations */