コード例 #1
0
 def test_sequence(self):
     natural = r"$\left|a_n - b_n \right|$"
     lean = "|a n - b n|"
     context = Context()
     context.add("a", "sequence")
     context.add("b", "sequence")
     test_bijective(self, AbsoluteDiff, natural, lean, context)
コード例 #2
0
 def test_basic(self):
     natural = r"$a_n \leq b_n$ by H1 with n"
     lean = "have A1 : a n ≤ b n := H1 n"
     context = Context()
     context.add("a", "sequence")
     context.add("b", "sequence")
     test_bijective(self, BySentenceWith, natural, lean, context)
コード例 #3
0
 def test_inequality_sequence(self):
     natural = r"$\left|a_n - b_n \right| \leq n$"
     lean = r"|a n - b n| ≤ n"
     context = Context()
     context.add("a", "sequence")
     context.add("b", "sequence")
     test_bijective(self, Inequality, natural, lean, context)
コード例 #4
0
ファイル: bank_page.py プロジェクト: yuruotong1/card_to_life
 def loan(self, describe):
     """
     银行操作,包括贷款
     :param describe: 描述信息
     :return:
     """
     while True:
         Base.draw_text("根据资产评估,您的贷款上限为:", self.loan_limit, ",贷款时间为: 30 年")
         loan_amount = Base.input_text("当前利率为:4%,请输入贷款金额,* 为取消:")
         if loan_amount == "*":
             continue
         elif int(loan_amount) <= self.loan_limit:
             from main.context import Context
             interest = int(int(loan_amount) * self.INTEREST_RATE)
             Context.get_profession().loan.append({
                 "describe":
                 describe,
                 "money": (int(loan_amount) + interest) // 30,
                 "time":
                 30
             })
             self.indicator_money.change(int(loan_amount))
             Base.draw_text(
                 f"贷款成功! 您贷款了 {loan_amount} 元,利息为 {interest} 元\n当前余额:{self.indicator_money.value}"
             )
             break
         elif int(loan_amount) > self.loan_limit:
             Base.draw_text("贷款金额超出上限,请重新选择")
コード例 #5
0
 def test_sequence(self):
     nat = r"$a_n \leq b_n$"
     lean = "a n ≤ b n"
     context = Context()
     context.add("a", "sequence")
     context.add("b", "sequence")
     test_bijective(self, Inequality, nat, lean, context)
コード例 #6
0
 def test_basic(self):
     natural = "Let $n$"
     lean = "intros n A1"
     context = Context()
     context.current_goal = ForAllNatIneqThen(
         "n", Inequality.from_natural(r"$n \leq N$"),
         r"|b_n - l| < \epsilon$")
     test_bijective(self, LetNInequality, natural, lean, context)
コード例 #7
0
 def test_fail(self):
     context = Context()
     natural = r"Let $\epsilon$"
     lean = "intros ε A1"
     context.current_goal = ForAll(
         "n", Inequality(Identifier("a"), InequalityType.GT,
                         Identifier("b")))
     self.assertIsNone(LetGoalLimit.from_natural(natural, context))
     self.assertIsNone(LetGoalLimit.from_lean(lean, context))
コード例 #8
0
 def test_basic(self):
     context = Context()
     RealValuedSequences.from_natural("$a_n, b_n, c_n$ are real-valued",
                                      context)
     RealDeclaration.from_natural(r"$l \in \mathbb{R}$", context)
     SequenceLimit.from_natural(r"$a_n \rightarrow l$", context)
     context.current_goal = SequenceLimit.from_natural(
         r"$b_n \rightarrow l$", context)
     LetGoalLimit.from_natural(r"Let $\epsilon$", context)
     natural = r"Let's choose $N_a$ such that H1 uses $\epsilon$"
     lean = r"cases H1 ε A1 with N_a A2"
     test_bijective(self, ChooseNEpsilonLimit, natural, lean, context)
コード例 #9
0
ファイル: bank_page.py プロジェクト: yuruotong1/card_to_life
 def __init__(self, money: Money):
     Base.draw_text("欢迎来到银行,我行现推出以下业务:")
     # 贷款上限为工资 *10
     # todo:加入资产评估
     from main.context import Context
     self.indicator_money = money
     self.loan_limit = Context.get_profession().get_salary() * 10
コード例 #10
0
ファイル: test_utils.py プロジェクト: azarzadavila/mapros
def test_bijective(self, cls: Type[Language], natural, lean, context=None):
    if context is None:
        context = Context()
    obj = cls.from_natural(natural, context)
    self.assertEqual(obj.to_natural(), natural)
    self.assertEqual(obj.to_lean(), lean)
    obj = cls.from_lean(lean, context)
    self.assertEqual(obj.to_natural(), natural)
    self.assertEqual(obj.to_lean(), lean)
コード例 #11
0
 def __init__(self):
     self.context = Context()
     self.hypotheses = []
     self.initial_goal = None
     self.theorem_name = "anonymous"
     self.proof = []
     self.to_extract = []
     self.contexts = []
     self.initial_context = None
コード例 #12
0
class Main:
    def __init__(self):
        self.context = Context()
        self.home_page = HomePage(self.context)
        self.event_factory = EventFactory(self.context.indicator)

    def main(self):
        self.home_page.choose_occupation()
        # 注册事件
        self.event_factory.register_from_file("../resource/events.yaml")
        while True:
            # 显示指标
            self.context.indicator.show_indicator()
            result = self.event_factory.get_event()
            if result:
                Base.draw_text("操作成功")
            else:
                Base.draw_text("放弃操作")
            # 回合数加 1
            self.context.iteration_bout()
            # 如果到达 100 岁,结束游戏
            if self.context.age == 100:
                return
            # 每回合结束进行清算
            elif self.context.bout == 0:
                # 发工资
                salary = self.context.profession.get_salary()
                Base.draw_text("发工资:" + str(salary))
                self.context.indicator.money.change(
                    self.context.profession.get_salary())
                # 偿还贷款
                for index, loan in enumerate(self.context.profession.loan):
                    # 如果贷款还完,就从贷款列表中清空
                    if loan.get("time") == 0:
                        self.context.profession.loan.pop(index)
                        break
                    Base.draw_text(f"还{loan.get('describe')}贷款:" +
                                   str(loan.get("money")))
                    self.context.indicator.money.change(-loan.get("money"))
                    loan["time"] -= 1

            Base.draw_text("-" * 40)
コード例 #13
0
'''
author: 李经纬
'''

import os
import sys
import eel

# 设置工作目录
script_path = sys.path[0]
os.chdir(script_path)

from main.context import Context

ctx = Context()


@eel.expose
def enable_mpc():
    return ctx.enable_mpc()


@eel.expose
def get_ncpus():
    return ctx.get_ncpus()


@eel.expose
def disable_mpc():
    return ctx.disable_mpc()
コード例 #14
0
 def __init__(self):
     self.context = Context()
     self.home_page = HomePage(self.context)
     self.event_factory = EventFactory(self.context.indicator)
コード例 #15
0
 def test_absdiff(self):
     natural = r"$\left|a_n - l \right| < \epsilon$ by H1 with H2"
     lean = "have A1 : |a n - l| < ε := H1 H2"
     context = Context()
     context.add("a", "sequence")
     test_bijective(self, BySentenceWith, natural, lean, context)
コード例 #16
0
 def test_fail(self):
     natural = "Let $n$"
     lean = "intros n A1"
     self.assertIsNone(LetNInequality.from_natural(natural, Context()))
     self.assertIsNone(LetNInequality.from_lean(lean, Context()))
コード例 #17
0
 def test_basic(self):
     context = Context()
     natural = r"Let $\epsilon$"
     lean = "intros ε A1"
     context.current_goal = SequenceLimit("b", "l")
     test_bijective(self, LetGoalLimit, natural, lean, context)