val for_loop' (start:US.t)
              (finish:US.t { US.v start <= US.v finish })
              (current:US.t { US.v start <= US.v current /\
                               US.v current <= US.v finish })
              (inv: nat_at_most finish -> vprop)
              (body:
                    (i:u32_between start finish ->
                          SteelT unit
                          (inv (US.v i))
                          (fun _ -> inv (US.v i + 1))))
  : SteelT unit
      (inv (US.v current))
      (fun _ -> inv (US.v finish))
let rec for_loop' start finish current inv body
  = if current = finish then (
       AT.change_equal_slprop (inv _) (inv _);
       AT.return ()
    )
    else (
      let _: squash (US.v current < US.v finish) = () in //fails without this
      body current;
      let current' = US.(current +^ 1sz) in
      AT.change_equal_slprop (inv (US.v current + 1))
                             (inv (US.v current'));
      for_loop' start finish current' inv body
    )
val for_loop' (start:US.t)
              (finish:US.t { US.v start <= US.v finish })
              (current:US.t { US.v start <= US.v current /\
                               US.v current <= US.v finish })
              (inv: nat_at_most finish -> vprop)
              (body:
                    (i:u32_between start finish ->
                          SteelT unit
                          (inv (US.v i))
                          (fun _ -> inv (US.v i + 1))))
  : SteelT unit
      (inv (US.v current))
      (fun _ -> inv (US.v finish))
let rec for_loop' start finish current inv body =
if current = finish
then
  (AT.change_equal_slprop (inv _) (inv _);
    AT.return ())
else
  (let _:squash (US.v current < US.v finish) = () in
    body current;
    let current' = let open US in current +^ 1sz in
    AT.change_equal_slprop (inv (US.v current + 1)) (inv (US.v current'));
    for_loop' start finish current' inv body)
Steel.Loops.fst.checked
Steel.Reference.fsti.checked Steel.Memory.fsti.checked Steel.Effect.Common.fsti.checked Steel.Effect.Atomic.fsti.checked Steel.Effect.fsti.checked prims.fst.checked FStar.SizeT.fsti.checked FStar.Pervasives.fsti.checked
Steel.Loops.fst
FStar.SizeT.t Prims.b2t Prims.op_LessThanOrEqual FStar.SizeT.v Prims.l_and Steel.Loops.nat_at_most Steel.Effect.Common.vprop Steel.Loops.u32_between Prims.unit Prims.op_Addition Prims.op_Equality Prims.l_or Steel.Effect.Atomic.return FStar.Ghost.hide FStar.Set.set Steel.Memory.iname FStar.Set.empty Steel.Effect.Atomic.change_equal_slprop Prims.bool Steel.Loops.for_loop' FStar.SizeT.op_Plus_Hat FStar.SizeT.__uint_to_t Prims.squash Prims.op_LessThan
(*
   Copyright 2021 Microsoft Research

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*)
module Steel.Loops
open Steel.Memory
open Steel.Effect.Common
open Steel.Effect
open Steel.Reference
module AT = Steel.Effect.Atomic
module US = FStar.SizeT

val for_loop' (start:US.t)
              (finish:US.t { US.v start <= US.v finish })
              (current:US.t { US.v start <= US.v current /\
                               US.v current <= US.v finish })
              (inv: nat_at_most finish -> vprop)
              (body:
                    (i:u32_between start finish ->
                          SteelT unit
                          (inv (US.v i))
                          (fun _ -> inv (US.v i + 1))))
  : SteelT unit
      (inv (US.v current))
      (fun _ -> inv (US.v finish))

#push-options "--fuel 0 --ifuel 0"
val for_loop' (start:US.t)
              (finish:US.t { US.v start <= US.v finish })
              (current:US.t { US.v start <= US.v current /\
                               US.v current <= US.v finish })
              (inv: nat_at_most finish -> vprop)
              (body:
                    (i:u32_between start finish ->
                          SteelT unit
                          (inv (US.v i))
                          (fun _ -> inv (US.v i + 1))))
  : SteelT unit
      (inv (US.v current))
      (fun _ -> inv (US.v finish))

    start: FStar.SizeT.t ->
    finish: FStar.SizeT.t{FStar.SizeT.v start <= FStar.SizeT.v finish} ->
    current:
      FStar.SizeT.t
        { FStar.SizeT.v start <= FStar.SizeT.v current /\
          FStar.SizeT.v current <= FStar.SizeT.v finish } ->
    inv: (_: Steel.Loops.nat_at_most finish -> Steel.Effect.Common.vprop) ->
    body: (i: Steel.Loops.u32_between start finish -> Steel.Effect.SteelT Prims.unit)
  -> Steel.Effect.SteelT Prims.unit