Exemplo n.º 1
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.º 2
0
def to_proof(currlv, arg):
    #   | [] ->
    if not arg:
        #       (Omitted Implicit @@ currlv, [])
        omitted = tla_ast.Omitted(tla_ast.Implicit())
        return (omitted, list())
#   | {core = PreBy (supp, onl, use, meth)} as p :: ps ->
    elif isinstance(arg[0], tla_ast.PreBy):
        p = arg[0]
        ps = arg[1:]
        supp = p.supp
        only = p.only
        usable = p.usable
        meth = p.method
        #       let p = By (use, onl = Only) @@ p in
        p = tla_ast.By(usable, isinstance(only, tla_ast.Only))
        #       let p = Property.assign p Props.step
        #                   (Unnamed (currlv.core, 0)) in
        p.step_number = tla_ast.Unnamed(currlv, 0)
        #       (annotate supp meth p, ps)
        annotate(supp, meth, p)
        return (p, ps)
#   | {core = PreObvious (supp, meth)} as p :: ps ->
    elif isinstance(arg[0], tla_ast.PreObvious):
        p = arg[0]
        ps = arg[1:]
        supp = p.supp
        meth = p.method
        #       let p = Obvious @@ p in
        obvious = tla_ast.Obvious()
        #       (annotate supp meth p, ps)
        annotate(supp, meth, obvious)
        return (obvious, ps)
#   | {core = PreOmitted om} as p :: ps ->
    elif isinstance(arg[0], tla_ast.PreOmitted):
        p = arg[0]
        ps = arg[1:]
        om = p.omission
        #       (Omitted om @@ p, ps)
        omitted = tla_ast.Omitted(om)
        return (omitted, ps)
    else:
        #   | ps -> begin
        ps = arg
        #       try
        try:
            #         let (ss, qp, ps) = to_steps ~first:true currlv ps in
            (ss, qp, ps) = to_steps(first=True, currlv=currlv, ps=ps)
            #         let sloc = List.fold_left begin
            #           fun l s -> Loc.merge l (Util.get_locus s)
            #         end (try
            #               Util.get_locus qp.core
            #              with _ -> Util.get_locus
            #                           (get_qed_proof qp.core)) ss in
            # TODO: locus
            #         let prf = Util.locate (Steps (ss, qp.core)) sloc in
            prf = tla_ast.Steps(ss, qp)
            #         let prf = Property.assign prf Props.step
            #                   (Property.get qp Props.step) in
            prf.step_number = qp.step_number
            #         (prf, ps)
            return (prf, ps)
#       with Backtrack ->
        except Backtrack:
            #         (Omitted Implicit @@ currlv, ps)
            omitted = tla_ast.Omitted(tla_ast.Implicit())
            return (omitted, ps)