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

[rich_list] Added IS_PREFIX_FINITE, etc. (The set of prefixes is finite) #1184

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

binghe
Copy link
Member

@binghe binghe commented Jan 22, 2024

Hi,

Today I was in the need of the following theorem stating that "the set of all prefixes of a given list, is finite":

   [IS_PREFIX_FINITE]  Theorem   
      ⊢ ∀l. FINITE {l1 | l1 ≼ l}

My idea of the proof is based on rewriting IS_PREFIX to TAKE (and then use IMAGE_FINITE to finish the proof):

   [IS_PREFIX_EQ_TAKE]  Theorem
      ⊢ ∀l l1. l1 ≼ l ⇔ ∃n. n ≤ LENGTH l ∧ l1 = TAKE n l

   [IS_PREFIX_EQ_TAKE']  Theorem
      ⊢ ∀l l1. l1 ≼ l ⇔ ∃n. l1 = TAKE n l

The above theorems are to be added into rich_listTheory.

But then this makes me wonder how to prove that "the set of all sublists of a list is finite", i.e. ∀l. FINITE {l1 | IS_SUBLIST l l1}? (I can imagine that a sublist may be obtained by first do a TAKE and then a DROP, or in reversed order, thus leads to finite number of possibilities, but this proof seems not easy)

This will subsume the above IS_PREFIX_FINITE, since we have:

   [IS_PREFIX_IS_SUBLIST]  Theorem      
      ⊢ ∀l1 l2. l2 ≼ l1 ⇒ IS_SUBLIST l1 l2

Furthermore, IS_SUFFIX_FINITE can be easily proved too, if we know "the set of all subsets of a list is finite", before suffix is also a sublist:

   [IS_SUFFIX_IS_SUBLIST]  Theorem      
      ⊢ ∀l1 l2. IS_SUFFIX l1 l2 ⇒ IS_SUBLIST l1 l2

@mn200
Copy link
Member

mn200 commented Jan 24, 2024

That theorem is already present in rich_listTheory under name FINITE_prefix, but the characterisations of prefix in terms of TAKE might still be useful.

@binghe
Copy link
Member Author

binghe commented Jan 24, 2024

Ah, thanks, I didn't see FINITE_prefix. After your addition of FINITE_BOUNDED_LISTS, I think all similar results (for suffix and sublists) are now quite obvious. I have deleted IS_PREFIX_FINITE and only kept the IS_PREFIX_EQ_TAKE and IS_PREFIX_EQ_TAKE' in the code changes.

@mn200
Copy link
Member

mn200 commented Jan 24, 2024

Thanks!

@mn200 mn200 merged commit 9cad979 into HOL-Theorem-Prover:develop Jan 24, 2024
2 checks passed
@binghe binghe deleted the IS_PREFIX_FINITE branch January 29, 2024 11:24
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