val false_elim (#a: Type) (f: False) : Tot a
let false_elim (#a:Type) (f:False) : Tot a
  = match f with
val false_elim (#a: Type) (f: False) : Tot a
let false_elim (#a: Type) (f: False) : Tot a =
match f with
FStar.SquashProperties.fst.checked
prims.fst.checked FStar.Squash.fsti.checked FStar.Pervasives.fsti.checked FStar.Constructive.fst.checked
FStar.SquashProperties.fst
Prims.l_False
(*
   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.SquashProperties

open FStar.Constructive

open FStar.Squash

val join_squash : #a:Type -> squash (squash a) -> GTot (squash a)
let join_squash #a s = bind_squash #(squash a) #a s (fun x -> x)

val squash_arrow : #a:Type -> #p:(a -> Type) ->
  $f:(x:a -> GTot (squash (p x))) -> GTot (squash (x:a -> GTot (p x)))
let squash_arrow #a #p f = squash_double_arrow (return_squash f)

val forall_intro : #a:Type -> #p:(a -> Type) ->
  $f:(x:a -> Lemma (p x)) -> Lemma (x:a -> GTot (p x))(* (forall (x:a). p x) *)
let forall_intro #a #p f =
  let ff : (x:a -> GTot (squash (p x))) = (fun x -> f x; get_proof (p x)) in
  give_proof #(x:a -> GTot (p x)) (squash_arrow #a #p ff)


// currently unused
// val squash_elim : a:Type -> #b:Type -> t1:b -> t2:b ->
//       (       a -> Tot (ceq t1 t2)) ->
//   Tot (squash a -> Tot (ceq t1 t2))

(* assume val tt (t:Type) : squash t *)

(* assume val squash_mem_elim : a:Type -> #b:Type -> t1:b -> t2:b -> *)
(*       (x:squash a -> t:(squash a -> Type) -> Tot (t ())) -> *)
(*   Tot (x:squash a -> t:(squash a -> Type) -> Tot (t x)) *)

(* get_proof and give_proof are phrased in terms of squash *)

(* The whole point of defining squash is to soundly allow define excluded_middle;
   here this follows from get_proof and give_proof *)

val bool_of_or : #p:Type -> #q:Type -> Prims.sum p q ->
  Tot (b:bool{(b ==> p) /\ (not(b) ==> q)})
let bool_of_or #p #q t =
  match t with
  | Prims.Left  _ -> true
  | Prims.Right _ -> false

val excluded_middle : p:Type -> GTot (squash (b:bool{b <==> p}))
let excluded_middle (p:Type) = map_squash (join_squash (get_proof (p \/ (~p)))) bool_of_or


val excluded_middle_squash : p:Type0 -> GTot (p \/ ~p)
let excluded_middle_squash p =
  bind_squash (excluded_middle p) (fun x ->
  if x then
    map_squash (get_proof p) (Prims.Left #p)
  else
    return_squash (Prims.Right #_ #(~p) (return_squash (fun (h:p) ->
                                   give_proof (return_squash h);
                                   false_elim #False ()))))

(* we thought we might prove proof irrelevance by Berardi ... but didn't manage *)

(* Conditional on any Type -- unused below *)
val ifProp: #p:Type0 -> b:Type0 -> e1:squash p -> e2:squash p -> GTot (squash p)
let ifProp #p b e1 e2 =
   bind_squash (excluded_middle_squash b) 
	       (fun (x:Prims.sum b (~ b)) -> 
		match x with
	        | Prims.Left _ -> e1
		| Prims.Right _ -> e2)

(* The powerset operator *)
type pow (p:Type) = p -> GTot bool

noeq type retract 'a 'b : Type =
  | MkR: i:('a -> GTot 'b) ->
         j:('b -> GTot 'a) ->
         inv:(x:'a -> GTot (ceq (j (i x)) x)) ->
         retract 'a 'b

noeq type retract_cond 'a 'b : Type =
  | MkC: i2:('a -> GTot 'b) ->
         j2:('b -> GTot 'a) ->
         inv2:(retract 'a 'b -> x:'a -> GTot (ceq (j2 (i2 x)) x)) ->
         retract_cond 'a 'b

(* unused below *)
val ac: r:retract_cond 'a 'b -> retract 'a 'b -> x:'a ->
          GTot (ceq ((MkC?.j2 r) (MkC?.i2 r x)) x)
let ac (MkC _ _ inv2) = inv2
val false_elim (#a: Type) (f: False) : Tot a
f: Prims.l_False -> a