Skip to content

Commit

Permalink
[examples/lambda] Some minor tweaks to results about appstar
Browse files Browse the repository at this point in the history
Use

  Induct_on `x` using SNOC_INDUCT

idiom more and also add some more rewrites.
  • Loading branch information
mn200 committed Oct 4, 2023
1 parent 020ebdf commit b1932f5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 37 deletions.
10 changes: 5 additions & 5 deletions examples/lambda/barendregt/chap2Script.sml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ Inductive lameq :
(!M N. M == N ==> N == M) /\
[~TRANS:]
(!M N L. M == N /\ N == L ==> M == L) /\
[~APPL:]
(!M N Z. M == N ==> M @@ Z == N @@ Z) /\
[~APPR:]
(!M N Z. M == N ==> Z @@ M == Z @@ N) /\
(!M N x. M == N ==> LAM x M == LAM x N)
End
Expand Down Expand Up @@ -343,8 +345,8 @@ val lameq_I = store_thm(
Theorem I_appstar' :
!Is. (!e. MEM e Is ==> e = I) ==> I @* Is == I
Proof
HO_MATCH_MP_TAC SNOC_INDUCT >> rw []
>> ASM_SIMP_TAC (betafy (srw_ss())) [SNOC_APPEND, SYM appstar_SNOC, lameq_I]
Induct_on ‘Is’ using SNOC_INDUCT >> rw [appstar_SNOC]
>> ASM_SIMP_TAC (betafy (srw_ss())) [lameq_I]
QED

Theorem I_appstar :
Expand Down Expand Up @@ -723,9 +725,7 @@ QED
Theorem lameq_appstar_cong :
!M N Ns. M == N ==> M @* Ns == N @* Ns
Proof
NTAC 2 GEN_TAC
>> HO_MATCH_MP_TAC SNOC_INDUCT >> rw []
>> ASM_SIMP_TAC (betafy (srw_ss())) [SNOC_APPEND, SYM appstar_SNOC]
Induct_on ‘Ns’ using SNOC_INDUCT >> rw [appstar_SNOC, lameq_APPL]
QED

val _ = remove_ovl_mapping "Y" {Thy = "chap2", Name = "Y"}
Expand Down
48 changes: 22 additions & 26 deletions examples/lambda/barendregt/standardisationScript.sml
Original file line number Diff line number Diff line change
Expand Up @@ -2499,38 +2499,34 @@ Proof
Induct_on ‘vs’ >> rw []
QED

Theorem is_abs_appstar[simp]:
is_abs (M @* Ns) ⇔ is_abs M ∧ (Ns = [])
Proof
Induct_on ‘Ns’ using SNOC_INDUCT >>
simp[appstar_SNOC]
QED

Theorem hnf_appstar :
!M Ns. Ns <> [] ==> (hnf (M @* Ns) <=> hnf M /\ ~is_abs M)
!M Ns. hnf (M @* Ns) <=> hnf M /\ (is_abs M ⇒ (Ns = []))
Proof
rpt STRIP_TAC
>> EQ_TAC
>- (POP_ASSUM MP_TAC \\
Q.ID_SPEC_TAC ‘Ns’ >> HO_MATCH_MP_TAC SNOC_INDUCT \\
rw [SNOC_APPEND, SYM appstar_SNOC] \\
Cases_on ‘Ns = []’ >> fs [])
>> STRIP_TAC
>> Q.ID_SPEC_TAC ‘Ns’
>> HO_MATCH_MP_TAC SNOC_INDUCT
>> rw [SNOC_APPEND, SYM appstar_SNOC]
>> Q.PAT_X_ASSUM ‘~is_abs M’ MP_TAC >> KILL_TAC >> DISCH_TAC
>> Q.SPEC_TAC (‘Ns'’, ‘Ns’)
>> HO_MATCH_MP_TAC SNOC_INDUCT
>> rw [SNOC_APPEND, SYM appstar_SNOC]
Induct_on ‘Ns’ using SNOC_INDUCT >> simp[appstar_SNOC] >>
dsimp[SF CONJ_ss] >> metis_tac[]
QED

Theorem hnf_cases :
!M : term. hnf M ==> ?vs args y. M = LAMl vs (VAR y @* args)
!M : term. hnf M <=> ?vs args y. M = LAMl vs (VAR y @* args)
Proof
rpt STRIP_TAC
>> MP_TAC (Q.SPEC ‘M’ strange_cases)
>> RW_TAC std_ss []
>- (FULL_SIMP_TAC std_ss [size_1] \\
qexistsl_tac [‘vs’, ‘[]’, ‘y’] >> rw [])
>> FULL_SIMP_TAC std_ss [hnf_LAMl]
>> ‘hnf t /\ ~is_abs t’ by PROVE_TAC [hnf_appstar]
>> ‘is_var t’ by METIS_TAC [term_cases]
>> FULL_SIMP_TAC std_ss [is_var_cases]
>> qexistsl_tac [‘vs’, ‘args’, ‘y’] >> art []
simp[FORALL_AND_THM, EQ_IMP_THM] >> conj_tac
>- (gen_tac >> MP_TAC (Q.SPEC ‘M’ strange_cases)
>> RW_TAC std_ss []
>- (FULL_SIMP_TAC std_ss [size_1] \\
qexistsl_tac [‘vs’, ‘[]’, ‘y’] >> rw [])
>> FULL_SIMP_TAC std_ss [hnf_LAMl]
>> ‘hnf t /\ ~is_abs t’ by PROVE_TAC [hnf_appstar]
>> ‘is_var t’ by METIS_TAC [term_cases]
>> FULL_SIMP_TAC std_ss [is_var_cases]
>> qexistsl_tac [‘vs’, ‘args’, ‘y’] >> art []) >>
simp[PULL_EXISTS, hnf_appstar]
QED

(* Proposition 8.3.13 (i) [1, p.174] *)
Expand Down
10 changes: 4 additions & 6 deletions examples/lambda/basics/appFOLDLScript.sml
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ Proof
qid_spec_tac ‘x’ >> Induct_on ‘Ms1’ >> simp[]
QED

Theorem appstar_SNOC:
x ·· Ms @@ M = x ·· (Ms ++ [M])
Theorem appstar_SNOC[simp]:
x ·· (SNOC M Ms) = (x ·· Ms) @@ M
Proof
simp[appstar_APPEND]
simp[appstar_APPEND, SNOC_APPEND]
QED

Theorem appstar_CONS :
Expand All @@ -174,9 +174,7 @@ QED
Theorem ssub_appstar :
fm ' (M @* Ns) = (fm ' M) @* MAP (ssub fm) Ns
Proof
Q.ID_SPEC_TAC ‘Ns’
>> HO_MATCH_MP_TAC SNOC_INDUCT
>> rw [SNOC_APPEND, SYM appstar_SNOC]
Induct_on ‘Ns’ using SNOC_INDUCT >> simp[appstar_SNOC, MAP_SNOC]
QED

val _ = export_theory ()

3 comments on commit b1932f5

@binghe
Copy link
Member

@binghe binghe commented on b1932f5 Oct 4, 2023

Choose a reason for hiding this comment

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

I think your change of appstar_SNOC has broken examples/lambda/typing/sttScript.sml. As the CI tests still passed (if we ignore the random failure due to PolyML crashing), this also means that examples/lambda is not built as part of the CI tests.

@mn200
Copy link
Member Author

@mn200 mn200 commented on b1932f5 Oct 4, 2023

Choose a reason for hiding this comment

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

Both issues now fixed (in 097809d and 30a4efc) I believe.

@binghe
Copy link
Member

@binghe binghe commented on b1932f5 Oct 5, 2023

Choose a reason for hiding this comment

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

Both issues now fixed (in 097809d and 30a4efc) I believe.

Thanks!

Please sign in to comment.