Problem: binary_search

Your task is to implement the Binary Search algorithm (specifically the lower_bound variant) and verify its correctness in Dafny. You are given a sorted sequence of integers and a target value. The algorithm must find the first index $k$ such that $s[k] \ge target$ in $O(\log N)$ time logic (using a shrinking window). In the incomplete code, the specification is_sorted is provided. You must implement the standard binary search loop (while low < high) and prove that the returned index is the correct boundary. This requires a two-sided invariant: (1) Left Side: All elements to the left of the current window (0..low) are strictly less than the target. (2) Right Side: All elements to the right of the current window (high..|s|) are greater than or equal to the target.

// Following is the block for necessary definitions
// <preamble>
predicate is_sorted(s: seq<int>) {
    forall i, j {:trigger s[i], s[j]} :: 
        0 <= i <= j < |s| ==> s[i] <= s[j]
}
// </preamble>

// Following is the block for potential helper specifications
// <helpers>

// </helpers>

// Following is the block for proofs of lemmas
// <proofs>

// </proofs>

// Following is the block for the main specification
// <spec>
method binary_search_lower_bound(s: seq<int>, target: int) returns (result: int)
    requires |s| <= 0x7FFFFFFF
    requires is_sorted(s)
    ensures result >= 0
    ensures result <= |s|
    ensures forall i {:trigger s[i]} :: 0 <= i < result ==> s[i] < target
    ensures forall i {:trigger s[i]} :: result <= i < |s| ==> s[i] >= target
// </spec>
// <code>
{
    // Implement and verify the binary search for lower bound here.
}
// </code>

method main() {}