def testParseProof2(self): data = { 'vars': {}, 'proof': [ {'id': 0, 'rule': 'variable', 'args': "a, 'a", 'prevs': [], 'th': ''} ] } state = ProofState.parse_proof(thy, data) self.assertEqual(len(state.prf.items), 1)
def testParseProof(self): data = { 'vars': {'A': 'bool', 'B': 'bool'}, 'proof': [ {'id': 0, 'rule': 'assume', 'args': 'A & B', 'prevs': [], 'th': ''}, {'id': 1, 'rule': 'sorry', 'args': '', 'prevs': [], 'th': 'A & B |- B & A'}, {'id': 2, 'rule': 'implies_intr', 'args': 'A & B', 'prevs': [1], 'th': ''} ] } state = ProofState.parse_proof(thy, data) self.assertEqual(len(state.vars), 2) self.assertEqual(len(state.prf.items), 3)
def init_saved_proof(): """Load saved proof.""" data = json.loads(request.get_data().decode("utf-8")) if data: try: thy = basic.load_theory(data['theory_name'], limit=('thm', data['thm_name']), user=user_info['username']) cell = ProofState.parse_proof(thy, data) cells[data['id']] = cell return jsonify(cell.json_data()) except Exception as e: error = {"failed": e.__class__.__name__, "message": str(e)} return jsonify(error) return jsonify({})