Metadata-Version: 2.4
Name: pnwratproject
Version: 0.1.7
Summary: A Python Package for evaluating relative propositional functions, logical relations, and equivalence with advanced mathematical tools.
Project-URL: Homepage, https://github.com/username/pnwratproject
Project-URL: Documentation, https://github.com/username/pnwratproject#readme
Project-URL: Repository, https://github.com/username/pnwratproject.git
Project-URL: Bug Tracker, https://github.com/username/pnwratproject/issues
Author-email: Nawarat <nawarat.ch@mail.wu.ac.th>
License: MIT
License-File: LICENSE
Keywords: functional relations,logic,logical equivalence,mathematical logic,propositional logic,relative functions
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Requires-Dist: gmpy2
Requires-Dist: matplotlib
Requires-Dist: networkx
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: plotly
Requires-Dist: pyvista
Requires-Dist: scipy
Requires-Dist: seaborn
Requires-Dist: sympy
Description-Content-Type: text/markdown

### pnwratproject

ตัวอย่าง Python Package ด้านตรรกศาสตร์และคณิตศาสตร์ดิสครีต ที่พัฒนาด้วยมาตรฐาน **PEP 517** และ **PEP 621**

---

## Description

แพ็คเกจนี้พัฒนาขึ้นเพื่อใช้ในการคำนวณ ตรวจสอบ และวิเคราะห์โครงสร้างทางตรรกศาสตร์และคณิตศาสตร์ดิสครีตเชิงลึก รองรับการประมวลผลเชิงวัตถุ (OOP), การสืบทอดคุณสมบัติ (Inheritance 5 รูปแบบ), การประมวลผลแบบ Recursion & Memoization, การส่งออกข้อมูล (File I/O) และการแสดงผลข้อมูลด้วยกราฟิก (Visualization) ประกอบด้วย 3 โมดูลหลัก:

* **`propositional`** : คำนวณค่าความจริงของตัวเชื่อมประพจน์พื้นฐาน (NOT, AND, OR, IMPLIES, IFF), การประมวลผลและลดรูปนิพจน์ประพจน์ด้วย SymPy, การประมวลผลประพจน์หลายตัวแปรด้วย Variable-length Args (`*args`, `**kwargs`), การคำนวณตารางความจริงแบบ Recursion และ Pandas DataFrame, การเปรียบเทียบประสิทธิภาพ 2 อัลกอริทึม (Algorithm Comparison) และการสร้าง Syntax Tree Diagram ด้วย NetworkX
* **`equivalence`** : ตรวจสอบการสมมูล สัจนิรันดร์ ข้อขัดแย้ง กฎ De Morgan, ระบบตรวจสอดคล้องความสัมพันธ์มูลเทียบ (Equivalence Relation), การแบ่งชั้นความสมมูล (Equivalence Classes), การคำนวณความแม่นยำสูงด้วย GMPY2 และการส่งออกรายงาน JSON และการจำลองภาพ 3 มิติด้วย PyVista
* **`rela_functions`** : ตรวจสอบคุณสมบัติของความสัมพันธ์ (Reflexive, Symmetric, Transitive) และฟังก์ชัน (Function, 1-to-1), ระบบวิเคราะห์เมทริกซ์ความสัมพันธ์ (Adjacency Matrix/Sparse Matrix), การนับจำนวนความสัมพันธ์ด้วย Memoization และการสร้าง Heatmap/Interactive Chart ด้วย Seaborn & Plotly
---

### การติดตั้ง (Installation)

## You can install the package directly from PyPI:
```bash
pip install pnwratproject
```


### ตัวอย่างการใช้งาน

```python
import myproject as pkg

# ==========================================
# 1. โมดูล propositional (ประพจน์และตรรกศาสตร์)
# ==========================================
print("=== 1. Propositional Module ===")

# 1.1 ฟังก์ชันตัวเชื่อมประพจน์พื้นฐาน
print(f"NOT(True) -> {pkg.NOT(True)}")                       # Output: False
print(f"AND(True, False) -> {pkg.AND(True, False)}")         # Output: False
print(f"OR(True, False) -> {pkg.OR(True, False)}")           # Output: True
print(f"IMPLIES(True, False) -> {pkg.IMPLIES(True, False)}") # Output: False
print(f"IFF(True, True) -> {pkg.IFF(True, True)}")           # Output: True

# 1.2 OOP: Class Proposition
prop1 = pkg.Proposition("P AND Q")
prop2 = pkg.Proposition("P & Q")
print(f"Proposition string -> {prop1}")                      # Output: Proposition('P & Q')
print(f"Proposition length -> {len(prop1)}")                 # Output: 5
print(f"Is Equal (__eq__) -> {prop1 == prop2}")             # Output: True
print(f"Simplify Logic -> {prop1.simplify()}")               # Output: P & Q

# 1.3 OOP: Class EvaluatableProposition (Multilevel Inheritance)
eval_prop = pkg.EvaluatableProposition("P AND (Q OR NOT P)")
print(f"Evaluate {{P:True, Q:False}} -> {eval_prop.evaluate({'P': True, 'Q': False})}") # Output: False

# Export Truth Table เป็นไฟล์ JSON
eval_prop.export_truth_table_json("truth_table.json", variables=["P", "Q"])

# Pandas Integration: สร้างตารางค่าความจริงเป็น DataFrame
df_truth = eval_prop.generate_truth_table_dataframe(variables=["P", "Q"])
print(f"\nTruth Table DataFrame:\n{df_truth}")

# 1.4 Variable-length Args (*args, **kwargs)
p1 = pkg.EvaluatableProposition("P AND Q")
p2 = pkg.EvaluatableProposition("P OR NOT Q")
multi_eval = pkg.combine_and_evaluate_propositions(p1, p2, P=True, Q=False, verbose=False)
print(f"\nMultiple Propositions Eval (*args, **kwargs) -> {multi_eval}")

# 1.5 Recursive Function
print(f"Truth Table Rows (3 Vars) -> {pkg.count_truth_rows_rec(3)}") # Output: 8

# 1.6 Algorithm Comparison (เปรียบเทียบประสิทธิภาพ 2 อัลกอริทึม)
comp_res = pkg.compare_truth_table_algorithms(n_vars=12)
print(f"Faster Algorithm Result -> {comp_res['faster_algorithm']}")

# 1.7 Visualization Diagram
pkg.plot_proposition_syntax_tree("P AND Q")


# ============================================
# 2. โมดูล equivalence (การสมมูลและความสมมูลเทียบ)
# ============================================
print("\n=== 2. Equivalence Module ===")

# 2.1 ฟังก์ชันตรวจสอบพื้นฐานและ De Morgan
res1 = [True, False, True]
res2 = [True, False, True]
print(f"Is Equivalent -> {pkg.is_equivalent(res1, res2)}")   # Output: True
print(f"Is Tautology -> {pkg.is_tautology([True, True])}")   # Output: True
print(f"Is Contradiction -> {pkg.is_contradiction([False, False])}") # Output: True
print(f"De Morgan AND ~(True ∧ False) -> {pkg.de_morgan_and(True, False)}") # Output: True
print(f"De Morgan OR ~(True ∨ False) -> {pkg.de_morgan_or(True, False)}")   # Output: False

# 2.2 OOP: Class EquivalenceLogger & EquivalenceRelation (Multiple Inheritance)
domain_set = {1, 2, 3}
eq_pairs = [(1, 1), (2, 2), (3, 3), (1, 2), (2, 1)]
eq_rel = pkg.EquivalenceRelation(domain=domain_set, pairs=eq_pairs)

eq_rel.log_status("Testing Equivalence System...")
print(f"Is Reflexive -> {eq_rel.is_reflexive()}")            # Output: True
print(f"Is Symmetric -> {eq_rel.is_symmetric()}")            # Output: True
print(f"Is Transitive -> {eq_rel.is_transitive()}")          # Output: True
print(f"Is Equivalence Relation -> {eq_rel.is_equivalence()}") # Output: True
print(f"EquivalenceRelation Info -> {eq_rel}")               # Output: EquivalenceRelation(...)
print(f"Pairs Length -> {len(eq_rel)}")                     # Output: 5

# 2.3 OOP: Class PartitionedEquivalenceSystem (Multilevel Inheritance)
part_sys = pkg.PartitionedEquivalenceSystem(domain=domain_set, pairs=eq_pairs)
print(f"Equivalence Classes -> {part_sys.get_equivalence_classes()}") # Output: {1: {1, 2}, 2: {1, 2}, 3: {3}}
print(f"Max Partitions (GMPY2) -> {part_sys.compute_max_partitions_gmpy2()}") # Output: 512

# 2.4 File I/O
pkg.export_equivalence_report_json(part_sys, "equivalence_report.json")

# 2.5 3D Visualization
pkg.render_equivalence_partition_3d()


# ==================================================
# 3. โมดูล rela_functions (ความสัมพันธ์ ฟังก์ชัน & เมทริกซ์)
# ==================================================
print("\n=== 3. Relations & Functions Module ===")

# 3.1 ฟังก์ชันตรวจสอบความสัมพันธ์และฟังก์ชันพื้นฐาน
domain_list = [1, 2, 3]
relation_list = [(1, 1), (2, 2), (3, 3), (1, 2)]
func_list = [(1, 'a'), (2, 'b'), (3, 'c')]

print(f"Is Reflexive -> {pkg.is_reflexive(domain_list, relation_list)}") # Output: True
print(f"Is Symmetric -> {pkg.is_symmetric(relation_list)}")            # Output: False
print(f"Is Transitive -> {pkg.is_transitive(relation_list)}")          # Output: True
print(f"Is Function -> {pkg.is_function(domain_list, func_list)}")     # Output: True
print(f"Is One-to-One -> {pkg.is_one_to_one(domain_list, func_list)}") # Output: True

# 3.2 OOP: Class BaseRelation
base_rel = pkg.BaseRelation(domain_set, relation_list)
print(f"BaseRelation String -> {base_rel}")                  # Output: BaseRelation(...)
print(f"BaseRelation Length -> {len(base_rel)}")            # Output: 4

# 3.3 OOP: Class FunctionRelation (Hierarchical Inheritance 1)
func_rel = pkg.FunctionRelation(domain_set, func_list)
print(f"Check Is Function -> {func_rel.check_is_function()}")         # Output: True
print(f"Check Is 1-to-1 -> {func_rel.check_is_one_to_one()}")         # Output: True

# 3.4 OOP: Class MatrixRelation (Hierarchical Inheritance 2)
mat_rel = pkg.MatrixRelation(domain_set, relation_list)
print(f"NumPy Matrix ->\n{mat_rel.to_numpy_matrix()}")
print(f"SciPy Sparse Matrix ->\n{mat_rel.to_scipy_sparse()}")

# 3.5 OOP: Class AdvancedRelationSystem (Hybrid Inheritance) & PrintableMixin
adv_sys = pkg.AdvancedRelationSystem(domain_set, relation_list)
print(f"Summary Dict -> {adv_sys.get_summary_dict()}")      # Output: {'domain_elements': {1, 2, 3}, 'total_pairs': 4}

# 3.6 Memoization Recursive Function
print(f"Possible Relations (Memoization, n=3) -> {pkg.count_possible_relations_memo(3)}") # Output: 512

# 3.7 Visualizations
pkg.plot_matrix_heatmap(mat_rel)
pkg.plot_interactive_domain_plotly(domain_set)
```