Open amblafont opened 4 years ago
Actually, the put lemmas also fails with the following simplest example:
idA : { a : U8 } -> { a : U8 }
idA r { a } = r { a }
idB : { b : U8 } -> { b : U8 }
idB b = b
I believe the problem is that the putboxed tactic doesn't work when two essentially identical cogent types are compiled to different (although isomorphic) C types.
I think the problem happens whenever two cogent types having the same representation are compiled to different C types.
The problem is in the relation between C heaps h
and the update semantics environment σ (assigning pointers to values): this relation basically states that given any C type τ
corresponding to a cogent type t
, and any pointer p
, if σ(p) has the "representational" type t
, then h_τ(p)
should relate to σ(p)
. But, if two cogent types have the same representation, then this relation is not preserved when updating a record in place, therefore the hypotheses of lemma all_heap_rel_updE can never be satisfied in the put boxed tactic. The reason is that on the C side, we only update the heap corresponding to the C record, but not the other heaps corresponding to the same "representational" cogent type.
With dargent, the issue is currently even more visible because the representation does not mention the layout, so the issue would occur if the same type is used with different layouts.
Possible fixes that I can think of (by decreasing order of preference / increasing amount of work):
This branch seems to solve this issue: https://github.com/amblafont/cogent/tree/heapabsptrsigma
In this branch above, the type relation is no longer necessary. Christine suggests an alternative fix : put the field names in the type representation. For the dargent case, it should be enough to assign layouts to the record type representation / update value.
The last lines of CorresSetup shows that some take/put lemmas fail to be proven by the automatic tactics.