Exemplo n.º 1
0
def preproof():
    while True:
        yield (proof_kwd() << shift_eq >> (
            lambda pk: choice([
                use(suppress()) << shift_eq >> (lambda supp: choice([
                    intf.locate(kwd('BY')) << times2 >> only() << times2 >>
                    use(usebody()) << times >> read_method() << apply >>
                    (lambda args: tla_ast.PreBy(supp, args[0][0][1], args[0][
                        1], args[1])),
                    intf.locate(
                        kwd('OBVIOUS') << second >> read_method() << apply >>
                        (lambda meth: tla_ast.PreObvious(supp, meth)))
                ])),

                # locate (kwd "OMITTED" <!> (PreOmitted Explicit)) ;
                intf.locate(
                    kwd('OMITTED') << bang >> tla_ast.PreOmitted(tla_ast.
                                                                 Explicit())),

                #  locate begin
                #           preno <**> use prestep
                #           <$> (fun (pn, stp) ->
                #                   PreStep (pk, pn, stp))
                #         end ;
                intf.locate(preno() << times2 >> use(prestep()) << apply >>
                            (lambda pn_stp: tla_ast.PreStep(
                                pk, pn_stp[0], pn_stp[1])))
            ])))
Exemplo n.º 2
0
def proof():
    while True:
        yield choice([
            star1(use(preproof())),
            intf.locate(succeed(tla_ast.PreOmitted(tla_ast.Implicit()))) <<
            apply >> (lambda pp: [pp])
        ]) << apply >> toplevel
Exemplo n.º 3
0
def sequent():
    while True:
        yield choice([
            use(ep.sequent(False)),
            use(ep.expr(False)) << apply >>
            (lambda e: tla_ast.Sequent(list(), e))
        ])
Exemplo n.º 4
0
def suppress():
    while True:
        yield choice([
            intf.pragma(punct('_') << or_ >> intf.ident('suppress')) << bang >>
            tla_ast.Suppress(),
            succeed(tla_ast.Emit())
        ])
Exemplo n.º 5
0
 def f():
     return (
         (kwd('THEOREM') << or_ >> kwd('PROPOSITION') << or_ >>
          kwd('COROLLARY') << or_ >> kwd('LEMMA')) << second_commit >>
         optional(intf.locate(intf.anyident() << first >> punct('==')))
         << times >> choice([
             use(ep.sequent(False)),
             use(ep.expr(False)) << apply >>
             (lambda e: nodes.Sequent(list(), e))
         ]) << times >> optional(use(pfp.method_prs_read_method())) <<
         times >> use(pfp.proof()) << apply >> apply_theorem_proof)
Exemplo n.º 6
0
        def f():
            return choice([
                # ['CONSTANT' | 'CONSTANTS'] opdecl (',' opdecl)*
                kwd('CONSTANT') << or_ >> kwd('CONSTANTS') << second_commit >>
                sep1(punct(','), use(ep.opdecl())) << apply >>
                (lambda cs: [nodes.Constants(cs)]),

                # 'RECURSIVE' opdecl (',' opdecl)*
                kwd('RECURSIVE') << second_commit >> sep1(
                    punct(','), use(ep.opdecl())) << apply >>
                (lambda cs: [nodes.Recursives(cs)]),

                # ['VARIABLE' | 'VARIABLES'] anyident (',' anyident)*
                kwd('VARIABLE') << or_ >> kwd('VARIABLES') << second_commit >>
                sep1(punct(','), locate(intf.anyident())) << apply >>
                (lambda vs: [nodes.Variables(vs)])
            ])
Exemplo n.º 7
0
def definable():
    while True:
        yield intf.locate(
            sep1(intf.punct('!'), choice([intf.anyop(),
                                          intf.anyident()])) << apply >>
            (lambda ids: tla_ast.Dvar('!'.join(ids))))
Exemplo n.º 8
0
def prestep():
    while True:
        yield choice([
            #     choice [
            #       kwd "QED" <!> PreQed ;
            kwd('QED') << bang >> tla_ast.PreQed(),
            #
            #       kwd "HIDE"
            #       >*> use usebody
            #       <$> (fun use -> PreHide use) ;
            kwd('HIDE') << second_commit >> use(usebody()) << apply >>
            (lambda use: tla_ast.PreHide(use)),
            #
            #       kwd "SUFFICES"
            #       >*> use sequent
            #       <$> (fun sq -> PreSuffices sq) ;
            kwd('SUFFICES') << second_commit >> use(sequent()) << apply >>
            (lambda sq: tla_ast.PreSuffices(sq)),
            #
            #       kwd "CASE"
            #       >*> use (expr false)
            #       <$> (fun e -> PreCase e) ;
            kwd('CASE') << second_commit >> use(ep.expr(False)) << apply >>
            (lambda e: tla_ast.PreCase(e)),
            #
            #       kwd "PICK"
            #       >*> use (bounds false)
            #       <**> (punct ":"
            #             >>> use (expr false))
            #       <$> (fun (bs, e) -> PrePick (bs, e)) ;
            kwd('PICK') << second_commit >> use(ep.bounds(False)) << times2 >>
            (punct(':') << second >> use(ep.expr(False))) << apply >>
            (lambda bs_e: tla_ast.PrePick(bs_e[0], bs_e[1])),
            #
            #       use suppress >>= begin fun supp ->
            use(suppress()) << shift_eq >> (
                lambda supp: choice([
                    #         choice [
                    #           kwd "USE"
                    #           >*> only
                    #           <*> use usebody
                    #           <*> read_method
                    #           <$> (fun ((onl, use), meth) ->
                    #                   PreUse (supp, onl, use, meth)) ;
                    kwd('USE') << second_commit >> only() << times >> use(
                        usebody()) << times >> read_method() << apply >>
                    (lambda args: tla_ast.PreUse(supp, args[0][0], args[0][1],
                                                 args[1])),
                    #
                    #           kwd "HAVE"
                    #           >*> use (expr false)
                    #           <*> read_method
                    #           <$> (fun (e, meth) -> PreHave (supp, e, meth)) ;
                    kwd('HAVE') << second_commit >> use(ep.expr(
                        False)) << times >> read_method() << apply >>
                    (lambda e_meth: tla_ast.PreHave(supp, e_meth[0], e_meth[1])
                     ),
                    #
                    #           kwd "TAKE"
                    #           >*> use (bounds false)
                    #           <*> read_method
                    #           <$> (fun (bs, meth) -> PreTake (supp, bs, meth)) ;
                    kwd('TAKE') << second_commit >> use(ep.bounds(
                        False)) << times >> read_method() << apply >>
                    (lambda bs_meth: tla_ast.PreTake(supp, bs_meth[0], bs_meth[
                        1])),
                    #
                    #           kwd "WITNESS"
                    #           >*> sep1 (punct ",") (use (expr false))
                    #           <*> read_method
                    #           <$> (fun (es, meth) -> PreWitness (supp, es, meth)) ;
                    kwd('WITNESS') << second_commit >> sep1(
                        punct(','), use(ep.expr(False))
                    ) << times >> read_method() << apply >>
                    (lambda es_meth: tla_ast.PreWitness(
                        supp, es_meth[0], es_meth[1]))
                    #         ]
                    #       end ;
                ])),
            #
            #       attempt (optional (kwd "DEFINE") >>> star1 (use (defn false)))
            #       <$> (fun dfs -> PreDefine dfs) ;
            attempt(
                optional(kwd('DEFINE')) << second >> star1(use(ep.defn(False)))
            ) << apply >> (lambda defns: tla_ast.PreDefine(defns)),
            #
            #       use sequent <$> (fun sq -> PreAssert sq) ;
            use(sequent()) << apply >> (lambda sq: tla_ast.PreAssert(sq))
            #     ]
        ])
Exemplo n.º 9
0
def proof_kwd():
    while True:
        yield choice([kwd('PROOF') << bang >> True, succeed(False)])
Exemplo n.º 10
0
def only():
    while True:
        yield choice([
            kwd('ONLY') << bang >> tla_ast.Only(),
            succeed(tla_ast.Default())
        ])