val append_among_gvars_s2_only_preserves_write_buffers_match_except_global_variables
      (vs: list var_id_t)
      (write_buffer1 write_buffer2: seq write_message_t)
      (write_message: write_message_t)
    : Lemma
      (requires
        write_buffers_match_except_global_variables vs write_buffer1 write_buffer2 /\
        pointer_among_global_variables vs write_message.location)
      (ensures
        (let write_buffer2' = build write_buffer2 write_message in
          write_buffers_match_except_global_variables vs write_buffer1 write_buffer2'))
      (decreases length write_buffer1 + length write_buffer2)
val append_among_gvars_s2_only_preserves_write_buffers_match_except_global_variables
      (vs: list var_id_t)
      (write_buffer1 write_buffer2: seq write_message_t)
      (write_message: write_message_t)
    : Lemma
      (requires
        write_buffers_match_except_global_variables vs write_buffer1 write_buffer2 /\
        pointer_among_global_variables vs write_message.location)
      (ensures
        (let write_buffer2' = build write_buffer2 write_message in
          write_buffers_match_except_global_variables vs write_buffer1 write_buffer2'))
      (decreases length write_buffer1 + length write_buffer2)
let append_among_gvars_s2_only_preserves_write_buffers_match_except_global_variables
  (vs: list var_id_t)
  (write_buffer1: seq write_message_t)
  (write_buffer2: seq write_message_t)
  (write_message: write_message_t)
  : Lemma (requires   write_buffers_match_except_global_variables vs write_buffer1 write_buffer2
                    /\ pointer_among_global_variables vs write_message.location)
          (ensures  (let write_buffer2' = build write_buffer2 write_message in
                     write_buffers_match_except_global_variables vs write_buffer1 write_buffer2'))
          (decreases length write_buffer1 + length write_buffer2) =
  build_equivalent_to_append write_buffer2 write_message;
  append_among_gvars_s2_only_preserves_write_buffer_lists_match_except_global_variables vs (seq_to_list write_buffer1)
    (seq_to_list write_buffer2) write_message
module Strategies.GlobalVars.VarIntro

open Armada.Base
open Armada.BinaryOp
open Armada.Computation
open Armada.Expression
open Armada.Init
open Armada.Memory
open Armada.Pointer
open Armada.State
open Armada.Statement
open Armada.Thread
open Armada.Type
open Armada.UnaryOp
open FStar.Sequence.Ambient
open FStar.Sequence.Base
open Spec.List
open Spec.Ubool
open Strategies.ArmadaInvariant.PositionsValid
open Strategies.ArmadaInvariant.RootsMatch
open Strategies.GlobalVars
open Strategies.GlobalVars.Pointer
open Strategies.GlobalVars.Unaddressed
open Strategies.GlobalVars.Util
open Strategies.PCRelation
open Util.Seq
open Util.Trigger

let rec pointer_among_gvars_implies_gvars_addressed
  (vs: list var_id_t)
  (p: Armada.Pointer.t)
  : Lemma (requires pointer_among_global_variables vs p)
          (ensures  not (global_variables_unaddressed_in_pointer vs p)) =
  match p with
  | PointerUninitialized -> ()
  | PointerNull -> ()
  | PointerRoot root_id -> ()
  | PointerField struct_ptr _ -> pointer_among_gvars_implies_gvars_addressed vs struct_ptr
  | PointerIndex array_ptr _ -> pointer_among_gvars_implies_gvars_addressed vs array_ptr
  
let append_among_gvars_s2_only_preserves_write_buffer_lists_match_except_global_variables
  (vs: list var_id_t)
  (write_buffer1: list write_message_t)
  (write_buffer2: list write_message_t)
  (write_message: write_message_t)
  : Lemma (requires   write_buffers_match (remove_global_variables_from_write_buffer vs write_buffer1)
                        (remove_global_variables_from_write_buffer vs write_buffer2)
                    /\ pointer_among_global_variables vs write_message.location)
          (ensures  (let write_buffer2' = FStar.List.Tot.append write_buffer2 [write_message] in
                     write_buffers_match (remove_global_variables_from_write_buffer vs write_buffer1)
                       (remove_global_variables_from_write_buffer vs write_buffer2'))) =
  pointer_among_gvars_implies_gvars_addressed vs write_message.location;
  append_effect_on_remove_global_variables_from_write_buffer_list vs write_buffer2 write_message
/
Util.Trigger.fst.checked Util.Seq.fsti.checked Strategies.PCRelation.fst.checked Strategies.GlobalVars.Util.fst.checked Strategies.GlobalVars.Unaddressed.fst.checked Strategies.GlobalVars.Pointer.fst.checked Strategies.GlobalVars.fst.checked Strategies.ArmadaInvariant.RootsMatch.fst.checked Strategies.ArmadaInvariant.PositionsValid.fsti.checked Spec.Ubool.fst.checked Spec.Map.fst.checked Spec.List.fst.checked prims.fst.checked FStar.Sequence.Base.fsti.checked FStar.Sequence.Ambient.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.List.Tot.fst.checked FStar.Classical.Sugar.fsti.checked Armada.UnaryOp.fst.checked Armada.Type.fst.checked Armada.Threads.fst.checked Armada.Thread.fst.checked Armada.Statement.fst.checked Armada.State.fst.checked Armada.Pointer.fst.checked Armada.Memory.fst.checked Armada.Init.fst.checked Armada.Expression.fst.checked Armada.Computation.fst.checked Armada.BinaryOp.fst.checked Armada.Base.fst.checked
Strategies.GlobalVars.VarIntro.fst

    vs: Prims.list Armada.Base.var_id_t ->
    write_buffer1: FStar.Sequence.Base.seq Armada.Thread.write_message_t ->
    write_buffer2: FStar.Sequence.Base.seq Armada.Thread.write_message_t ->
    write_message: Armada.Thread.write_message_t
  -> FStar.Pervasives.Lemma
      (requires
        Strategies.GlobalVars.write_buffers_match_except_global_variables vs
          write_buffer1
          write_buffer2 /\
        Strategies.GlobalVars.VarIntro.pointer_among_global_variables vs
          (Mkwrite_message_t?.location write_message))
      (ensures
        (let write_buffer2' = FStar.Sequence.Base.build write_buffer2 write_message in
          Strategies.GlobalVars.write_buffers_match_except_global_variables vs
            write_buffer1
            write_buffer2'))
      (decreases FStar.Sequence.Base.length write_buffer1 + FStar.Sequence.Base.length write_buffer2
      )
Prims.list Armada.Base.var_id_t FStar.Sequence.Base.seq Armada.Thread.write_message_t Strategies.GlobalVars.VarIntro.append_among_gvars_s2_only_preserves_write_buffer_lists_match_except_global_variables Util.Seq.seq_to_list Prims.unit Util.Seq.build_equivalent_to_append Prims.op_Addition FStar.Sequence.Base.length Prims.l_and Strategies.GlobalVars.write_buffers_match_except_global_variables Prims.b2t Strategies.GlobalVars.VarIntro.pointer_among_global_variables Armada.Thread.__proj__Mkwrite_message_t__item__location Prims.squash FStar.Sequence.Base.build Prims.Nil FStar.Pervasives.pattern
let append_among_gvars_s2_only_preserves_write_buffers_match_except_global_variables
      (vs: list var_id_t)
      (write_buffer1 write_buffer2: seq write_message_t)
      (write_message: write_message_t)
    : Lemma
      (requires
        write_buffers_match_except_global_variables vs write_buffer1 write_buffer2 /\
        pointer_among_global_variables vs write_message.location)
      (ensures
        (let write_buffer2' = build write_buffer2 write_message in
          write_buffers_match_except_global_variables vs write_buffer1 write_buffer2'))
      (decreases length write_buffer1 + length write_buffer2) =
  
build_equivalent_to_append write_buffer2 write_message;
append_among_gvars_s2_only_preserves_write_buffer_lists_match_except_global_variables vs
  (seq_to_list write_buffer1)
  (seq_to_list write_buffer2)
  write_message