(* Copyright (C) 2012  G. Gonthier, B. Ziliani, A. Nanevski, D. Dreyer  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.  You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>. *)
From mathcomp
From LemmaOverloading
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
(**************************************************************************)
(*                  Syntactic cancelation of heaps                        *)
(**************************************************************************)
(* Differences w.r.t. the paper:  In the paper we described the cancellation algorithm as producing a proposition. Instead, it will produce a sequence of "facts" which are later on evaluated into a proposition. We did this in order to further simplify the proposition. Each fact is of the form t1 = t2, where t1 and t2 are heaps, pointers, or values.  Another simplification we made in the paper is that the values contained in a heap are actually instances of a generic type 'dynamic'. This type is defined in the file heaps.v, and is just a structure containing a value and its type. So, instead of equating values, we are equating dynamics, therefore we need some extra step to prove the values are equal (see the examples at the bottom of the file). This can be avoided with extra canonical structures machinery. *)
(***************************)
(* interpretation contexts *)
(***************************)
Structure ctx := Context {heap_ctx : seq heap; ptr_ctx : seq ptr}.
Definition empc := Context [::] [::].
Definition subctx i j :=
prefix (heap_ctx i) (heap_ctx j) /\ prefix (ptr_ctx i) (ptr_ctx j).

Lemma subctx_refl i: subctx i i.