Get an unsatisfiable core if the formula was previously
            unsatisfied.
196740
def get_core(self):
        

        if self.maplesat and self.status == False:
            return pysolvers.maplechrono_core(self.maplesat)
1233913
def check_path_satisfiability(code_analyzer, path, start_address):
        
        start_instr_found = False
        sat = False

        # Traverse basic blocks, translate its instructions to SMT
        # expressions and add them as assertions.
        for bb_curr, bb_next in zip(path[:-1], path[1:]):
            logger.info("BB @ {:#x}".format(bb_curr.address))

            # For each instruction...
            for instr in bb_curr:
                # If the start instruction have not been found, keep
                # looking...
                if not start_instr_found:
                    if instr.address == start_address:
                        start_instr_found = True
                    else:
                        continue

                logger.info("{:#x} {}".format(instr.address, instr))

                # For each REIL instruction...
                for reil_instr in instr.ir_instrs:
                    logger.info("{:#x} {:02d} {}".format(reil_instr.address >> 0x8, reil_instr.address & 0xff,
                                                         reil_instr))

                    if reil_instr.mnemonic == ReilMnemonic.JCC:
                        # Check that the JCC is the last instruction of
                        # the basic block (skip CALL instructions.)
                        if instr.address + instr.size - 1 != bb_curr.end_address:
                            logger.error("Unexpected JCC instruction: {:#x} {} ({})".format(instr.address,
                                                                                            instr,
                                                                                            reil_instr))

                            # raise Exception()

                            continue

                        # Make sure branch target address from current
                        # basic block is the start address of the next.
                        assert(bb_curr.taken_branch == bb_next.address or
                               bb_curr.not_taken_branch == bb_next.address or
                               bb_curr.direct_branch == bb_next.address)

                        # Set branch condition accordingly.
                        if bb_curr.taken_branch == bb_next.address:
                            branch_var_goal = 0x1
                        elif bb_curr.not_taken_branch == bb_next.address:
                            branch_var_goal = 0x0
                        else:
                            continue

                        # Add branch condition goal constraint.
                        code_analyzer.add_constraint(code_analyzer.get_operand_expr(reil_instr.operands[0]) == branch_var_goal)

                        # The JCC instruction was the last within the
                        # current basic block. End this iteration and
                        # start next one.
                        break

                    # Translate and add SMT expressions to the solver.
                    code_analyzer.add_instruction(reil_instr)

            sat = code_analyzer.check() == 'sat'

            logger.info("BB @ {:#x} sat? {}".format(bb_curr.address, sat))

            if not sat:
                break

        # Return satisfiability.
        return sat
757621
def unbounded(self):
        """"""
        self._check_valid()

        cp = self._problem._cp
        status = cp.solution.get_status()
        presolve = cp.parameters.preprocessing.presolve.get()
        if (status == cp.solution.status.infeasible_or_unbounded and
                presolve):
            # Disable presolve to obtain a definitive answer
            logger.info('Disabling presolver and solving again to determine'
                        ' whether objective is unbounded.')
            cp.parameters.preprocessing.presolve.set(False)
            try:
                self._problem._solve()
            finally:
                cp.parameters.preprocessing.presolve.set(True)

            status = cp.solution.get_status()

        return status == cp.solution.status.unbounded
184024
def _is_always_unsatisfied(self):
        
        # If this is a github sha tarball, then it is always unsatisfied
        # because the url has a commit sha in it and not the version
        # number.
        url = self._url()
        if url:
            filename = filename_from_url(url)
            if filename.endswith(ARCHIVE_EXTENSIONS):
                filename, ext = splitext(filename)
                if is_git_sha(filename):
                    return True
        return False
878813
def _sat(lexer, varname):
    """"""
    _expect_token(lexer, {KW_p})
    fmt = _expect_token(lexer, {KW_sat, KW_satx, KW_sate, KW_satex}).value
    nvars = _expect_token(lexer, {IntegerToken}).value
    return _sat_formula(lexer, varname, fmt, nvars)
690108
def is_satisfied(self, x_cat):
        
        satisfied = []
        if self.is_default():
            return np.ones(x_cat.shape[0], dtype=bool)
        for idx, cat in self.clauses:
            satisfied.append(x_cat[:, idx] == cat)
        return reduce(np.logical_and, satisfied)
1100589
def get(self, key, failobj=None, exact=0):
        """"""
        if not exact:
            key = self.getfullkey(key,new=1)
        return self.data.get(key,failobj)
1307121
def apply_outcomes(self, outcomes, uio, dropped=False, prevxn=None):
        
        if self.dropped and not dropped:
            # do nothing for dropped xn, unless specifically told to
            return

        if 'drop' in outcomes:
            highscore = score.score(outcomes['drop'].highest()[0])
            if highscore >= threshold['y']:
                # drop without prompting
                self.dropped = True
            elif highscore < threshold['n?']:
                # do NOT drop, and don't even ask
                pass
            else:
                uio.show('DROP was determined for transaction:')
                uio.show('')
                uio.show(self.summary())
                if highscore >= threshold['y?']:
                    default = True
                elif highscore >= threshold['?']:
                    default = None
                else:
                    default = False
                try:
                    self.dropped = uio.yn('DROP this transaction?', default)
                except ui.RejectWarning:
                    # we assume they mean "no"
                    pass

        if self.dropped and not dropped:
            # do nothing further for dropped xn, unless specifically told to
            return

        # rebate outcomes
        #
        # A rebate is a rebate of the previous transaction.
        # The proportions of credits in the prev xn are kept,
        # inverted (i.e. made debits) and scaled to the rebate
        # amount credit amount.
        if 'rebate' in outcomes and not self.src and prevxn is not None:
            ratio = self.amount / prevxn.amount
            def scale(dst_ep):
                amount = (dst_ep.amount * ratio).quantize(dst_ep.amount)
                return Endpoint(dst_ep.account, -amount)
            self.src = map(scale, prevxn.dst)
            # handle rounding errors
            self.src[0].amount -= self.amount + sum(x.amount for x in self.src)

        # account outcomes
        for outcome in ['src', 'dst']:
            if outcome not in outcomes or getattr(self, outcome):
                # no outcome, or the attribute was already set
                continue

            endpoints = []
            highest = outcomes[outcome].highest()
            try:
                highscore = score.score(highest[0])
                if len(highest) == 1:
                    if highscore >= threshold['y']:
                        # do it
                        endpoints = [
                            Endpoint(score.value(highest[0]), self.amount)
                        ]
                    else:
                        uio.show('Choose ' + outcome + ' for transaction:')
                        uio.show('')
                        uio.show(self.summary())

                        prompt = 'Is the account {0}?'.format(
                            score.value(highest[0])
                        )
                        if highscore >= threshold['y?']:
                            default = True
                        elif highscore >= threshold['?']:
                            default = None
                        else:
                            default = False
                        if uio.yn(prompt, default):
                            endpoints = [
                                Endpoint(
                                    score.value(highest[0]),
                                    self.amount
                                )
                            ]
                        else:
                            raise ui.RejectWarning('top score declined')
                else:
                    # tied highest score, let user pick
                    uio.show('Choose ' + outcome + ' for transaction:')
                    uio.show('')
                    uio.show(self.summary())

                    prompt = 'Choose an account'
                    endpoints = [
                        Endpoint(
                            uio.choose(prompt, map(score.value, highest)),
                            self.amount
                        )
                    ]

            except ui.RejectWarning:
                # user has rejected our offer(s)
                uio.show("\n")
                uio.show('Enter ' + outcome + ' endpoints:')
                try:
                    endpoints = []
                    remaining = self.amount
                    while remaining:
                        uio.show('\n${0} remaining'.format(remaining))
                        account = uio.text(
                            ' Enter account',
                            score.value(highest[0]) if highest else None
                        )
                        amount = uio.decimal(
                            ' Enter amount',
                            default=remaining,
                            lower=0,
                            upper=remaining
                        )
                        endpoints.append(Endpoint(account, amount))
                        remaining = self.amount \
                            - sum(map(lambda x: x.amount, endpoints))
                except ui.RejectWarning:
                    # bail out
                    sys.exit("bye!")

            # flip amounts if it was a src outcome
            if outcome == 'src':
                endpoints = map(
                    lambda x: Endpoint(x.account, -x.amount),
                    endpoints
                )

            # set endpoints
            setattr(self, outcome, endpoints)
644521
def get_formula(self, period = None):
        

        if not self.formulas:
            return None

        if period is None:
            return self.formulas.peekitem(index = 0)[1]  # peekitem gets the 1st key-value tuple (the oldest start_date and formula). Return the formula.

        if isinstance(period, periods.Period):
            instant = period.start
        else:
            try:
                instant = periods.period(period).start
            except ValueError:
                instant = periods.instant(period)

        if self.end and instant.date > self.end:
            return None

        instant = str(instant)
        for start_date in reversed(self.formulas):
            if start_date <= instant:
                return self.formulas[start_date]

        return None
150276
def recompute_if_necessary(self, ui):
        """"""
        self.__initialize_cache()
        if self.__cached_value_dirty:
            with self.__is_recomputing_lock:
                is_recomputing = self.__is_recomputing
                self.__is_recomputing = True
            if is_recomputing:
                pass
            else:
                # the only way to get here is if we're not currently computing
                # this has the side effect of limiting the number of threads that
                # are sleeping.
                def recompute():
                    try:
                        if self.__recompute_thread_cancel.wait(0.01):  # helps tests run faster
                            return
                        minimum_time = 0.5
                        current_time = time.time()
                        if current_time < self.__cached_value_time + minimum_time:
                            if self.__recompute_thread_cancel.wait(self.__cached_value_time + minimum_time - current_time):
                                return
                        self.recompute_data(ui)
                    finally:
                        self.__is_recomputing = False
                        self.__recompute_thread = None
                with self.__is_recomputing_lock:
                    self.__recompute_thread = threading.Thread(target=recompute)
                    self.__recompute_thread.start()
531567
def optimise_newton(x, a, c, tolerance=0.001):
    
    x_new = x
    x_old = x-1 # dummy value
    while np.abs(x_new - x_old).sum() > tolerance:
        x_old = x_new
        x_new = newton_update(x_old, a, c)
    return x_new
1152648
def _get_future_expected_model(self, core_element):
        """"""
        for model in self.expected_future_models:
            if model.core_element is core_element:
                # print("expected_future_model found -> remove model:", model, [model], id(model))
                self.expected_future_models.remove(model)
                return model
        return None
1230504
@Override
    public final boolean satisfiedForConsume(final FilterOutcomes outcomes, final InputRow row) {
        final boolean satisfiedOutcomesForConsume =
                satisfiedOutcomesForConsume(_hasComponentRequirement, row, outcomes);
        if (!satisfiedOutcomesForConsume) {
            return false;
        }
        return satisfiedInputsForConsume(row, outcomes);
    }
922419
def get_smtlib_script_satisfiability(self, extra_constraints=(), extra_variables=()):
        
        try:
            e_csts = self._solver_backend.convert_list(extra_constraints + tuple(self.constraints))
            e_variables = self._solver_backend.convert_list(extra_variables)

            variables, csts = self._solver_backend._get_all_vars_and_constraints(e_c=e_csts, e_v=e_variables)
            return self._solver_backend._get_satisfiability_smt_script(csts, variables)
        except BackendError as e:
            raise ClaripyFrontendError("Backend error during smtlib script generation") from e
65448
public static Backbone computeNegative(final Collection<Formula> formulas) {
        return compute(formulas, allVariablesInFormulas(formulas), BackboneType.ONLY_NEGATIVE);
    }
995175
def satisfies?(target)
      target = Semverse::Version.coerce(target)

      return false if !(version == 0) && greedy_match?(target)

      compare(target)
    end
626901
def satisfies?(target)
      target = Version.coerce(target)

      if !version.zero? && greedy_match?(target)
        return false
      end

      OPERATORS[operator].call(self, target)
    end