nibli KR cookbook
Short surface cheat sheet. Normative reference: NIBLI_KR.md (v0.1). Executable grammar: nibli-kr/src/nibli_kr.pest. Examples match the product README language table.
nibli KR is a strict predicate-call surface: one statement per line, ending with a period. Unknown predicate words are a compile error, never a guess — names resolve through the committed English corpus, fail-closed.
Common patterns
| nibli KR / REPL input | Reads as |
|---|---|
dog(Adam). | Adam is a dog |
animal(every dog). | every dog is an animal (a rule) |
~eats(Adam). | Adam does not eat |
past eats(me, some food). | I ate some food |
dog(Adam) & cat(Betis). | conjunction (| or, -> if-then) |
goes(Adam, destination: some market). | named argument places |
beautiful(every person where ~cat). | rule with a negated restrictor (NAF) |
Kim = Adam. | identity |
? red(exactly 2 red). | REPL exact-count query over the current KB (? selects the query route; it is not KR grammar) |
all $x: dangerous($x) & uses(Adam, $x) -> warns($x). | prenex rule with variables |
exactly N and no compile as count formulas only for querying. They cannot
be asserted as persistent cardinality constraints; assert ordinary facts and
re-query the current count.
Predicates and places
dog(Adam).
goes(Adam, destination: some market).
- Positional args fill places in order; named args use corpus place labels (
destination:, …). - Converted aliases and compounds are dictionary-driven; uncurated
a+bcompounds fail closed.
Rules
animal(every dog).
eats(every animal).
dog(Adam).
Description-style universals (every dog) compile to rules. Explicit prenex:
all $x: dog($x) -> animal($x).
For ordinary predicates, temporal wrappers are part of each rule literal’s meaning. A bare rule is unqualified; it is not automatically projected into the past, present, or future. Declare same-flavor taxonomy or cross-flavor causation explicitly:
all $x: past dog($x) -> past animal($x).
all $x: past eats($x) -> now be_hungry($x).
With only all $x: dog($x) -> animal($x)., a past dog(Adam). fact does not
derive past animal(Adam).
Choose exactly one prefix family per atom. past ~eats(Adam). and
must ~eats(Adam). are valid, while must past eats(Adam). and
past must eats(Adam). are compile errors. This restriction is per formula
path, so separate rule literals may still declare a mapping such as
past P -> must Q.
Negation-as-failure
~eats(Adam).
Stratified NAF under closed-world assumptions — see GUARANTEES for oracle coverage. Unstratifiable programs are rejected at assert time.
Where to go next
- Full construct inventory and profiles: NIBLI_KR.md
- IR after compile: LOGIC_IR.md
- Try it without installing: Playground