val ite_wp (#a: Type) (wp_then wp_else: pure_wp a) (b: bool) : pure_wp a
val ite_wp (#a: Type) (wp_then wp_else: pure_wp a) (b: bool) : pure_wp a
let ite_wp (#a:Type) (wp_then wp_else:pure_wp a) (b:bool) : pure_wp a =
  elim_pure_wp_monotonicity_forall ();
  as_pure_wp (fun p -> (b ==> wp_then p) /\ ((~ b) ==> wp_else p))
(*
   Copyright 2008-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 IteSoundness

(*
 * This module intentionally admits goals etc., so silence warnings
 *)
#set-options "--warn_error -274 --warn_error -296 --warn_error -242"

(*
 * This module provides unit tests for checking the soundness of the layered
 *   effects if-then-else combinator using a tactic
 *)

open FStar.Tactics.V2

let unit : Type0 = unit
irreducible let an_attr : unit = ()

(*
 * First a layer over PURE
 * This works without the tactic too, but just to illustrate
 *)

type repr (a:Type) (wp:pure_wp a) = unit -> PURE a wp

open FStar.Monotonic.Pure

unfold
let return_wp (#a:Type) (x:a) : pure_wp a = as_pure_wp (fun p -> p x)
let return (a:Type) (x:a) : repr a (return_wp x) = fun () -> x

unfold
let bind_wp (#a #b:Type) (wp1:pure_wp a) (wp2:a -> pure_wp b) : pure_wp b =
  elim_pure_wp_monotonicity_forall ();
  as_pure_wp (fun p -> wp1 (fun x -> wp2 x p))
let bind (a b:Type) (wp1:pure_wp a) (wp2:a -> pure_wp b)
  (f:repr a wp1)
  (g:(x:a -> repr b (wp2 x)))
  : repr b (bind_wp wp1 wp2)
  = FStar.Monotonic.Pure.elim_pure_wp_monotonicity_forall ();
    fun () ->
    let x = f () in
    g x ()

let subcomp (a:Type) (wp1 wp2:pure_wp a) (f:repr a wp1)
  : Pure (repr a wp2)
      (requires forall p. wp2 p ==> wp1 p)
      (ensures fun _ -> True)
  = f
/
prims.fst.checked FStar.Tactics.V2.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.Monotonic.Pure.fst.checked
IteSoundness.fst
wp_then: Prims.pure_wp a -> wp_else: Prims.pure_wp a -> b: Prims.bool -> Prims.pure_wp a
Prims.pure_wp Prims.bool FStar.Monotonic.Pure.as_pure_wp Prims.pure_post Prims.l_and Prims.l_imp Prims.b2t Prims.l_not Prims.pure_pre Prims.unit FStar.Monotonic.Pure.elim_pure_wp_monotonicity_forall
let ite_wp (#a: Type) (wp_then wp_else: pure_wp a) (b: bool) : pure_wp a =
  
elim_pure_wp_monotonicity_forall ();
as_pure_wp (fun p -> (b ==> wp_then p) /\ ((~b) ==> wp_else p))