(**************************************************************************)
(*                  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}.(**************************************************************************)
(*                  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}.(**************************************************************************)
(*                  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}.(**************************************************************************)
(*                  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 subctx i j :=
  prefix (heap_ctx i) (heap_ctx j) /\ prefix (ptr_ctx i) (ptr_ctx j).

Lemma subctx_trans j i k : subctx i j -> subctx j k -> subctx i k.