(* This file was originally generated by why.
   It can be modified; only the generated parts will be overwritten. *)

Require Export swap_spec_why.

(* Why obligation from file "/home/cmarche/recherche/why/examples-c/tutorial/swap.c", line 5, characters 12-16: *)
(*Why goal*) Lemma swap_impl_po_1 : 
  forall (t: (pointer global)),
  forall (i: Z),
  forall (j: Z),
  forall (alloc: alloc_table),
  forall (HW_1: (* CADUCEUS_1 *) ((valid_index alloc t i) /\
                (valid_index alloc t j))),
  forall (result: (pointer global)),
  forall (HW_2: result = (shift t i)),
  (valid alloc result).
Proof.
intuition.
subst; auto.
Save.

(* Why obligation from file "/home/cmarche/recherche/why/examples-c/tutorial/swap.c", line 6, characters 9-13: *)
(*Why goal*) Lemma swap_impl_po_2 : 
  forall (t: (pointer global)),
  forall (i: Z),
  forall (j: Z),
  forall (alloc: alloc_table),
  forall (intM_global: (memory Z global)),
  forall (HW_1: (* CADUCEUS_1 *) ((valid_index alloc t i) /\
                (valid_index alloc t j))),
  forall (result: (pointer global)),
  forall (HW_2: result = (shift t i)),
  forall (HW_3: (valid alloc result)),
  forall (result0: Z),
  forall (HW_4: result0 = (acc intM_global result)),
  forall (result1: (pointer global)),
  forall (HW_5: result1 = (shift t i)),
  forall (result2: (pointer global)),
  forall (HW_6: result2 = (shift t j)),
  (valid alloc result2).
Proof.
intuition; subst; auto.
Save.

(* Why obligation from file "/home/cmarche/recherche/why/examples-c/tutorial/swap.c", line 6, characters 2-6: *)
(*Why goal*) Lemma swap_impl_po_3 : 
  forall (t: (pointer global)),
  forall (i: Z),
  forall (j: Z),
  forall (alloc: alloc_table),
  forall (intM_global: (memory Z global)),
  forall (HW_1: (* CADUCEUS_1 *) ((valid_index alloc t i) /\
                (valid_index alloc t j))),
  forall (result: (pointer global)),
  forall (HW_2: result = (shift t i)),
  forall (HW_3: (valid alloc result)),
  forall (result0: Z),
  forall (HW_4: result0 = (acc intM_global result)),
  forall (result1: (pointer global)),
  forall (HW_5: result1 = (shift t i)),
  forall (result2: (pointer global)),
  forall (HW_6: result2 = (shift t j)),
  forall (HW_7: (valid alloc result2)),
  forall (result3: Z),
  forall (HW_8: result3 = (acc intM_global result2)),
  (valid alloc result1).
Proof.
intuition;subst;auto.
Save.

(* Why obligation from file "/home/cmarche/recherche/why/examples-c/tutorial/swap.c", line 7, characters 2-6: *)
(*Why goal*) Lemma swap_impl_po_4 : 
  forall (t: (pointer global)),
  forall (i: Z),
  forall (j: Z),
  forall (alloc: alloc_table),
  forall (intM_global: (memory Z global)),
  forall (HW_1: (* CADUCEUS_1 *) ((valid_index alloc t i) /\
                (valid_index alloc t j))),
  forall (result: (pointer global)),
  forall (HW_2: result = (shift t i)),
  forall (HW_3: (valid alloc result)),
  forall (result0: Z),
  forall (HW_4: result0 = (acc intM_global result)),
  forall (result1: (pointer global)),
  forall (HW_5: result1 = (shift t i)),
  forall (result2: (pointer global)),
  forall (HW_6: result2 = (shift t j)),
  forall (HW_7: (valid alloc result2)),
  forall (result3: Z),
  forall (HW_8: result3 = (acc intM_global result2)),
  forall (HW_9: (valid alloc result1)),
  forall (intM_global0: (memory Z global)),
  forall (HW_10: intM_global0 = (upd intM_global result1 result3)),
  forall (result4: (pointer global)),
  forall (HW_11: result4 = (shift t j)),
  (valid alloc result4).
Proof.
intuition.
subst; auto.
Save.

(* Why obligation from file "/home/cmarche/recherche/why/examples-c/tutorial/swap.c", line 2, characters 12-52: *)
(*Why goal*) Lemma swap_impl_po_5 : 
  forall (t: (pointer global)),
  forall (i: Z),
  forall (j: Z),
  forall (alloc: alloc_table),
  forall (intM_global: (memory Z global)),
  forall (HW_1: (* CADUCEUS_1 *) ((valid_index alloc t i) /\
                (valid_index alloc t j))),
  forall (result: (pointer global)),
  forall (HW_2: result = (shift t i)),
  forall (HW_3: (valid alloc result)),
  forall (result0: Z),
  forall (HW_4: result0 = (acc intM_global result)),
  forall (result1: (pointer global)),
  forall (HW_5: result1 = (shift t i)),
  forall (result2: (pointer global)),
  forall (HW_6: result2 = (shift t j)),
  forall (HW_7: (valid alloc result2)),
  forall (result3: Z),
  forall (HW_8: result3 = (acc intM_global result2)),
  forall (HW_9: (valid alloc result1)),
  forall (intM_global0: (memory Z global)),
  forall (HW_10: intM_global0 = (upd intM_global result1 result3)),
  forall (result4: (pointer global)),
  forall (HW_11: result4 = (shift t j)),
  forall (HW_12: (valid alloc result4)),
  forall (intM_global1: (memory Z global)),
  forall (HW_13: intM_global1 = (upd intM_global0 result4 result0)),
  (* CADUCEUS_2 *) ((acc intM_global1 (shift t i)) =
  (acc intM_global (shift t j)) /\ (acc intM_global1 (shift t j)) =
  (acc intM_global (shift t i))).
Proof.
(*
intuition.
assert (i=j \/ i<>j).
  omega.
intuition.
subst; caduceus.
subst; caduceus.
subst; caduceus.
*)
intros.
assert (i=j \/ i<>j).
  omega.
intuition; subst; caduceus.
Save.

