CNF Converter/CNFConverter.py
def inner_demorgan(input):
	""" Function to move not inwards in the inner clauses """
	for i in range(len(input)):		
		if is_symbol(input):		# check if its a symbol then return as it is
			return input
		elif input[i][0] in [AND,OR]:		# append the clauses to the output if the connective is AND or OR
			return recursive_call(input,3)
		elif input[i][0] == NOT  and input[i][1][0] in [AND,OR]:	
				output = []						# input - ["and" ,["not",["or","A","B"]],"A" ] then convert it to ["and", ["and",["not","A"],["not","B"]],"A" 
				if(input[i][1][0] == AND):	
					output.append(OR)
				elif(input[i][1][0] == OR):
					output.append(AND)
				for j in range(1,len(input[i][1])):
					output.append(inner_demorgan([NOT,input[i][1][j]]))
				return output
		else:
			return input
 Function to move not inwards in the inner clauses 
Function to move not inwards in the inner clauses
Function to move not inwards in the inner clauses
def inner_demorgan(input):
	for i in range(len(input)):		
		if is_symbol(input):		
			return input
		elif input[i][0] in [AND,OR]:		
			return recursive_call(input,3)
		elif input[i][0] == NOT  and input[i][1][0] in [AND,OR]:	
				output = []						
				if(input[i][1][0] == AND):	
					output.append(OR)
				elif(input[i][1][0] == OR):
					output.append(AND)
				for j in range(1,len(input[i][1])):
					output.append(inner_demorgan([NOT,input[i][1][j]]))
				return output
		else:
			return input
def inner_demorgan ( input ) : for i in range ( len ( input ) ) : if is_symbol ( input ) : return input elif input [ i ] [ 0 ] in [ AND , OR ] : return recursive_call ( input , 3 ) elif input [ i ] [ 0 ] == NOT and input [ i ] [ 1 ] [ 0 ] in [ AND , OR ] : output = [ ] if ( input [ i ] [ 1 ] [ 0 ] == AND ) : output . append ( OR ) elif ( input [ i ] [ 1 ] [ 0 ] == OR ) : output . append ( AND ) for j in range ( 1 , len ( input [ i ] [ 1 ] ) ) : output . append ( inner_demorgan ( [ NOT , input [ i ] [ 1 ] [ j ] ] ) ) return output else : return input
Function to move not inwards in the inner clauses
Function to move not inwards in the inner clauses
""" Function to move not inwards in the inner clauses """ # check if its a symbol then return as it is
 # append the clauses to the output if the connective is AND or OR
 # input - ["and" ,["not",["or","A","B"]],"A" ] then convert it to ["and", ["and",["not","A"],["not","B"]],"A" 

input