val get_constant_lemma :world:Type
                                -> p:Type0
                                -> Lemma (get #world (fun _ -> p) <==> p)
let get_constant_lemma world p = get_set_axiom #world p
val get_constant_lemma :world:Type
                                -> p:Type0
                                -> Lemma (get #world (fun _ -> p) <==> p)
let get_constant_lemma world p =
get_set_axiom #world p
FStar.Monotonic.Witnessed.fst.checked
prims.fst.checked FStar.Preorder.fst.checked FStar.Pervasives.fsti.checked FStar.Classical.fsti.checked
FStar.Monotonic.Witnessed.fst
FStar.Monotonic.Witnessed.get_set_axiom Prims.unit
(*
   Copyright 2008-2018 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 FStar.Monotonic.Witnessed

open FStar.Preorder

(* NOT EXPOSED BY THE INTERFACE [start] *)

(* 
   A hybrid modal extension to F*'s classical reasoning logic:
     - extends F*'s logic with two hybrid modal operators (get, set)
     - extends F*'s logic with corresponding logical axioms, based
       on the Kripke semantics of these two hybrid modal operators:

         w |= get p   iff   w |= p w

         w |= set p w'   iff   w' |= p

    We do not expose these modal operators to the users directly.
    Instead we use them below to define the 'witnessed' modality 
    which is the basis of reasoning about monotonic state in F*, 
    as discussed in Ahman et al.'s POPL 2018 paper "Recalling a 
    Witness: Foundations and Applications of Monotonic State".
*)

(* Hybrid modal operators *)
assume private type get : #world:Type -> (world -> Type0) -> Type0
assume private type set : #world:Type -> Type0 -> world -> Type0

(* Weakening for the get operator *)
assume val get_weakening :#world:Type
                          -> p:(world -> Type0)
                          -> q:(world -> Type0)
                          -> Lemma (requires (forall w. p w ==> q w))
                                  (ensures  (get p ==> get q))
                                  [SMTPat (get p); SMTPat (get q)]

(* Interaction axioms between the get and set operators *)
assume val get_set_axiom :#world:Type
                          -> p:Type0
                          -> Lemma (get (set #world p) <==> p)
                                  [SMTPat (get (set #world p))]

assume val set_get_axiom :#world:Type
                          -> w:world
                          -> p:(world -> Type0)
                          -> Lemma (set (get p) w <==> set (p w) w)
                                  [SMTPat (set (get p) w)]

assume val set_set_axiom :#world:Type
                          -> w:world
                          -> w':world
                          -> p:Type0
                          -> Lemma (set (set p w') w <==> set p w')
                                  [SMTPat (set (set p w') w)]

(* Useful derivable get lemma *)

private val get_constant_lemma :world:Type
                                -> p:Type0
val get_constant_lemma :world:Type
                                -> p:Type0
                                -> Lemma (get #world (fun _ -> p) <==> p)
world: Type -> p: Type0
  -> FStar.Pervasives.Lemma (ensures FStar.Monotonic.Witnessed.get (fun _ -> p) <==> p)