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

input