(self, facts)
Update the KB with all the implications of a list of facts.

        Facts can be specified as a dictionary or as a list of (key, value)
        pairs.
Update the KB with all the implications of a list of facts.
Update the KB with all the implications of a list of facts .
def deduce_all_facts(self, facts):
        """
        Update the KB with all the implications of a list of facts.

        Facts can be specified as a dictionary or as a list of (key, value)
        pairs.
        """
        # keep frequently used attributes locally, so we'll avoid extra
        # attribute access overhead
        full_implications = self.rules.full_implications
        beta_triggers = self.rules.beta_triggers
        beta_rules = self.rules.beta_rules

        if isinstance(facts, dict):
            facts = facts.items()

        while facts:
            beta_maytrigger = set()

            # --- alpha chains ---
            for k, v in facts:
                if not self._tell(k, v) or v is None:
                    continue

                # lookup routing tables
                for key, value in full_implications[k, v]:
                    self._tell(key, value)

                beta_maytrigger.update(beta_triggers[k, v])

            # --- beta chains ---
            facts = []
            for bidx in beta_maytrigger:
                bcond, bimpl = beta_rules[bidx]
                if all(self.get(k) is v for k, v in bcond):
                    facts.append(bimpl)
def deduce_all_facts ( self , facts ) : # keep frequently used attributes locally, so we'll avoid extra # attribute access overhead full_implications = self . rules . full_implications beta_triggers = self . rules . beta_triggers beta_rules = self . rules . beta_rules if isinstance ( facts , dict ) : facts = facts . items ( ) while facts : beta_maytrigger = set ( ) # --- alpha chains --- for k , v in facts : if not self . _tell ( k , v ) or v is None : continue # lookup routing tables for key , value in full_implications [ k , v ] : self . _tell ( key , value ) beta_maytrigger . update ( beta_triggers [ k , v ] ) # --- beta chains --- facts = [ ] for bidx in beta_maytrigger : bcond , bimpl = beta_rules [ bidx ] if all ( self . get ( k ) is v for k , v in bcond ) : facts . append ( bimpl )