  # Asserting New Facts some_engine.add_universal_fact(kb_name, fact_name, arguments) The `add_universal_fact` function is called once per fact. These facts are never deleted and apply to all cases. Alternatively, you can place universal facts in a .kfb file so that they are loaded automatically.
      >>> my_engine.add_universal_fact('family', 'son_of', ('bruce', 'thomas'))
  Multiple facts with the same name are allowed.
      >>> my_engine.add_universal_fact('family', 'son_of', ('david', 'bruce'))
  But duplicate facts (with the same arguments) are silently ignored.
      >>> my_engine.add_universal_fact('family', 'son_of', ('david', 'bruce'))
      >>> my_engine.get_kb('family').dump_universal_facts()
      son_of('bruce', 'thomas')
      son_of('david', 'bruce')
  These facts are accessed as `kb_name.fact_name(arguments)` within the .krb files. some_engine.assert_(kb_name, fact_name, arguments) Call `assert_` for each starting fact for this case. Like universal facts, you may have multiple facts with the same name so long as they have different arguments.
      >>> my_engine.assert_('family', 'son_of', ('michael', 'bruce'))
      >>> my_engine.assert_('family', 'son_of', ('fred', 'thomas'))
      >>> my_engine.assert_('family', 'son_of', ('fred', 'thomas'))
  Duplicates with universal facts are also ignored.
      >>> my_engine.assert_('family', 'son_of', ('bruce', 'thomas'))
      >>> my_engine.get_kb('family').dump_specific_facts()
      son_of('michael', 'bruce')
      son_of('fred', 'thomas')
      >>> my_engine.get_kb('family').dump_universal_facts()
      son_of('bruce', 'thomas')
      son_of('david', 'bruce')
  There is no difference within the .krb files of how universal facts verses case specific facts are used. The only difference between the two types of facts is that the case specific facts are deleted when a `reset` is done.
      >>> my_engine.reset()
      >>> my_engine.get_kb('family').dump_specific_facts()
      >>> my_engine.get_kb('family').dump_universal_facts()
      son_of('bruce', 'thomas')
      son_of('david', 'bruce')
Copyright © 2007-2009 Bruce Frederiksen

Page last modified Mon, Mar 08 2010.