I am doing some exercises with the subsequence order,
record _⊑₀_ {X : Set} (xs ys : List X) : Set where
field
indices : Fin (length xs) → Fin (length ys)
embed : ∀ {a b : Fin (length xs)} → a < b → indices a < indices b
eq : ∀ {i : Fin (length xs)} → xs ‼ i ≡ ys ‼ (indices i)
where
_‼_ : ∀ {X : Set} → (xs : List X) → Fin (length xs) → X
[] ‼ ()
(x ∷ xs) ‼ fzero = x
(x ∷ xs) ‼ fsuc i = xs ‼ i
is the usual safe lookup.
Now while the record version is nice, I'd like to use inference rules instead as that's probably easier than constructing embeddings and proving properties about them each time.
So I try the following,
infix 3 _⊑₁_
data _⊑₁_ {X : Set} : (xs ys : List X) → Set where
nil : ∀ {ys} → [] ⊑₁ ys
embed : ∀ {x y} → x ≡ y → x ∷ [] ⊑₁ y ∷ []
cons : ∀ {xs₁ ys₁ xs₂ ys₂} → xs₁ ⊑₁ ys₁ → xs₂ ⊑₁ ys₂ → xs₁ ++ xs₂ ⊑₁ ys₁ ++ ys₂
Which looks promising. Though I have had trouble proving it to be a sound and complete reflection of the record version.
Anyhow, the subsequence order is transitive, and this is a bit of trouble:
⊑₁-trans : ∀ {X : Set} (xs ys zs : List X) → xs ⊑₁ ys → ys ⊑₁ zs → xs ⊑₁ zs
⊑₁-trans .[] ys zs nil q = nil
⊑₁-trans ._ ._ [] (embed x₁) q = {! q is absurd !}
⊑₁-trans ._ ._ (x ∷ zs) (embed x₂) q = {!!}
⊑₁-trans ._ ._ zs (cons p p₁) q = {!!}
We get unification errors when pattern matching on a seemingly impossible pattern q
. So I have tried other data
versions of the order that avoid this unification error but then other proofs have seemingly-absurd patterns lying around.
I'd like some help with a data
version of the subsequence order (with soundness and completeness proofs, that'd be nice).
Are there any general heuristics to try when transforming a proposition in formula form into an inference/data form?
Thank-you!