import Base import ../../lib/logic.bend as L import ../../../spec/containers/doubly_linked_list.bend as S import ../../../src/containers/doubly_linked_list.bend as D import ./state.bend as ST # The refinement statement of one step: the implementation's result is the # real list of a new shadow with an observation, the specification's the # shadow's model with the same observation, and the shadow is good. def POK(~T: Data, -X: Data, spec: S.DS & X, r: D.DList & X) -> Type: Sigma<&1, &1, ST.Sh, sh2 => Sigma<&1, &1, X, o => {r == (ST.real(~T, sh2), o) : D.DList & X} & ({spec == (ST.model(~T, sh2), o) : S.DS & X} & {ST.good(~T, sh2) == True{} : Bool})>> # both results rewritten def pok_eq(~T: Data, -X: Data, -spec: S.DS & X, -spec2: S.DS & X, -r: D.DList & X, -r2: D.DList & X, +es: {spec == spec2 : S.DS & X}, +er: {r == r2 : D.DList & X}, p: POK(~T, X, spec2, r2)) -> POK(~T, X, spec, r): p1 = L.subst(D.DList & X, z => POK(~T, X, spec2, z), r2, r, Equal.sym(D.DList & X, r, r2, er), p) L.subst(S.DS & X, z => POK(~T, X, z, r), spec2, spec, Equal.sym(S.DS & X, spec, spec2, es), p1)