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

Uniqueness of list elements (UNIQUE) and 3 alternative definitions #470

Merged
merged 2 commits into from
Oct 6, 2017

Conversation

binghe
Copy link
Contributor

@binghe binghe commented Oct 5, 2017

Currently HOL's listTheory lack of the definition for testing the uniqueness of an element in a list. I've learnt several equivalent definitions from the mailing list, one (the most useful form for me) is from Robert Beers robert@beers.org:

   [UNIQUE_DEF]  Definition

      |- ∀e L.
           UNIQUE e L ⇔ ∃L1 L2. (L1 ⧺ [e] ⧺ L2 = L) ∧ ¬MEM e L1 ∧ ¬MEM e L2

The most common alternative definitions (suggested by Scott Owens and Anthony Fox) are based on FILTER and LENGTH. Or it can be based on LIST_ELEM_COUNT (in rich_listTheory):

   [UNIQUE_ALT]  Theorem

      |- ∀e L. UNIQUE e L ⇔ (FILTER ($= e) L = [e])

   [UNIQUE_ALT_COUNT]  Theorem

      |- ∀e L. UNIQUE e L ⇔ (LIST_ELEM_COUNT e L = 1)

   [UNIQUE_ALT_LENGTH]  Theorem

      |- ∀e L. UNIQUE e L ⇔ (LENGTH (FILTER ($= e) L) = 1)

I have put UNIQUE_DEF into listTheory, and 3 alternative definitions (as theorems) into rich_listTheory.

@binghe
Copy link
Contributor Author

binghe commented Oct 5, 2017

What about changing the names of theorems in this way?

  • UNIQUE_ALT -> UNIQUE_FILTER
  • UNIQUE_ALT_COUNT -> UNIQUE_LIST_ELEM_COUNT
  • UNIQUE_ALT_LENGTH -> UNIQUE_LENGTH_FILTER

@xrchz
Copy link
Member

xrchz commented Oct 6, 2017

The proposed name changes sound good.

@xrchz
Copy link
Member

xrchz commented Oct 6, 2017

I think the theorems based on LENGTH and FILTER should be in listTheory, not rich_listTheory.

@xrchz
Copy link
Member

xrchz commented Oct 6, 2017

#98 is related

@binghe
Copy link
Contributor Author

binghe commented Oct 6, 2017

I have renamed those 3 theorems.

But I don't know how to move UNIQUE_FILTER and UNIQUE_LENGTH_FILTER to listTheory, because in their proofs I have used some FULL_SIMP_TAC list_ss [], in which list_ss is only defined in rich_listTheory. list_ss is based on listSimps which in turn depends on listTheory. I don't know how to remove these FULL_SIMP_TAC because I don't know which low-level list theorems were actually used ...

@xrchz
Copy link
Member

xrchz commented Oct 6, 2017

OK I guess they can be moved around later, maybe when we make progress on #98.

@xrchz xrchz merged commit ae60328 into HOL-Theorem-Prover:master Oct 6, 2017
@konrad-slind
Copy link
Contributor

konrad-slind commented Oct 6, 2017 via email

@binghe
Copy link
Contributor Author

binghe commented Oct 6, 2017 via email

@konrad-slind
Copy link
Contributor

konrad-slind commented Oct 6, 2017 via email

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.

None yet

3 participants