Skip to content

Parsing problems with the PermutationReasoning combinators in Data.List.Relation.Binary.Permutation.Propositional #2319

@jamesmckinna

Description

@jamesmckinna

(micro-issue arising in the course of #2317 / #2311 )
UPDATED: two instances of what might be considered parsing 'bugs', but might merely be 'peeves'... but the first does seem to be a semantic failure of the current setup?

Suggest adding a comment in the definition of the combinators, or in the README to draw attention to this issue?
Or is there a 'better' definition which might help avoid these problems?

  • On master, the reasoning step here makes a combination of a prep/'prefix' step with a use of shift reflected symmetrically; but if
      _ ∷ (_ ∷ ws ++ _) <⟨ ↭-sym (shift _ _ _) ⟩

is replaced with

      _ ∷ (_ ∷ ws ++ _) <⟨ shift _ _ _ ⟨

then the parser complains...

  • The step-swap combinator, defined as:
  -- Skip reasoning about the first two elements
  step-swap :  x y xs {ys zs : List A}  (y ∷ x ∷ ys) IsRelatedTo zs 
              xs ↭ ys  (x ∷ y ∷ xs) IsRelatedTo zs
  step-swap x y xs rel xs↭ys = relTo (trans (swap x y xs↭ys) (begin rel))

  syntax step-swap x y xs y↭z x↭y = x ∷ y ∷ xs <<⟨ x↭y ⟩ y↭z

seems to work in the handful of places in the library where it is used:

But attempting to deploy it in the associated README leads to the following unpleasant need for re-bracketing when trying to re-express example lem₂ using the combinator, as follows:

-- In practice it is further useful to extend `PermutationReasoning` with
-- specialised syntax `_∷_<⟨_⟩_` and `_∷_∷_<<⟨_⟩_` to support the
-- distinguished use of the `prep` and `swap` steps, allowing
-- the above proof to be recast in the following form:

lem₂ᵣ : 123 ∷ [] ↭ 312 ∷ []
lem₂ᵣ = begin
  1 ∷ (2 ∷ (3 ∷ [])) <⟨ swap 2 3 refl ⟩
  13 ∷ (2 ∷ [])   <<⟨ refl ⟩
  31 ∷ (2 ∷ [])   ∎

Removing any of these brackets (or any other bracketing) seems to cause the parser to fall over.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions