Dear Professor Dawson, Thank you very much!
Actually I’ve read the following 4 papers written by you and R. Goré, since the
my first post in this mail thread:
[1] J.E. Dawson, R. Goré, Machine-checked Cut-elimination for Display
Logic, (2006).
[2] J.E. Dawson, R. Goré, Formalised cut admissibility for display logic,
in: Theorem Proving in Higher Order Logics, Springer, Berlin, Berlin,
Heidelberg, 2002: pp. 131–147. doi:10.1007/3-540-45685-6_10.
[3] J.E. Dawson, R. Goré, Generic Methods for Formalising Sequent Calculi
Applied to Provability Logic, Logic for Programming. 6397 (2010) 263–.
doi:10.1007/978-3-642-16242-8_19.
[4] J.E. Dawson, R. Goré, Embedding Display Calculi into Logical
Frameworks: Comparing Twelf and Isabelle, Electronic Notes in Theoretical
Computer Science. 42 (2001) 89–103. doi:10.1016/s1571-0661(04)80880-6.
And the sentence I quoted in my first post, “when encoding any aspect of a
logic, we must encode the basic syntactic expressions like atomic formulae,
logical connectives, and formulae.”, is actually from page 11 of [1] (section
4.4: Deep and Shallow Embeddings). And for the concept of Deep and Shallow
Embeddings, I never heard before reading your papers. So I want to say, thank
you very much for writing these papers!
With Yong Kiam’s working code understood and referenced, the approach I have
finally chosen for Lambek’s Sequent Calculus, is quite similar with your
Datatype definitions in [1]:
val _ = Datatype `Sequent = Sequent ('a gentzen_extension) ('a Term) ('a Form)`;
val _ = Datatype `Rule = SeqAxiom | CutRule | SequentExtension
| RightSlash | RightBackslash | RightDot
| LeftSlash | LeftBackslash | LeftDot `;
val _ = Datatype `Dertree = Der ('a Sequent) Rule (Dertree list)
| Unf ('a Sequent)`;
Here the types (‘a Term) and (‘a Form) correspond to the types “structr” and
“formula” in Display Logic [1]. I found it’s impossible to define a
datatype “Rule” like in [1] for Lambek Calculus:
(* rule definition in [1], not used *)
datatype rule = Rule (sequent list) sequent
because some of my rules cannot be fully defined as a list of sequent. So I
took the idea of Yong Kiam, defining Rule as just atomic IDs.
Now I can define the operation “derivation” mapping Dertree to Dertree as a
relation:
val (deriv_rules, deriv_ind, deriv_cases) = Hol_reln `
(!E A.
deriv (Unf (Sequent E (OneForm A) A))
(Der (Sequent E (OneForm A) A) SeqAxiom [])) /\
...
(!E Delta Gamma Gamma' A C.
replace Gamma Gamma' (OneForm A) Delta ==>
deriv (Unf (Sequent E Gamma' C))
(Der (Sequent E Gamma' C) CutRule
[Unf (Sequent E Delta A); Unf (Sequent E Gamma C)])) /\
(!E Gamma Gamma' Delta Delta' C.
replace Gamma Gamma' Delta Delta' /\ E Delta Delta' ==>
deriv (Unf (Sequent E Gamma' C))
(Der (Sequent E Gamma' C) SequentExtension
[Unf (Sequent E Gamma C)]))`;
And now I can define the “degree” of a proof as in the Coq proof scripts:
val degreeProof_def = Define `
(degreeProof (Der _ SeqAxiom []) = 0) /\
(degreeProof (Der _ RightSlash [H]) = degreeProof H) /\
(degreeProof (Der _ RightBackslash [H]) = degreeProof H) /\
(degreeProof (Der _ RightDot [H1; H2]) = MAX (degreeProof H1)
(degreeProof H2)) /\
(degreeProof (Der _ LeftSlash [H1; H2]) = MAX (degreeProof H1)
(degreeProof H2)) /\
(degreeProof (Der _ LeftBackslash [H1; H2]) = MAX (degreeProof H1)
(degreeProof H2)) /\
(degreeProof (Der _ LeftDot [H]) = degreeProof H) /\
(degreeProof (Der _ SequentExtension [H]) = degreeProof H) /\
(* CutRule is special *)
(degreeProof (Der _ CutRule [Der (Sequent E Delta A) rule derlist; H2]) =
MAX (MAX (degreeFormula A) (degreeProof (Der (Sequent E Delta A) rule
derlist)))
(degreeProof H2))`;
All my code written so far can be found here [5, 6]. I haven’t fully finished
the formal proof of Cut Elimination theorem, that will be done in next week.
Just I’m not blocked any more:)
Best regards,
Chun Tian
[5]
https://github.com/binghe/informatica-public/blob/master/lambek/CutFreeScript.sml
[6]
https://github.com/binghe/informatica-public/blob/master/lambek/LambekScript.sml
> Il giorno 22 gen 2017, alle ore 08:21, Jeremy Dawson
> <[email protected]> ha scritto:
>
> Hi Chun,
>
> It looks as though you have this worked out, so I won't give a long
> reply, but here's a few short comments:
>
> There's a distinction between an inductively defined set (in Isabelle or
> HOL) and a datatype, though they can look similar. I don't know which
> corresponds better to your Coq code
>
> You can model a proof by a proof tree "object" by using a datatype
> definition - then you have something of which you can define functions
> to give, eg, its' height, number of rule applications, etc.
>
> On the other hand you can model a proof by an inductively defined set
> (predicate), defining the predicate "is_provable". Then if you want to
> deal with the number of rule applications, or the height of the
> corresponding proof tree, you would have to define a new inductively
> defined set, "is_provable in at most n steps".
>
> The concepts are discussed (in Isabelle notation) in
> Jeremy E. Dawson & Rajeev Goré, Generic Methods for Formalising Sequent
> Calculi Applied to Provability Logic. In Logic for Programming,
> Artificial Intelligence and Reasoning (LPAR 2010), LNCS 6397, 263-277
> http://users.cecs.anu.edu.au/~jeremy/pubs/cutelim/gls/lpar-final/
>
> Cheers,
>
> Jeremy
>
>
> On 13/01/17 05:24, Chun Tian (binghe) wrote:
>> Hi Yong,
>>
>> thank you very much! Now I understand the situation much better:)
>>
>> Regards,
>>
>> Chun Tian
>>
>>> Il giorno 12/gen/2017, alle ore 17:28, Yong Kiam <[email protected]> ha
>>> scritto:
>>>
>>> Hi,
>>>
>>> I formalized cut elimination for a version of ordered logic (related to the
>>> Lambek calculus) awhile ago, but never got it cleaned up to put anywhere.
>>> It's available here:
>>> https://github.com/tanyongkiam/15816/blob/master/ordered_logicScript.sml
>>>
>>> The proof uses this method:
>>> http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.40.173
>>>
>>> It needed 1) names for each rule, and 2) a notion of size for proofs, which
>>> aren't provided by default by Hol_reln. I got around this by 1) defining a
>>> datatype of rulename identifiers and 2) adding a counter to each of the
>>> rules.
>>>
>>> I think 1) is what you are missing, and 2) is related to what you're trying
>>> to define.
>>>
>>> Note that if you just wanted 2), you can add it directly to the inductive
>>> relation defining your rules as an additional argument instead of defining
>>> a brand new relation.
>>>
>>>
>>> On Thu, Jan 12, 2017 at 10:19 AM, Chun Tian (binghe)
>>> <[email protected]> wrote:
>>> Dear HOL users,
>>>
>>> Sorry for disturbing, but I have a long question about HOL.
>>>
>>> I’m trying to implement Lambek calculus in HOL with several deep theorems
>>> proved. This is my exam project on theorem proving. I found an existing
>>> work [1] based on Coq, so I think maybe I can migrate the existing work
>>> first, then add the proof for more theorems as my work. I have to say
>>> that, before mid December last year I have never proved anything
>>> successfully in HOL (although I have been reading HOL manuals & papers for
>>> several months), nor can I read Coq proof scripts, but I studied very much
>>> and today I got 1000 lines of HOL code as my implementation of Lambek
>>> Calculus [2].
>>>
>>> [1] https://github.com/coq-contribs/lambek
>>> [2]
>>> https://github.com/binghe/informatica-public/blob/master/lambek/LambekScript.sml
>>>
>>> (My question is at the end of this mail, people who doesn’t have time can
>>> skip this mail and save your time, thanks all the same!)
>>>
>>> Recall that, “when encoding any aspect of a logic, we must encode the basic
>>> syntactic expressions like atomic formulae, logical connectives, and
>>> formulae.” The Coq work has defined two concepts (Form and Term) which
>>> corresponds to syntactic categories of single words and sentences in Lambek
>>> calculus:
>>>
>>> """
>>> Inductive Form (Atoms : Set) : Set :=
>>> | At : Atoms -> Form Atoms
>>> | Slash : Form Atoms -> Form Atoms -> Form Atoms
>>> | Dot : Form Atoms -> Form Atoms -> Form Atoms
>>> | Backslash : Form Atoms -> Form Atoms -> Form Atoms.
>>>
>>> Inductive Term (Atoms:Set) : Set :=
>>> | OneForm : Form Atoms -> Term Atoms
>>> | Comma : Term Atoms -> Term Atoms -> Term Atoms."""
>>> """
>>>
>>> After reading "The HOL System TUTORIAL”carefully, especially “Chapter 6.
>>> Example: Combinatory Logic”, I think above definitions must be defining new
>>> datatypes, so I write down the following two Datatype definitions:
>>>
>>> """
>>> val _ = Datatype `Form = Atom 'a | Slash Form Form | Backslash Form Form |
>>> Dot Form Form`;
>>> val _ = Datatype `Term = OneForm ('a Form) | Comma Term Term`;
>>> """
>>>
>>> Now Coq scripts have gentzen styled sequent calculus defined in the same
>>> “Inductive” keyword: (I omitted some similar lines)
>>>
>>> """
>>> Variable E : gentzen_extension.
>>> Inductive gentzenSequent (Atoms : Set) : Term Atoms -> Form Atoms -> Set :=
>>> | Ax : forall A : Form Atoms, gentzenSequent (OneForm A) A
>>> | RightSlash :
>>> forall (Gamma : Term Atoms) (A B : Form Atoms),
>>> gentzenSequent (Comma Gamma (OneForm B)) A ->
>>> gentzenSequent Gamma (Slash A B)
>>> ...
>>> | CutRule :
>>> forall (Delta Gamma Gamma' : Term Atoms) (A C : Form Atoms),
>>> replace Gamma Gamma' (OneForm A) Delta ->
>>> gentzenSequent Delta A ->
>>> gentzenSequent Gamma C -> gentzenSequent Gamma' C
>>> | SequentExtension :
>>> forall (Gamma Gamma' T1 T2 : Term Atoms) (C : Form Atoms),
>>> E T1 T2 ->
>>> replace Gamma Gamma' T1 T2 ->
>>> gentzenSequent Gamma C -> gentzenSequent Gamma' C.
>>> """
>>>
>>> To me, this does’t look like a Datatype in HOL but Hol_reln, although it
>>> has three parameters:
>>>
>>> """
>>> val (gentzenSequent_rules, gentzenSequent_ind, _) = Hol_reln `
>>> (!(E:'a gentzen_extension) A. gentzenSequent E (OneForm A) A) /\ (*
>>> SeqAxiom *)
>>> (!E Gamma A B. (*
>>> RightSlash = SlashIntro *)
>>> gentzenSequent E (Comma Gamma (OneForm B)) A ==>
>>> gentzenSequent E Gamma (Slash A B)) /\
>>> ...
>>> (!E Delta Gamma Gamma' A C.
>>> (* CutRule *)
>>> replace Gamma Gamma' (OneForm A) Delta /\
>>> gentzenSequent E Delta A /\ gentzenSequent E Gamma C
>>> ==> gentzenSequent E Gamma' C) /\
>>> (!(E:'a gentzen_extension) Gamma Gamma' Delta Delta' C. (*
>>> SequentExtension *)
>>> replace Gamma Gamma' Delta Delta' /\ E Delta Delta' /\ gentzenSequent E
>>> Gamma C
>>> ==> gentzenSequent E Gamma' C)`;
>>>
>>> val [SeqAxiom, RightSlash, … ,CutRule, SequentExtension] = CONJ_LIST 9
>>> gentzenSequent_rules;
>>> """
>>>
>>> So far so good, actually I can easily migrate all theorems related to above
>>> Sequent calculus in one-to-one mapping, see the following theorem in Coq
>>> and HOL versions:
>>>
>>> “""
>>> (* Coq version *)
>>> Definition restructuring :
>>> forall (A B C : Form Atoms) (E : gentzen_extension),
>>> genExtends L_Sequent E ->
>>> gentzenSequent E (OneForm (Slash (Backslash A B) C))
>>> (Backslash A (Slash B C)).
>>>
>>> intros A B C E H.
>>> apply RightBackSlash.
>>> apply RightSlash.
>>> apply LextensionSimpl.
>>> assumption.
>>> apply CutRuleSimpl with (Dot A (Backslash A B)).
>>> apply RightDot.
>>> apply Ax.
>>> apply LeftSlashSimpl; apply Ax.
>>> apply application'.
>>> Defined.
>>>
>>> (* HOL version *)
>>> val restructuring = store_thm ("restructuring",
>>> ``!E A B C. extends L_Sequent E ==> gentzenSequent E (OneForm (Slash
>>> (Backslash A B) C))
>>> (Backslash A (Slash B
>>> C))``,
>>> REPEAT STRIP_TAC
>>>>> MATCH_MP_TAC RightBackslash
>>>>> MATCH_MP_TAC RightSlash
>>>>> MATCH_MP_TAC LextensionSimpl
>>>>> CONJ_TAC THEN1 (POP_ASSUM ACCEPT_TAC)
>>>>> MATCH_MP_TAC CutRuleSimpl
>>>>> EXISTS_TAC ``(Dot A (Backslash A B))``
>>>>> CONJ_TAC
>>>> | [ MATCH_MP_TAC RightDot
>>>>> CONJ_TAC THEN1 REWRITE_TAC [SeqAxiom]
>>>>> MATCH_MP_TAC LeftSlashSimpl
>>>>> REWRITE_TAC [SeqAxiom],
>>> REWRITE_TAC [application'] ]);
>>> """
>>>
>>> The proof steps are exactly the same, the theorem sets used to prove above
>>> theorem is also the same. After “proving" 100+ such theorems in HOL, I
>>> felt that I’m going toward success to migrate all the Coq scripts, until I
>>> met the following strange definition: (it’s used in proving the
>>> cut-elimination theorem in Lambek’s sequent calculus)
>>>
>>> (* Recursive definition of the degree of a proof which is
>>> the max of the degree of its cut rules (the degree of a cut rule
>>> is the degree of the formula which is eliminated in the conclusion
>>> sequent )*)
>>>
>>> Fixpoint degreeProof (Atoms : Set) (Gamma : Term Atoms)
>>> (B : Form Atoms) (E : gentzen_extension) (p : gentzenSequent E Gamma B)
>>> {struct p} : nat :=
>>> match p with
>>> | Ax _ => 0
>>> | RightSlash _ _ _ H => degreeProof H
>>> | RightBackSlash _ _ _ H => degreeProof H
>>> | RightDot _ _ _ _ H1 H2 => max (degreeProof H1) (degreeProof H2)
>>> | LeftSlash _ _ _ _ _ _ R H1 H2 => max (degreeProof H1) (degreeProof H2)
>>> | LeftBackSlash _ _ _ _ _ _ R H1 H2 =>
>>> max (degreeProof H1) (degreeProof H2)
>>> | LeftDot _ _ _ _ _ R H => degreeProof H
>>> | CutRule _ _ _ A _ R H1 H2 =>
>>> max (max (degreeFormula A) (degreeProof H1)) (degreeProof H2)
>>> | SequentExtension _ _ _ _ _ E R H => degreeProof H
>>> end.
>>>
>>> It’s talking about the “proof” itself. it looks like a recursive function
>>> that I could define using HOL’s Define, but in HOL named like Ax,
>>> RightSlash, … are just names of theorems, and there’s no concept of “proof”
>>> defined so far, so I have no way to express the degree of a proof itself !!
>>> I’m stuck here…
>>>
>>> So my question is: how can I modify my previous definitions to be able to
>>> define “degreeProof” in HOL?
>>>
>>> P. S. I guess Coq is more powerful somehow, such that just "Shallow
>>> Embedding" would be enough to express theorems about proofs themselves. But
>>> in HOL some kinds of "Deep Embedding" is required, but I don’t know how to
>>> do it...
>>>
>>> ---
>>>
>>> Chun Tian (binghe)
>>> University of Bologna (Italy)
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Developer Access Program for Intel Xeon Phi Processors
>>> Access to Intel Xeon Phi processor-based developer platforms.
>>> With one year of Intel Parallel Studio XE.
>>> Training and support from Colfax.
>>> Order your platform today. http://sdm.link/xeonphi
>>> _______________________________________________
>>> hol-info mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/hol-info
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Developer Access Program for Intel Xeon Phi Processors
>>> Access to Intel Xeon Phi processor-based developer platforms.
>>> With one year of Intel Parallel Studio XE.
>>> Training and support from Colfax.
>>> Order your platform today. http://sdm.link/xeonphi
>>>
>>>
>>> _______________________________________________
>>> hol-info mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/hol-info
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> hol-info mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hol-info
signature.asc
Description: Message signed with OpenPGP using GPGMail
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________ hol-info mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/hol-info
