Hi Michael,

thanks very much!   Yesterday Thomas also sent me a similar solution, so I
took your solutions as the "official" solution that HOL can support at
best. (I'll give up with my original proposed syntax "AE x in m. P" which I
took from Isabelle.

The good thing is, actually I don't need a "fake" constant, instead I have
a "default" measure parameter to be used here:

val AE_def = new_definition ("AE_def",
  ``$AE = \P. almost_everywhere Lebesgue P``);

val _ = set_fixity "AE" Binder;
val _ = associate_restriction ("AE", "almost_everywhere");

Now I can define what I wanted before in a beautiful way (almost everywhere
convergence in probability theory):

val converge_AE_def = Define `
    converge_AE X Y p = (!n. real_random_variable (X n) p) /\
real_random_variable Y p /\
AE x::p. (\n. (real (X n x))) --> (real (Y x))`;

As the answer for my second question, I think the main difficulty is that,
in HOL's add_rule syntax, the order of "TM" must be the same as the order
of each parameters in the targeting term.  This limitation, in my option,
is not necessary. I think "TM" should take a number parameter to indicate
exactly which "hole" it is.  But for now, I can just adjust my definition
of "converge_AE", re-ordering its parameters.

So finally I do can express "converge_AE" and another similar "converge_PR"
(convergence in probability) by the following PP definitions:

val _ = add_rule { term_name = "converge_AE", fixity = Closefix,
  pp_elements = [ TOK "", TM, BreakSpace(1,0), TOK "-->", BreakSpace(1,0),
TM,
  BreakSpace(1,0), TOK "(", TM, HardSpace 0, TOK "-a.e.)" ],
  paren_style = OnlyIfNecessary,
  block_style = (AroundEachPhrase, (PP.CONSISTENT, 0)) };

val _ = add_rule { term_name = "converge_PR", fixity = Closefix,
  pp_elements = [ TOK "", TM, BreakSpace(1,0), TOK "-->", BreakSpace(1,0),
TM,
  BreakSpace(1,0), TOK "(in", BreakSpace(1,0), TM, HardSpace 0, TOK ")" ],
  paren_style = OnlyIfNecessary,
  block_style = (AroundEachPhrase, (PP.CONSISTENT, 0)) };

See this test:

> ``converge_AE Xn X p``;
val it =
   ``Xn --> X (p-a.e.)``:
   term
> ``converge_PR Xn X p``;
val it =
   ``Xn --> X (in p)``:
   term

HOL cannot parse them if I wrote them directly as a term (because I have
used some TOK ""). But the pretty printing is indeed satisfied.

I'll look forward for improvements of these PP settings, but for now it's
enough for me to go further, e.g. the general weak and strong law of large
numbers expressed in HOL:

> WLLN_general_def;
val it =
   ``∀p X S' mu.
    indep_real_rvs p X 𝕌(:num) ∧ (∀n. distribution p (X n) = mu) ∧
    (∀n. expectation p (X n) < PosInf) ∧
    (∀x. S' n x = SIGMA (λi. X i x) (count n)) ⇒
    (λn x. (S' n x − expectation p (S' n)) / &n) --> (λx. 0) (in p)``:
   term

> SLLN_general_def;
val it =
   ``∀p X S' mu.
    indep_real_rvs p X 𝕌(:num) ∧ (∀n. distribution p (X n) = mu) ∧
    (∀n. expectation p (X n) < PosInf) ∧
    (∀x. S' n x = SIGMA (λi. X i x) (count n)) ⇒
    (λn x. (S' n x − expectation p (S' n)) / &n) --> (λx. 0) (p-a.e.)``:
   term

Thanks again to you all!

Regards,

Chun Tian

On 7 February 2017 at 07:01, <[email protected]> wrote:

> The only easy way to do this at the moment would be to
>
> - Define a fake constant with the name of the binder you want, but which
> does nothing. E.g.,
>
>      Define`AE x = x`;
>
> - Make it a binder :
>
>      set_fixity “AE” Binder;
>
> - Define your real constant as below:
>
>      Define`almost_everywhere m P = …`
>
> - Then
>
>      associate_restriction ("AE", "almost_everywhere")
>
> Then, you can get the sort of effect you want by writing
>
>    ``AE x::m. P``
>
> The m will be a free variable, and the x will be bound in P. If you do a
> dest_term on it, you will get
>
>    COMB(``almost_everywhere m``, ``\x. P``)
>
> In some future update to HOL, I’d like to make it possible to use the
> set-membership epsilon instead of the ::, which is not a great piece of
> syntax.
>
> I hope this helps.  I will think about your second question some more.
>
> Michael
>
>
> On 7/2/17, 07:58, "Chun Tian (binghe)" <[email protected]> wrote:
>
>     Hi,
>
>     Suppose I have the following definition about a predicate P (with a
> measure space m):
>
>     val almost_everywhere_def = Define `
>         almost_everywhere m P = ?N. null_set m N /\ !x. x IN (UNIV DIFF N)
> ==> P x`;
>
>     (I think you can safely think it as `almost_everywhere m P = !x. P x`.)
>
>     Now my purpose is to define a syntax "AE x in m. P”, which has the
> meaning: ``almost_everywhere m (\x. P)``.  The main difficulty is that, x
> is not a free variable.
>
>     If I try to define it in this (wrong) way:
>
>     val AE_def = Define `AE x m P = almost_everywhere m (\x. P)`;
>
>     val _ = add_rule { term_name = "AE", fixity = Prefix 1000, (* make
> sure lower than limit "-->" *)
>                    pp_elements = [ PPBlock ([TOK "AE", BreakSpace(1,2),
> TM, BreakSpace(1,0), TOK "in"],
>                                             (PP.CONSISTENT, 0)),
>                                    BreakSpace(1,2), TM, HardSpace 0, TOK
> ".", BreakSpace(1,0) ],
>                    paren_style = OnlyIfNecessary,
>                    block_style = (AroundEachPhrase, (PP.INCONSISTENT, 0))
> };
>
>     A test term like the following looks good but actually not:
>
>      > ``AE x in p. (\j. (X_n j x)) --> (X x)``;
>     <<HOL message: inventing new type variable names: 'a, 'b>>
>     val it =
>        ``AE x in p. ((λj. X_n j x) --> X x)``:
>        term
>
>     because somehow the outside “x” is a free variable in this term. So I
> have no way to further define my final concept:
>
>     val converge_AE_def = Define `converge_AE p X_n X = AE x in p. (\j.
> (X_n j x)) --> (X x)`;
>
>     Can anyone suggest a correct way to define the “AE” syntax?
>
>     P. S. furthermore, is it possible to define a pretty printer for the
> last definition “converge_AE p X_n X”, to make it printing into the
> following form?
>
>     X_n --> X (p-a.e.)
>
>     Best Regards,
>
>     Chun Tian
>
>
>
>
>
> ------------------------------------------------------------
> ------------------
> 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
>



-- 
---

Chun Tian (binghe)
University of Bologna (Italy)
------------------------------------------------------------------------------
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

Reply via email to