Module BarebonesLogic <: VERISTAR_LOGIC.
Definition loc := loc.
Instance Join_loc : Join loc := @Join_equiv _.
Instance Perm_loc : Perm_alg loc := _.
Instance Sep_loc : Sep_alg loc := _.
Instance Canc_loc : Canc_alg loc := _.
Instance Join_nat : Join nat := @Join_discrete _.
Instance Pos_nat : @Pos_alg nat (@Join_discrete _) := @psa_discrete _.
Instance Canc_nat : @Canc_alg nat Join_nat.
unfold Canc_alg; intros ? ? ? ? H; inv H.
Qed.
Definition val := val.
Instance Join_val : Join val := Join_lower Join_nat.
Instance Perm_val : Perm_alg val := _.
Instance Sep_val : Sep_alg val := _.
Instance Canc_val : Canc_alg val := @Canc_lower _ _ _ Canc_nat.
repeat intro. inv H; auto. Qed.
Hint Resolve identity_None.
Definition val2loc (v: val) : option loc :=
match v with Some (S n) => Some (S n) | _ => None end.
Definition nil_val : val := Some O.
Definition full (v: val) := forall v2, joins v v2 -> identity v2.
intro H; destruct v as [[|n]|]; inv H.
unfold full; intros v2 [[x|] H]; inv H; auto; inversion H3.
Qed.
unfold full, nil_val; intros x H; inversion H as [x0 H0]; inv H0; auto; inv H2.
Qed.
unfold not, full, empty_val; intros. specialize (H (Some O)).
spec H. econstructor; constructor. specialize (H None (Some O)).
spec H. constructor. inv H.
Qed.
unfold val2loc; intros. destruct v1; inv H. destruct n; inv H2.
destruct v2; inv H0. destruct n0; inv H1. auto.
Qed.
intros; case_eq (beq_nat l1 l2); intros.
left; apply beq_nat_eq; auto.
right; apply beq_nat_false; auto.
Qed.
unfold nil_val; intros. destruct v. destruct n. left; auto. right; congruence.
right; congruence.
Qed.
Definition var := Ident.t.
Definition env := var -> nat.
Definition env_get (rho: env) : var -> val := fun x => Some (rho x).
Definition env_set (x: var) (v: val) (rho: env) : env :=
match v with
| None (*empty_val*) => rho
| Some v' => fun y => if Ident.eq_dec x y then v' else rho y
end.
unfold env_get, env_set; intros.
destruct v.
destruct (Ident.eq_dec x x); auto.
contradiction n0; auto.
elimtype False; apply H; auto.
Qed.

Lemma gso_env (x y : var) (v: val) (s: env) :
x<>y -> env_get (env_set x v s) y = env_get s y.