Skip to main content

A Python package for automated mathematical conjecturing.

Project description

GraffitiAI

GraffitiAI is a Python package for automated mathematical conjecturing, inspired by the legacy of GRAFFITI. It provides tools for exploring relationships between mathematical invariants and properties, with a focus on graph theory and polytopes. This package supports generating conjectures, applying heuristics, and visualizing results.

Features

  • Load and preprocess datasets with ease.
  • Identify possible invariants and hypotheses for conjecturing.
  • Generate upper and lower bounds for a target invariant.
  • Apply customizable heuristics to refine conjectures.
  • Export results to PDF for presentation and sharing.
  • Includes a sample dataset of 3-regular polytopes for experimentation.

Installation

To install GraffitiAI, use pip:

# Install GraffitiAI with pip
pip install graffitiai

Quick Start

Here's a simple example to get you started:

TxGraffitiAI

from graffitiai import GraffitiAI

# Point towards the URL hosted on Jillian's GitHub
url = 'https://raw.githubusercontent.com/jeddyhub/Polytope_Database/refs/heads/main/Simple_Polytope_Data/simple_polytope_properties.csv'

# Create an instance of the GraffitiAI class
ai = GraffitiAI()

# Read the data from the URL
ai.read_csv(url)

# Vectorize the p-vector column
ai.vectorize(['p_vector'])

# Define small face counts
ai.knowledge_table["p_3"] = ai.knowledge_table["p_vector"].apply(lambda x: x[0] if len(x) > 2 else 0)
ai.knowledge_table["p_4"] = ai.knowledge_table["p_vector"].apply(lambda x: x[1] if len(x) > 2 else 0)
ai.knowledge_table["p_5"] = ai.knowledge_table["p_vector"].apply(lambda x: x[2] if len(x) > 2 else 0)
ai.knowledge_table["p_6"] = ai.knowledge_table["p_vector"].apply(lambda x: x[3] if len(x) > 3 else 0)
ai.knowledge_table["p_7"] = ai.knowledge_table["p_vector"].apply(lambda x: x[4] if len(x) > 4 else 0)
ai.knowledge_table['sum(p_vector)'] = ai.knowledge_table['p_vector'].apply(sum)
ai.knowledge_table['sum(p_vector not p_6)'] = ai.knowledge_table['p_vector'].apply(lambda x: sum([i for i in x if i != 6]))
ai.knowledge_table['sum(p_vector) with p >= 7'] = ai.knowledge_table['p_vector'].apply(lambda x: sum([i for i in x if i >= 7]))

ai.update_invariant_knowledge()

# Optionally add statistics on the vector valued column
ai.add_statistics(['p_vector'])

# Drop the columns that are not needed
ai.drop_columns([
    'edgelist',
    'adjacency_matrix',
    'p_vector',
])

# Optionally increase the complexity of the types of conjectures applied
ai.set_complexity( max_complexity=1)

# Generate conjectures on a list of target properties (invariants)
ai.conjecture(
    target_invariants=[
        'sum(p_vector)',
        'p_6',
    ],
    hypothesis=[
      'simple_polytope_graph',
      'simple_polytope_graph_with_p6_greater_than_zero',
   ],
   other_invariants=[
        'p_3',
        'p_4',
        'p_5',
        'p_7',
        'order',
        'size',
        'sum(p_vector)',
        'size',
        'sum(p_vector)',
        'p_6',
        'median_absolute_deviation(p_vector)',
        'max(p_vector)',
        'independence_number',

   ],
    complexity_range=(1, 3),
    lower_b_max=2,
    lower_b_min=-2,
    upper_b_max=3,
    upper_b_min=-3,
    W_lower_bound=None,
    W_upper_bound=None,
    min_touch=1,
)

ai.write_on_the_wall(search=True)

Christine

from graffitiai import Christine

# Initialize Christine
ai =Christine()

# Read in data
ai.read_csv("https://raw.githubusercontent.com/RandyRDavila/GraffitiAI/refs/heads/main/graffitiai/data/data_437.csv")

# Drop unwanted columns
ai.drop_columns([
    "adjacency_matrix",
    "edge_list",
    "number_of_spanning_trees",
    'maximum_degree',
    'minimum_degree',
    'average_degree',
    'number_of_triangles',
    'vertex_connectivity',
    'edge_connectivity',
    'is_simple',
    'clique_number',
])
ai.drop_columns([
    f'number_of_{p}_gons' for p in range(12, 126)
])

# Conjecture on a target invariant with a time limit set to 5 minutes
ai.conjecture('number_of_6_gons', bound_type='lower', time_limit_minutes=5)

# Write conjectures to the wall.
ai.write_on_the_wall()

Contributing

Contributions are welcome! If you have suggestions, find bugs, or want to add features, feel free to create an issue or submit a pull request.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments

GraffitiAI is inspired by the pioneering work of GRAFFITI and built using the ideas of TxGraffiti and the Optimist.

Author

Randy R. Davila, PhD

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

graffitiai-0.1.17.tar.gz (569.1 kB view details)

Uploaded Source

Built Distribution

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

graffitiai-0.1.17-py3-none-any.whl (678.1 kB view details)

Uploaded Python 3

File details

Details for the file graffitiai-0.1.17.tar.gz.

File metadata

  • Download URL: graffitiai-0.1.17.tar.gz
  • Upload date:
  • Size: 569.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for graffitiai-0.1.17.tar.gz
Algorithm Hash digest
SHA256 9eef552af5c47ea7cdf0282a4ede3654d1ba82e57e93fa428836d57b7f7eed57
MD5 38564d761874278958cc66bece2badc8
BLAKE2b-256 2f11c1613e4bfe47ae2da388d34c25f85ec4146b12d0335da87f23f4ae005fca

See more details on using hashes here.

File details

Details for the file graffitiai-0.1.17-py3-none-any.whl.

File metadata

  • Download URL: graffitiai-0.1.17-py3-none-any.whl
  • Upload date:
  • Size: 678.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for graffitiai-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 39b415c2db64034de2f1208d1757f3ad7903b7cf771a4e23bbbfc47ea69a80c1
MD5 63c7a89f76e77638c3abbd741c200c45
BLAKE2b-256 5b98dc056a66113620aa63fa7722f4bb89b11e157a4378e92fc43a2766b0c237

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