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 results of terms having head normal forms (has_hnf) #1150

Merged
merged 3 commits into from
Oct 4, 2023

Conversation

binghe
Copy link
Member

@binghe binghe commented Oct 3, 2023

Hi,

This is a stage work proving more results of terms having head normal forms (has_hnf), independent with solvable terms. The end of the chain of proved theorems is the following theorems with [simp] (Proposition 8.3.13 (i) of [1, p.174]):

[has_hnf_iff_LAM] (standardisationTheory)
    ⊢ ∀x M. has_hnf (LAM x M) ⇔ has_hnf M

Now I have to use chap3Theory, i.e. using theorems about (beta) reductions (beta and grandbeta) to prove results about beta conversions (lameq). The following important lemmas are proved:

lameq_CR (chap3Theory)
    ⊢ ∀M N. M == N ⇒ ∃Z. M -β->* Z ∧ N -β->* Z

grandbeta_imp_betastar (chap3Theory)
    ⊢ ∀M N. M =β=> N ⇒ M -β->* N

grandbeta_imp_lameq (chap3Theory)
    ⊢ ∀M N. M =β=> N ⇒ M == N

abs_betastar (chap3Theory, statements modified in 2nd commit)
    ⊢ ∀x M Z. LAM x M -β->* Z ⇒ ∃N'. Z = LAM x N' ∧ M -β->* N'

P.S. With the above theorem "has_hnf_iff_LAM" and the following theorem (slightly renamed) added by previous PR #1148:

solvable_iff_LAM (solvableTheory)
    ⊢ ∀x M. solvable (LAM x M) ⇔ solvable M

we are now ready to show |- solvable M <=> has_hnf M (a term is solvable iff has head normal forms) by first reducing all involved terms to closed terms (by closing the terms with LAMs of free variables.), i.e. |- closed M ==> solvable M <=> has_hnf M.

[1] Barendregt, H.P.: The Lambda Calculus, Its Syntax and Semantics. College Publications, London (1984).

(* cf. abs_grandbeta, added by Chun Tian *)
(* |- !R x y z. R^+ x y /\ R^+ y z ==> R^+ x z *)
Theorem TC_TRANS[local] = REWRITE_RULE [transitive_def] TC_TRANSITIVE

Theorem abs_betastar :
Copy link
Member

Choose a reason for hiding this comment

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

This could be an iff.

Induct_on ‘vs’ >> rw []
QED

Theorem hnf_appstar :
Copy link
Member

Choose a reason for hiding this comment

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

If you lift the Ns <> [] assumption out, I believe the statement could be an iff:

Ns <> [] ==> (hnf (M @* Ns) <=> hnf M /\ ~is_abs M)

@@ -106,6 +106,7 @@ val lameq_weaken_cong = store_thm(
METIS_TAC [lameq_rules]);

Theorem lameq_SYM = List.nth(CONJUNCTS lameq_rules, 2)
Copy link
Member

Choose a reason for hiding this comment

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

If you use the labelling option in the Inductive definition of lameq you should be able to get these for free:

...
[~SYM:]
(!M N. M == N ==> N == M) /\
[~TRANS:]
(!M N P. M == N /\ N == P ==> M == P) /\ ...

You will need to replace the call to xHol_reln with Inductive lameq:

@binghe
Copy link
Member Author

binghe commented Oct 4, 2023

Thanks for your code review @mn200, I have made all the related changes (my first time using the modern syntax of Inductive with tags)

@binghe
Copy link
Member Author

binghe commented Oct 4, 2023

If you could take a look at hnf_cases :

    !M. hnf M ==> ?vs args y. M = LAMl vs (VAR y @* args)

I believe this theorem may be also improved as an iff: if M = LAMl vs (VAR y @* args) holds, then there should be no way to do one more head reduction as VAR y plus HD args (if exists) is not a valid head redex. Is this true? (even so, the new proof has to be delayed to next PR as I don't know how to manipulate head reduction process yet...)

@mn200
Copy link
Member

mn200 commented Oct 4, 2023

Thanks for all this!

I agree that your implication looks to definitely be an iff. Will look at it.

@mn200 mn200 merged commit cc9a0ec into HOL-Theorem-Prover:develop Oct 4, 2023
2 checks passed
@mn200
Copy link
Member

mn200 commented Oct 4, 2023

See b1932f5

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