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

[lambda] agree_upto_lemma (enhanced) #1354

Merged
merged 4 commits into from
Nov 29, 2024

Conversation

binghe
Copy link
Member

@binghe binghe commented Nov 28, 2024

Hi,

This PR follows #1348 and fixed the involved definitions and proofs. Previously, the definition of agree_upto requires literal equivalent of corresponding Böhm tree notes between two terms (ltree_el (BT' X M r) q = ltree_el (BT' X N r) q). This turns out to be wrong (not general enough). Instead, the concept of subtree_equiv (based on head_equivalent) should be used:

[agree_upto_def] (fixed)
⊢ ∀X Ms p r.
    agree_upto X Ms p r ⇔
    ∀M N q. MEM M Ms ∧ MEM N Ms ∧ q ≼ p ⇒ subtree_equiv X M N q r

[subtree_equiv_def]
⊢ ∀X M N p r.
    subtree_equiv X M N p r ⇔
    ltree_equiv (ltree_el (BT' X M r) p) (ltree_el (BT' X N r) p)

Overload ltree_equiv = “OPTREL head_equivalent”

[head_equivalent_def] (updated)
⊢ ∀a1 m1 a2 m2.
    head_equivalent (a1,m1) (a2,m2) ⇔
    case (a1,a2) of
      (NONE,NONE) => T
    | (NONE,SOME v3) => F
    | (SOME v2,NONE) => F
    | (SOME (vs1,y1),SOME (vs2,y2)) =>
      (let
         n1 = LENGTH vs1;
         n2 = LENGTH vs2
       in
         y1 = y2 ∧ n1 + THE m2 = n2 + THE m1)

In short words, previously the equivalence of corresponding tree nodes is y1 = y2 /\ n1 = n2 /\ m1 = m2, now it's relaxed to y1 = y2 ∧ n1 + m2 = n2 + m1, which essentially captures the idea of η-equivalence between λ-terms.

The proof of agree_upto_lemma (for the previously proved conclusions) becomes even more tedious, requiring some more devices on head reductions, which now involves "suffix" of lists:

[hreduce_permutator_shared]
⊢ ∀Ns n ls.
    LENGTH Ns ≤ n ∧ n < LENGTH ls ∧ ALL_DISTINCT ls ∧
    DISJOINT (set ls) (BIGUNION (IMAGE FV (set Ns))) ⇒
    ∃xs y.
      permutator n ·· Ns -h->* LAMl xs (LAM y (VAR y ·· Ns ·· MAP VAR xs)) ∧
      LENGTH xs = n − LENGTH Ns ∧ IS_SUFFIX ls (SNOC y xs)

For this reason, I have also added a few new lemmas into rich_listTheory regarding IS_SUFFIX, etc.

Now the statements of agree_upto_lemma is slightly extended to the following:

[agree_upto_lemma]
⊢ ∀X Ms p r.
    FINITE X ∧ p ≠ [] ∧ 0 < r ∧ Ms ≠ [] ∧
    BIGUNION (IMAGE FV (set Ms)) ⊆ X ∪ RANK r ∧
    EVERY (λM. subterm X M p r ≠ NONE) Ms ⇒
    ∃pi.
      Boehm_transform pi ∧ EVERY is_ready' (MAP (apply pi) Ms) ∧
      (agree_upto X Ms p r ⇒ agree_upto X (MAP (apply pi) Ms) p r) ∧
      ∀M N.
        MEM M Ms ∧ MEM N Ms ⇒
        subtree_equiv X M N p r ⇒
        subtree_equiv X (apply pi M) (apply pi N) p r

Note that the only difference between the above form and the final full form, is that the last logical implication (between two subtree_equivs) will be an "if and only if" in the full form.

Chun

@binghe
Copy link
Member Author

binghe commented Nov 28, 2024

Strange, I forked this delivery branch from 01016dc for which CI tests passed but still encountered CI test failures...

@binghe
Copy link
Member Author

binghe commented Nov 29, 2024

I have updated [head_equivalent_def] by using SML case .. of. I look forward for updates on develop to get the CI tests fully fixed.

@mn200
Copy link
Member

mn200 commented Nov 29, 2024

Thanks for this !

@mn200 mn200 merged commit 56f838f into HOL-Theorem-Prover:develop Nov 29, 2024
4 checks passed
@binghe binghe deleted the agree_upto.fix branch December 3, 2024 09:02
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.

3 participants