## FANDOM

21 Pages

This is what I attempted to do later in the semester after I found that there is a definite patern in the way that the rules of inference are applied. Unfortunately, I just did not have enough time to put this into the main program, but I do feel that it deserves some explanation here. First, let's look at to simple rules of inference and how these are related to each other. Modus ponens states that $(p\land (p\rightarrow q))\rightarrow q \Leftrightarrow T$ and hypothetical syllogism states that $((p\rightarrow q)\land(q\rightarrow r))\rightarrow(p\rightarrow r)\Leftrightarrow T$. Now, without thinking about the logic behind these statements and just thinking about how each of these acts like a mold we can create a single method that can check both of these rules of inference. This method is found here and the main project can be found here.

## Intoduction to the generalized method

Look at the first line of the method

def confirm(forms, rule):


This method takes two arguments and will return a boolean (python is not a statically typed language and so the return type is not declared here). The first argument is a tuple of the formulas that are being checked for validity based on the inference rule named rule. The first step is to make sure that the first part of the rule of inference matches the first part of the formulas being checked.

    wtup = rule[0]
maintup = rule[1]
if len(forms) != len(wtup):
return False


This part of the method first takes the wff's of the rule of inference and puts them into a tuple named wtup. Then it takes the main operators of the rule of inference and puts them into a tuple named maintup. Finally, it returns false if the number of wffs in forms is not equal to the number of wffs in wtup.

    dict1 = {}


This dictionary will be used to check to make sure that whatever symbols are used in the wtup match up with the ones that are used in forms.

    for index,form in enumerate(forms):


This will take each form in forms and the index of forms.