Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maxine branch #3

Merged
merged 3 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file modified __pycache__/element.cpython-39.pyc
Binary file not shown.
Binary file modified __pycache__/group.cpython-39.pyc
Binary file not shown.
Binary file modified __pycache__/integer.cpython-39.pyc
Binary file not shown.
Binary file modified __pycache__/logicObjects.cpython-39.pyc
Binary file not shown.
Binary file modified __pycache__/proof.cpython-39.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions abelian_proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

G = group('G','*')
abelianG = forall(['x', 'y'], G, Eq(Mult(['x', 'y']), Mult(['y','x']),G))
p = Proof('Simple Abelian Proof', forall(['x'], G, Eq(Mult(['x', 'x']), G.elements['e'],G)), goal=abelianG)
p = Proof('Simple Abelian Proof', forall(['x'], G, Eq(Mult(['x', 'x']), Mult([G.elements['e']]),G)), goal=abelianG)
p.introGroup(G)
p.introElement(G,'a')
p.introElement(G,'b')
p.closure(G,'a','b')
p.accessAssumption()
p.forallElim(4,['a * b'])
p.accessAssumption() # this and below one
p.forallElim(4,['a * b']) # combine two steps
p.leftMult('a',5)
p.forallElim(4,['a'])
p.substituteRHS(6,7)
Expand Down
1 change: 1 addition & 0 deletions element.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def mult(self,other, group): # this is just for representation
elif binOp in self.elementName and ')' != self.elementName[-1]:
return "(" + self.elementName + ")" + binOp + other.elementName
else:

return self.elementName + binOp + other.elementName

def addToGroup(self, group):
Expand Down
10 changes: 5 additions & 5 deletions group.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
exec(compile(source=open('element.py').read(), filename='element.py', mode='exec'))
from logicObjects import identity, Mult, inverse

from logicObjects import identity, Mult
from element import *

class group:
# TRUTHS for all classes - need to add more here
Expand All @@ -15,7 +15,7 @@ class group:
def __init__(self, name, binOp, additionalGroupProperties = None):
self.groupName = name
self.binaryOperator = binOp
self.elements.update({self.identity_identifier:Mult([identity(self)])})
self.elements.update({self.identity_identifier:identity(self)})
if additionalGroupProperties != None:
self.groupProperties.update(additionalGroupProperties)

Expand All @@ -41,7 +41,7 @@ def newInverse(self, elementName):
# declare new element in group with elementName
def newElement(self,elementName):
if elementName not in self.elements:
self.elements.update({elementName:Mult([element(elementName,self)])})
self.elements.update({elementName:element(elementName,self)})
else:
print("Sorry, that element already exists!")

Expand All @@ -53,7 +53,7 @@ def mulElements(self, elem1, elem2): # should this return an equation?
try:
gelem1 = self.elements[elem1]
gelem2 = self.elements[elem2]
result = gelem1 * gelem2 # need to specify which group we are multiplying in
result = Mult([gelem1 ,gelem2]) # need to specify which group we are multiplying in
self.elements.update({repr(result):result}) # is this the right?
except:
print("Sorry, one or both of these elements are not in the group!")
Expand Down
26 changes: 26 additions & 0 deletions inverse_of_ab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from enum import unique
from telnetlib import GA
from proof import *
from element import *
from group import *
from integer import *
from logicObjects import *

G = group('G','*')
ab_inverse = forall(['a','b'], G, Eq(Mult([inverse('b',G),inverse('a',G)]),Mult([inverse(Mult(['a','b']),G)]),G))
p = Proof('Inverse of ab Proof', assumption = None, goal = ab_inverse)
p.introGroup(G)
p.introElement(G,'a')
p.introElement(G,'b')
p.closure(G,'a','b')
p.introInverse(G, Mult(['a','b']))
p.rightMultInverse('b',4)
p.inverseElimLHS(5)
p.identleft(6)
p.identright(7)
p.rightMultInverse('a',8)
p.inverseElimLHS(9)
p.identleft(10)
p.switchSidesOfEqual(11)
p.forAllIntroduction(12,["a","b"],[1,2])
p.qed(13)
34 changes: 27 additions & 7 deletions logicObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def replace(self, var, expr):
#print(self.products,var.products,expr.products)
while i < len(self.products):
if self.products[i:i+len(var.products)] == var.products:
new_products += expr.products
if isinstance(expr,Mult):
new_products += expr.products
else:
new_products.append(expr)
i+=len(var.products)
else:
new_products.append(self.products[i])
Expand Down Expand Up @@ -253,6 +256,11 @@ def __init__ (self, prpty, pg):

## Special types of elements/groups

# class element_(element):
# def __init__(self, pg, elementName):
# elementName = elementName
# super().__init__(elementName, pg)

class identity(element):
def __init__(self, pg):
elementName = pg.identity_identifier
Expand All @@ -264,12 +272,24 @@ def __init__(self, pg):
pg.addElementProperty(idnty,elementName)

class inverse(element):
def __init__(self, elementName, pg):
inverseName = '(' + elementName + ")^(-1)"
def __init__(self, object, pg):
if type(object) == str:
elementName = object
inverseName = elementName + "^(-1)"
# lhs = Mult([inverseName,pg.elements[object]])
else:
elementName = repr(object)
inverseName = "(" + elementName + ")" + "^(-1)"
# lhs = Mult([inverseName]+object.products)
super().__init__(inverseName, pg)
lhs = Mult([inverseName,elementName]) # self or elementName?
rhs = Mult([pg.identity_identifier])
inverseEq = Eq(lhs,rhs,pg)
pg.addGroupProperty(inverseEq, "Inverse of " + elementName)
self.inverseName = inverseName
self.elementName = elementName
def __repr__(self):
return self.inverseName
# self or elementName?
# rhs = Mult([pg.identity_identifier])
# inverseEq = Eq(lhs,rhs,pg)
# pg.addGroupProperty(inverseEq, "Inverse of " + elementName)


## TO DO: class generator(element):
Loading