Skip to content

Commit

Permalink
adding print error statemetns
Browse files Browse the repository at this point in the history
  • Loading branch information
ahu96 committed Apr 19, 2022
1 parent 2a00f17 commit 7f86563
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,16 @@ def rightMult (self, elem, lineNum):
self.show()

##power methods
def breakPower(self,power):
def breakPower(self,input):
"""
Given an expression like e^a where a is a python integer, return a mult object equivalent to e^a
:param power: the power to be converted to mult
"""
exp=power.exponent
element = power.element
"""
if isinstance(input,power) == False:
print (f"Expected a power object but received type {type(input)}")
return
exp=input.exponent
element = input.element
multList=[]
for i in range(exp):
multList.append(element)
Expand All @@ -287,6 +290,9 @@ def combinePower(self, mult):
Given a mult object with a single element, convert it to a power object (for example turning e*e*e to e^3)
:param mult: the mult object to be converted
"""
if isinstance(mult,Mult) == False:
print (f"Expected a Mult object but received type {type(mult)}")
return
multList=mult.elemList
e=multList[0]
for i in multList:
Expand All @@ -298,13 +304,16 @@ def combinePower(self, mult):
self.justifications += ['Convert multiplications to equivalent powers']
self.show()

def splitPowerAddition(self,power):
def splitPowerAddition(self,input):
"""
Simplify power objects: Given an expression e^a+b, convert to e^a*e^b. Given an expression e^a*b=(e^a)^b
:param power: the power object with addition in exponent to be modified
"""
element = self.element
exp=self.exponent
if isinstance(input, power) == False:
print (f"Expected a power object but received type {type(input)}")
return
element = input.element
exp=input.exponent
l=exp.split("+")
if len(l)==1:
print ("No power addition to be split apart")
Expand All @@ -318,13 +327,16 @@ def splitPowerAddition(self,power):
self.show()


def splitPowerMult(self,power):
def splitPowerMult(self,input):
"""
Simplify power objects: Given an expression e^a*b=(e^a)^b
:param lineNum: the power object with mult in exponent to be modified
"""
element = self.element
exp=self.exponent
"""
if isinstance(input, power) == False:
print (f"Expected a power object but received type {type(input)}")
return
element = input.element
exp=input.exponent
l=exp.split("*")
if len(l)==1:
print ("No power multiplication to be split apart")
Expand Down Expand Up @@ -396,6 +408,9 @@ def identleft(self, lineNum):
return
newProduct = Mult(l1)
ret = Eq(newProduct,evidence.RHS,evidence.parentgroup)
else:
print(f"Expected an equation on line {lineNum} but received {type(evidence)}")
return

self.steps += [ret]
self.justifications += ["identity elimination "]
Expand Down Expand Up @@ -427,6 +442,9 @@ def identright(self, lineNum):
return
newProduct = Mult(l1)
ret = Eq(evidence.LHS,newProduct,evidence.parentgroup)
else:
print(f"Expected an equation on line {lineNum} but received {type(evidence)}")
return

self.steps += [ret]
self.justifications += ["identity elimination "]
Expand Down

0 comments on commit 7f86563

Please sign in to comment.