Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more theory about lists #1957

Merged
merged 6 commits into from
May 18, 2024
Merged

more theory about lists #1957

merged 6 commits into from
May 18, 2024

Conversation

Alizter
Copy link
Collaborator

@Alizter Alizter commented May 14, 2024

This PR develops the theory of lists some more. Here is a summary of the changes:

  • We change the [ a0; ...; an ] notation to [ a0, ..., an ] in a way that doesn't disrupt the pointed type notation.
  • We add a new theories/Spaces/Option.v file for some basics about option types.
  • In Option.v I needed to use the injection tactic which lets Coq prove that constructors of inductive types are injective. In order to do that, I had to register some constants in Overture.v. It appears to be working fine. See the proof of option_path.
  • The head, nth and last functions now return an option A rather than requiring a default value.
  • We add new functions:
    • drop which drops the first n elements of a list.
    • take which takes the first n elements of a list and returns it.
    • remove which removes the element at a given index.
    • nth' a variant of nth which takes a proof that the index is in bounds and guarantees an element.
    • repeat which repeats an element n times.
    • seq' a variant of seq which keeps around a proof that the elements are less than the length.
  • We prove many new lemmas about the existing and new list functions and improve existing entries.
  • We add comments to the Theory.v file.

These new functions and lemmas will be used in an upcoming PR.

Signed-off-by: Ali Caglayan <[email protected]>
@Alizter Alizter requested a review from jdchristensen May 14, 2024 01:26
@Alizter Alizter mentioned this pull request May 17, 2024
Copy link
Collaborator

@jdchristensen jdchristensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I skimmed some parts, but this looks good. Lots of results in this PR!

theories/Spaces/Option.v Outdated Show resolved Hide resolved
theories/Spaces/Option.v Outdated Show resolved Hide resolved
theories/Spaces/List/Theory.v Show resolved Hide resolved
theories/Spaces/List/Theory.v Outdated Show resolved Hide resolved
theories/Spaces/List/Theory.v Outdated Show resolved Hide resolved
apply nth'_cons.
Defined.

(** The [nth'] element of a map is the function applied to the [nth'] element of the original list. *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if some of the results about nth' would be cleaner if first proved about nth and then converted to statements about nth' using nth_nth'? (Like how nth'_cons was done.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried nth'_map and I end up having to reason about nth returning Some when in range so it ended up not being shorter. I did not try nth'_map2 but presumably it has the same issue. That leaves only nth'_repeat and I would guess the nth_repeat proof would be the same length if we had it.

@Alizter Alizter requested a review from jdchristensen May 18, 2024 00:56
theories/Spaces/List/Theory.v Outdated Show resolved Hide resolved
theories/Spaces/List/Theory.v Outdated Show resolved Hide resolved
theories/Spaces/List/Theory.v Outdated Show resolved Hide resolved
theories/Spaces/List/Theory.v Outdated Show resolved Hide resolved
@Alizter Alizter merged commit 3956d68 into HoTT:master May 18, 2024
21 checks passed
@Alizter Alizter deleted the more-list branch May 18, 2024 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants