Skip to content

Commit

Permalink
fixed for CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
Vipul-Cariappa committed Oct 22, 2023
1 parent cfc9de2 commit 7afb508
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
22 changes: 15 additions & 7 deletions logic/proof.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
from typing import Sequence, Generator, Iterator, TypeAlias
from .proposition import *
from typing import Sequence, Generator, Iterator, TypeAlias, Any
from .proposition import (
Statement,
CompositePropositionAND,
CompositePropositionNOT,
CompositePropositionOR,
CompositePropositionBICONDITIONAL,
CompositePropositionCONDITIONAL,
)

from enum import Enum

AssumptionT: TypeAlias = "Assumption"
ProofT: TypeAlias = "Proof"


class RulesOfInference(Enum):
Expand All @@ -21,7 +29,7 @@ class RulesOfInference(Enum):


class Assumption:
def __init__(self, assumptions: Sequence[Statement] | Self) -> None:
def __init__(self, assumptions: Sequence[Statement] | AssumptionT) -> None:
if isinstance(assumptions, Assumption):
self.assumptions: set[Statement] = set(assumptions.assumptions)
else:
Expand All @@ -31,10 +39,10 @@ def __contains__(self, key: Any) -> bool:
return key in self.assumptions

def with_proposition(self, prop: Statement) -> Generator[Statement, None, None]:
l = prop.extract()
individual_propositions = prop.extract()
for i in self.assumptions:
yielded = False
for j in l:
for j in individual_propositions:
if j in i and not yielded:
yielded = True
yield i
Expand All @@ -56,7 +64,7 @@ def __init__(self) -> None:
def add(self, roi: RulesOfInference, *statement: Statement) -> None:
self.proof.append((roi, (*statement,)))

def extend(self, proof: Self) -> None:
def extend(self, proof: ProofT) -> None:
self.proof.extend(proof.proof)

def __iter__(self) -> Iterator[tuple[RulesOfInference, tuple[Statement, ...]]]:
Expand Down Expand Up @@ -244,7 +252,7 @@ def prove(self) -> tuple[Proof, bool]:
self.proof.add(RulesOfInference.Resolution, i)
self.proof.extend(proof)
return self.proof, True

# Applying Disjunctive Syllogism
if self.conclusion == first:
proof, truth = Prover(self.assumptions.remove(i), ~second).prove()
Expand Down
12 changes: 6 additions & 6 deletions logic/proposition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Self, Any, TypeAlias
from typing import Any, TypeAlias
from copy import copy
from abc import ABC, abstractmethod
from warnings import warn
Expand Down Expand Up @@ -27,27 +27,27 @@ def extract(self) -> list[PropositionT]:
def __contains__(self, key: Any) -> bool:
pass

def __and__(self, other: Any) -> CompositePropositionT:
def __and__(self, other: Any) -> StatementT:
if not isinstance(other, Statement):
raise TypeError(f"Cannot perform logical and of {type(self)} with {type(other)}")
return CompositePropositionAND(self, other)

def __or__(self, other: Any) -> CompositePropositionT:
def __or__(self, other: Any) -> StatementT:
if not isinstance(other, Statement):
raise TypeError(f"Cannot perform logical or of {type(self)} with {type(other)}")
return CompositePropositionOR(self, other)

def __invert__(self) -> CompositePropositionT:
def __invert__(self) -> StatementT:
if isinstance(self, CompositePropositionNOT):
return copy(self.statement)
return CompositePropositionNOT(self)

def __truediv__(self, other: Any) -> CompositePropositionT:
def __truediv__(self, other: Any) -> StatementT:
if not isinstance(other, Statement):
raise TypeError(f"Cannot perform logical imply of {type(self)} with {type(other)}")
return CompositePropositionCONDITIONAL(self, other)

def __mod__(self, other: Any) -> CompositePropositionT:
def __mod__(self, other: Any) -> StatementT:
if not isinstance(other, Statement):
raise TypeError(f"Cannot perform logical bi-conditional of {type(self)} with {type(other)}")
return CompositePropositionBICONDITIONAL(self, other)
Expand Down

0 comments on commit 7afb508

Please sign in to comment.