From 985de5f735cdb473019c3e903137ce0ad023cb3c Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Mon, 23 Oct 2023 11:21:56 +0530 Subject: [PATCH] removed copy because all are immutable objects and ~(~x) simplification at construction step --- logic/proposition.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/logic/proposition.py b/logic/proposition.py index c83364e..16e9e4f 100644 --- a/logic/proposition.py +++ b/logic/proposition.py @@ -1,5 +1,4 @@ from typing import Any, TypeAlias -from copy import copy from abc import ABC, abstractmethod from warnings import warn from dataclasses import dataclass @@ -38,8 +37,6 @@ def __or__(self, other: Any) -> StatementT: return CompositePropositionOR(self, other) def __invert__(self) -> StatementT: - if isinstance(self, CompositePropositionNOT): - return copy(self.statement) return CompositePropositionNOT(self) @@ -49,10 +46,10 @@ class Proposition(Statement): statement: str = "" def remove_conditionals(self) -> StatementT: - return copy(self) + return self def simplify(self) -> StatementT: - return copy(self) + return self def extract(self) -> list[PropositionT]: return [self] @@ -83,7 +80,7 @@ def __eq__(self, other: Any) -> bool: class CompositeProposition(Statement): def simplify(self) -> StatementT: warn("Not Implemented") - return copy(self) + return self @dataclass(frozen=True)