This project implements an Ethiopian Recipe Recommendation Agent using symbolic cognitive architecture principles with backward chaining reasoning. The agent demonstrates key concepts from cognitive architectures like ACT-R and Soar, implemented in the MeTTa programming language with deep knowledge of Ethiopian cuisine.
Symbolic Cognitive Architecture for Ethiopian Cuisine - The agent uses:
- Rule-based reasoning with explicit logical rules for Ethiopian recipes
- Declarative knowledge (facts about Ethiopian ingredients, recipes, dietary restrictions)
- Procedural knowledge (rules for making Ethiopian recipe recommendations)
- Goal-directed backward chaining (similar to Soar's problem-space search)
- Proof construction for explainable reasoning (similar to ACT-R's production traces)
- Cultural intelligence about Ethiopian culinary traditions
ask_questions.metta- Interactive Ethiopian recipe agent interface (main file to use)knowledge_base.metta- Comprehensive Ethiopian ingredient and recipe knowledge baserules.metta- Logical rules for Ethiopian recipe recommendation reasoningagent.metta- Advanced agent implementation with Ethiopian culinary cognitive functions
(: syn (-> Atom Nat Atom Atom))- Implements goal-directed reasoning
- Constructs proof trees showing reasoning steps
- Provides explainable AI capabilities
- Ingredient Properties: protein, vegetable, grain classifications
- Recipe Requirements: ingredient-to-recipe mappings
- Dietary Information: vegetarian/vegan compatibility
- Nutritional Data: protein content, cooking times
- User Preferences: dietary restrictions, time constraints
- Dietary Restriction Handling: Vegetarian/vegan recipe filtering
- Nutritional Matching: High-protein, low-carb recommendations
- Time Preference Reasoning: Quick vs. complex recipe suggestions
- Ingredient Substitution: Protein substitution logic
- Multi-constraint Satisfaction: Combining multiple user requirements
- Production System: Rule matching and firing
- Working Memory: Current ingredient availability
- Goal-directed Search: Backward chaining from desired outcomes
- Explanation Generation: Reasoning trace construction
metta ask_questions.metta- Open
ask_questions.metta - Replace the example question with any question from
questions_list.md - Run the file to see proof-based answers
Question: "What recipes can we make with available ingredients?"
Agent Response:
- Chicken Stir Fry (with proof: has chicken, broccoli, rice)
- Tofu Scramble (with proof: has tofu, spinach, mushroom)
- Pasta Dish (with proof: has pasta, tomato, onion)
Question: "What vegetarian recipes can Alice make?"
Agent Response:
- Tofu Scramble (proof chain: Alice is vegetarian β tofu/spinach/mushroom are vegetarian β recipe is vegetarian β recommend)
- Pasta Dish (proof chain: Alice is vegetarian β pasta/tomato/onion are vegetarian β recipe is vegetarian β recommend)
Question: "What high-protein recipes can Bob make?"
Agent Response:
- Chicken Stir Fry (proof: Bob wants high protein β chicken stir fry has high protein β can make β recommend)
- Tofu Scramble (proof: Bob wants high protein β tofu scramble has high protein β can make β recommend)
- Uses explicit rules and logical symbols
- No neural networks or statistical learning
- Pure logic-based inference
- Rules match current conditions
- Selected rules fire to update system state
- Cycle continues until goal is reached
- Goal-directed backward chaining
- Subgoal creation when needed
- State-operator-result cycles
- Declarative: Facts about ingredients, recipes, users
- Procedural: Rules for making recommendations
- Clear separation like ACT-R architecture
- Every conclusion comes with proof
- Shows complete reasoning chain
- Enables trust and debugging
The agent can chain multiple rules together:
- User has dietary restriction
- Recipe uses specific ingredients
- Ingredients match dietary restriction
- Therefore recipe is suitable
- We have all ingredients available
- Therefore recommend recipe
The agent assesses confidence based on proof complexity:
- High: Direct single-rule inference
- Medium: Two-rule chain
- Low: Complex multi-rule reasoning
Basic learning from user feedback:
- Strengthen rules for liked recommendations
- Weaken rules for disliked recommendations
- Maintain neutral rules
;; Base case: Direct match in knowledge base
(= (syn $kb $_ (: $prf $ccln))
(match $kb (: $prf $ccln) (: $prf $ccln)))
;; Recursive step: Apply rules to derive conclusions
(= (syn $kb (S $k) (: ($prfabs $prfarg) $ccln))
(let* (((: $prfabs (-> $prms $ccln)) (syn $kb $k (: $prfabs (-> $prms $ccln))))
((: $prfarg $prms) (syn $kb $k (: $prfarg $prms))))
(: ($prfabs $prfarg) $ccln)));; Example rule: Recipe recommendation based on dietary restrictions
!(add-atom &kb (: vegetarian-recommendation-rule
(-> (IsVegetarian $person)
(-> (IsVegetarianRecipe $recipe)
(-> (CanMake $recipe)
(RecommendFor $recipe $person))))))This project demonstrates:
- Symbolic AI: Rule-based reasoning systems
- Cognitive Architectures: ACT-R and Soar principles
- Backward Chaining: Goal-directed inference
- Explainable AI: Proof construction and reasoning traces
- Knowledge Representation: Structured domain knowledge
- Multi-constraint Reasoning: Complex decision making
Unlike the simple frog/canary example from training, this agent:
- Larger Knowledge Base: 100+ facts vs. 5 facts
- Multiple File Structure: Professional organization
- Complex Reasoning: Multi-step inference chains
- Real-world Domain: Practical recipe recommendations
- Multiple User Types: Different preferences and constraints
- Advanced Features: Substitution, confidence, learning simulation
Potential enhancements:
- Hybrid Architecture: Add neural components for ingredient similarity
- Temporal Reasoning: Seasonal ingredient availability
- Probabilistic Logic: Uncertainty in preferences
- Multi-agent System: Multiple recommendation agents
- Learning: Adaptive rule weights based on feedback
This Recipe Recommendation Agent successfully demonstrates symbolic cognitive architecture principles using backward chaining in MeTTa. It provides explainable, multi-step reasoning for recipe recommendations while handling complex constraints and user preferences.
The agent showcases the power of symbolic AI for domains requiring transparent, logical reasoning with clear explanation capabilities.