Skip to main content

Prolog-powered system optimizer - uses logical reasoning to optimize your system

Project description

prolog-ninja

Prolog-powered system optimizer - uses logical reasoning to optimize your computer for specific tasks.

The "wheel within a wheel" - a reasoning engine inside a Python package that analyzes your hardware and generates smart optimization recommendations.

How It Works

  1. Detects your system hardware (CPU, RAM, GPU, disk, power status)
  2. Converts hardware specs into Prolog-style facts
  3. Reasons using rules to determine suitability and optimizations
  4. Recommends (or applies) settings for your chosen task
Your Hardware → Facts → Prolog Engine → Rules → Recommendations
     ↓              ↓                      ↓
  CPU: 8 cores   cpu_cores(8)    suitable_for(gaming, good) :-
  RAM: 16GB      ram_gb(16)          has_dedicated_gpu(true),
  GPU: RTX 3080  gpu_vendor(nvidia)  ram_gb(R), R >= 8.

Installation

pip install prolog-ninja

Quick Start

# See your system info
prolog-ninja info

# List available optimization tasks
prolog-ninja list

# Get recommendations for gaming
prolog-ninja optimize gaming

# Check if your system can handle ML training
prolog-ninja check ml_training

# See the reasoning behind recommendations
prolog-ninja explain gaming

# Interactive mode
prolog-ninja interactive

Available Tasks

Task Description
gaming Optimize for gaming performance
video_editing Optimize for video editing (Premiere, DaVinci)
programming Optimize for software development
ml_training Optimize for machine learning training
streaming Optimize for live streaming (OBS)
3d_modeling Optimize for 3D modeling (Blender, Maya)
audio_production Optimize for audio production (DAWs)
compiling Optimize for compiling large projects
virtualization Optimize for running VMs
data_analysis Optimize for data analysis (pandas, R)
office Optimize for office work
web_dev Optimize for web development
battery_saver Maximize battery life
quiet Minimize fan noise
balanced Balanced performance

Usage Examples

Check System Info

$ prolog-ninja info

==================================================
SYSTEM INFORMATION
==================================================

OS: Linux 6.6.87
    (Running in WSL)

CPU: AMD Ryzen 7 5800X
    Cores: 16 (8 physical)
    Tier: HIGH

RAM: 32.0 GB total (24.5 GB available)
    Tier: HIGH

GPU: NVIDIA GeForce RTX 3080 (10.0 GB VRAM)
    Dedicated: Yes
    Tier: HIGH

Disk: NVME - 500 GB total (234 GB free)
    Tier: HIGH

Power: Desktop (AC)

Get Optimization Recommendations

$ prolog-ninja optimize gaming

============================================================
OPTIMIZATION REPORT: GAMING
============================================================

Task: Optimize for gaming performance

--- System Summary ---
  CPU: 16 cores (high)
  RAM: 32.0 GB (high)
  GPU: nvidia GeForce RTX 3080 (high)
  DISK: nvme (high)

Suitability: EXCELLENT

--- Recommended Optimizations ---
  1. Set power plan to High Performance for maximum speed
  2. Set GPU to prefer maximum performance
  3. Disable unnecessary background applications
  4. Set application priority to High

Run Prolog Queries

$ prolog-ninja query "suitable_for(X, excellent)"

Query: suitable_for(X, excellent)
----------------------------------------
Found 3 solution(s):

  1. X = gaming
  2. X = programming
  3. X = compiling

Explain the Reasoning

$ prolog-ninja explain ml_training

Reasoning Explanation: ML_TRAINING
==================================================

1. System Facts (detected from your system):
----------------------------------------
   cpu_cores(16)
   ram_total_gb(32.0)
   gpu_vendor(nvidia)
   gpu_vram_gb(10.0)
   has_dedicated_gpu(True)
   ...

2. Suitability Query: suitable_for(ml_training, Rating)?
----------------------------------------
    Rating = excellent

3. Optimization Query: optimize(ml_training, Setting, Value)?
----------------------------------------
    set_power_mode = high_performance
    set_cuda_visible_devices = 0
    set_process_priority = high

4. Warning Query: warning(ml_training, Type, Message)?
----------------------------------------
    No warnings

Python API

from system_sage import (
    detect_system, get_system_facts,
    PrologEngine, Fact, Rule,
    optimize_for, list_tasks, get_recommendations
)

# Detect your system
system = detect_system()
print(f"CPU: {system['cpu']['cores']} cores")
print(f"GPU: {system['gpu']['vendor']} {system['gpu']['model']}")

# Get recommendations
recs = get_recommendations("gaming")
print(f"Suitability: {recs['suitability']}")
for opt in recs['optimizations']:
    print(f"  - {opt['description']}")

# Use the Prolog engine directly
engine = PrologEngine()
engine.add_fact("likes", "alice", "python")
engine.add_fact("likes", "bob", "prolog")

# Query
from system_sage.reasoner import var, fact
X = var("X")
for solution in engine.query(fact("likes", X, "python")):
    print(f"Who likes Python? {solution['X']}")

The Prolog Engine

prolog-ninja includes a lightweight Prolog-style reasoning engine with:

  • Unification - Pattern matching with variables
  • Backtracking - Find all solutions via Python generators
  • Rules - Define complex relationships
  • Built-in predicates - >=, <=, >, <, ==, !=, member, not
from system_sage.reasoner import PrologEngine, var, fact, rule

engine = PrologEngine()

# Add facts
engine.add_fact("parent", "tom", "bob")
engine.add_fact("parent", "tom", "liz")
engine.add_fact("parent", "bob", "ann")

# Add rules
X, Y, Z = var("X"), var("Y"), var("Z")
engine.add_rule(
    fact("grandparent", X, Z),
    fact("parent", X, Y),
    fact("parent", Y, Z)
)

# Query
for sol in engine.query(fact("grandparent", "tom", var("Who"))):
    print(f"Tom is grandparent of: {sol['Who']}")
# Output: Tom is grandparent of: ann

Support

If you find this project useful, consider supporting its development:

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prolog_ninja-1.0.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prolog_ninja-1.0.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file prolog_ninja-1.0.0.tar.gz.

File metadata

  • Download URL: prolog_ninja-1.0.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for prolog_ninja-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0b05e5ffa3203aad222d1fcbb4c3c118d14249489a9c35a52a97757dfc3751fe
MD5 8c448ab2f78dd4fb98314bbf4a2c6f8d
BLAKE2b-256 a4752860aa8bea8c7f7eafae868e4cacd5d7a3d281d8d865284f4dd213f3b5a0

See more details on using hashes here.

File details

Details for the file prolog_ninja-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: prolog_ninja-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for prolog_ninja-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5340391ceb248d7f89ce623f3c334464abb96f942b6fdbaf744ec2373b6e8627
MD5 1fa8b2c25bea77c7691ebb554f17c958
BLAKE2b-256 cd2166b471ad5dc3955880bf85fd7448f0f0f87f2930eae61d71873addaab796

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page