val compute_gen_elim_q (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot vprop) (decreases x)
val compute_gen_elim_q (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot vprop) (decreases x)
let rec compute_gen_elim_q
  (x: gen_elim_i)
: Tot (compute_gen_elim_a x -> Tot vprop)
  (decreases x)
= match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
  | GEUnit u -> fun _ -> compute_gen_unit_elim_q u
  | GEStarL left right -> fun v -> compute_gen_elim_q left (coerce_with_trefl v) `star` compute_gen_unit_elim_q right
  | GEStarR left right -> fun v -> compute_gen_unit_elim_q left `star` compute_gen_elim_q right (coerce_with_trefl v)
  | GEStar left right ->
    let tleft = compute_gen_elim_a left in
    let tright = compute_gen_elim_a right in
    fun v ->
      let v' : (tleft & tright) = coerce_with_trefl v in
      compute_gen_elim_q left (fstp #tleft #tright v') `star` compute_gen_elim_q right (sndp #tleft #tright v')
  | GEExistsNoAbs0 #a p -> fun v -> p (U.downgrade_val v)
  | GEExistsUnit0 #a p -> fun v -> compute_gen_unit_elim_q (p (U.downgrade_val v))
  | GEExists0 #a body ->
    let dept = (fun x -> compute_gen_elim_a (body x)) in
    fun v ->
    let v' : dtuple2 a dept = coerce_with_trefl v in
    compute_gen_elim_q
      (body (dfstp #a #dept v'))
      (dsndp #a #dept v')
  | GEExistsNoAbs1 #a p -> p
  | GEExistsUnit1 #a p -> fun v -> compute_gen_unit_elim_q (p v)
  | GEExists1 #a body ->
    let dept = (fun x -> compute_gen_elim_a (body x)) in
    fun v ->
    let v' : dtuple2 a dept = coerce_with_trefl v in
    compute_gen_elim_q
      (body (dfstp #a #dept v'))
      (dsndp #a #dept v')
module Steel.ST.GenElim1.Base
include Steel.ST.Util

module T = FStar.Tactics

let is_fvar     = Reflection.is_fvar
let is_any_fvar = Reflection.is_any_fvar

/// A tactic to automatically generate a unique binder

[@@erasable]
noeq
type gen_unit_elim_i
= | GUEId: (v: vprop) -> gen_unit_elim_i
  | GUEPure: (p: prop) -> gen_unit_elim_i
  | GUEStar: (left: gen_unit_elim_i) -> (right: gen_unit_elim_i) -> gen_unit_elim_i

[@@erasable]
noeq
type gen_elim_i =
  | GEUnit: (i: gen_unit_elim_i) -> gen_elim_i
  | GEStarL: (left: gen_elim_i) -> (right: gen_unit_elim_i) -> gen_elim_i
  | GEStarR: (left: gen_unit_elim_i) -> (right: gen_elim_i) -> gen_elim_i
  | GEStar: (left: gen_elim_i) -> (right: gen_elim_i) -> gen_elim_i
  | GEExistsNoAbs0: (#a: Type0) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
  | GEExistsUnit0: (#a: Type0) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
  | GEExists0: (#a: Type0) -> (body: (a -> gen_elim_i)) -> gen_elim_i
  | GEExistsNoAbs1: (#a: Type u#1) -> (body: (a -> vprop)) -> gen_elim_i // FIXME: generalize the universe
  | GEExistsUnit1: (#a: Type u#1) -> (body: (a -> gen_unit_elim_i)) -> gen_elim_i
  | GEExists1: (#a: Type u#1) -> (body: (a -> gen_elim_i)) -> gen_elim_i

val gen_elim_reduce: unit

[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_p
  (x: gen_unit_elim_i)
: Tot vprop
= match x with
  | GUEId v -> v
  | GUEPure p -> pure p
  | GUEStar left right -> compute_gen_unit_elim_p left `star` compute_gen_unit_elim_p right

[@@ gen_elim_reduce]
let rec compute_gen_unit_elim_q
  (x: gen_unit_elim_i)
: Tot vprop
= match x with
  | GUEId v -> v
  | GUEPure _ -> emp
  | GUEStar left right -> compute_gen_unit_elim_q left `star` compute_gen_unit_elim_q right

[@@gen_elim_reduce; noextract_to "Plugin"]
let rec compute_gen_unit_elim_post
  (x: gen_unit_elim_i)
: Tot prop
= match x with
  | GUEId _ -> True
  | GUEPure p -> p
  | GUEStar left right -> compute_gen_unit_elim_post left /\ compute_gen_unit_elim_post right

[@@gen_elim_reduce]
let rec compute_gen_elim_p
  (x: gen_elim_i)
: Tot vprop
= match x with
  | GEUnit i -> compute_gen_unit_elim_p i
  | GEStarL left right -> compute_gen_elim_p left `star` compute_gen_unit_elim_p right
  | GEStarR left right -> compute_gen_unit_elim_p left `star` compute_gen_elim_p right
  | GEStar left right -> compute_gen_elim_p left `star` compute_gen_elim_p right
  | GEExistsNoAbs0 #a p -> exists_ p
  | GEExistsUnit0 #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
  | GEExists0 #a body -> exists_ (fun x -> compute_gen_elim_p (body x))
  | GEExistsNoAbs1 #a p -> exists_ p
  | GEExistsUnit1 #a p -> exists_ (fun x -> compute_gen_unit_elim_p (p x))
  | GEExists1 #a body -> exists_ (fun x -> compute_gen_elim_p (body x))

let compute_gen_elim_p' = compute_gen_elim_p

module U = FStar.Universe

[@@ gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let rec compute_gen_elim_a
  (x: gen_elim_i)
: Tot (Type u#1)
= match x with
  | GEUnit _ -> U.raise_t unit
  | GEStarL left _ -> compute_gen_elim_a left
  | GEStarR _ right -> compute_gen_elim_a right
  | GEStar left right -> (compute_gen_elim_a left & compute_gen_elim_a right)
  | GEExistsNoAbs0 #a _
  | GEExistsUnit0 #a _ -> U.raise_t a
  | GEExists0 #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))
  | GEExistsNoAbs1 #a _
  | GEExistsUnit1 #a _ -> a
  | GEExists1 #a body -> dtuple2 a (fun x -> compute_gen_elim_a (body x))

[@@noextract_to "Plugin"]
let dfstp #a #b t = dfst #a #b t
[@@noextract_to "Plugin"]
let dsndp #a #b t = dsnd #a #b t
[@@noextract_to "Plugin"]
let fstp #a #b t = fst #a #b t
[@@noextract_to "Plugin"]
let sndp #a #b t = snd #a #b t

[@@gen_elim_reduce; __steel_reduce__; noextract_to "Plugin"]
let coerce_with_trefl (#tfrom #tto: Type) (x: tfrom) : Pure tto (requires (T.with_tactic T.trefl (tfrom == tto))) (ensures (fun _ -> True)) = x
/
Steel.ST.Util.fsti.checked Steel.Effect.Common.fsti.checked prims.fst.checked FStar.Universe.fsti.checked FStar.Tactics.fst.checked FStar.Reflection.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.List.Tot.fst.checked FStar.Ghost.fsti.checked
Steel.ST.GenElim1.Base.fsti
x: Steel.ST.GenElim1.Base.gen_elim_i
  -> Prims.Tot (_: Steel.ST.GenElim1.Base.compute_gen_elim_a x -> Steel.Effect.Common.vprop)
Steel.ST.GenElim1.Base.gen_elim_i Steel.ST.GenElim1.Base.compute_gen_elim_a Steel.Effect.Common.vprop Steel.ST.GenElim1.Base.gen_unit_elim_i Steel.ST.GenElim1.Base.GEUnit Steel.ST.GenElim1.Base.compute_gen_unit_elim_q Steel.ST.GenElim1.Base.GEStarL Steel.Effect.Common.star Steel.ST.GenElim1.Base.compute_gen_elim_q Steel.ST.GenElim1.Base.coerce_with_trefl Steel.ST.GenElim1.Base.GEStarR Steel.ST.GenElim1.Base.GEStar Steel.ST.GenElim1.Base.fstp Steel.ST.GenElim1.Base.sndp FStar.Pervasives.Native.tuple2 Steel.ST.GenElim1.Base.GEExistsNoAbs0 FStar.Universe.downgrade_val Steel.ST.GenElim1.Base.GEExistsUnit0 Steel.ST.GenElim1.Base.GEExists0 Steel.ST.GenElim1.Base.dfstp Steel.ST.GenElim1.Base.dsndp Prims.dtuple2 Steel.ST.GenElim1.Base.GEExistsUnit1 Steel.ST.GenElim1.Base.GEExists1
let rec compute_gen_elim_q (x: gen_elim_i) : Tot (compute_gen_elim_a x -> Tot vprop) (decreases x) =
  
match x as x' returns (compute_gen_elim_a x' -> Tot vprop) with
| GEUnit u -> fun _ -> compute_gen_unit_elim_q u
| GEStarL left right ->
  fun v -> (compute_gen_elim_q left (coerce_with_trefl v)) `star` (compute_gen_unit_elim_q right)
| GEStarR left right ->
  fun v -> (compute_gen_unit_elim_q left) `star` (compute_gen_elim_q right (coerce_with_trefl v))
| GEStar left right ->
  let tleft = compute_gen_elim_a left in
  let tright = compute_gen_elim_a right in
  fun v ->
    let v':(tleft & tright) = coerce_with_trefl v in
    (compute_gen_elim_q left (fstp #tleft #tright v'))
    `star`
    (compute_gen_elim_q right (sndp #tleft #tright v'))
| GEExistsNoAbs0 #a p -> fun v -> p (U.downgrade_val v)
| GEExistsUnit0 #a p -> fun v -> compute_gen_unit_elim_q (p (U.downgrade_val v))
| GEExists0 #a body ->
  let dept = (fun x -> compute_gen_elim_a (body x)) in
  fun v ->
    let v':dtuple2 a dept = coerce_with_trefl v in
    compute_gen_elim_q (body (dfstp #a #dept v')) (dsndp #a #dept v')
| GEExistsNoAbs1 #a p -> p
| GEExistsUnit1 #a p -> fun v -> compute_gen_unit_elim_q (p v)
| GEExists1 #a body ->
  let dept = (fun x -> compute_gen_elim_a (body x)) in
  fun v ->
    let v':dtuple2 a dept = coerce_with_trefl v in
    compute_gen_elim_q (body (dfstp #a #dept v')) (dsndp #a #dept v')