My knowledge base consists of the following instances:
"Max", "Adam", "Mark", "Homer", "brother", "mother", "father"
and the two predicates:
isTypeOf(x,y), isFriendOf(x,y).
Now, I want to iterate over all instances of my knowledge and "put them" for the variables x,y,z into the following formula:
isTypeOf(x,y) And isFriendOf(x,z)
so that are all possible combinations of the knowledge base evaluated.
Can I say that every combination with the instances of my knowledge base for x,y, and z is an assignment and the interpretation is the evaluation of this formula for a specific assignment that is either true or false. Right? Is assignment the right word?
Can I express this state of affairs as follows:
$(\forall x,y,z \text{ isTypeOf(x,y)} \land \text{ isFriendOf(x,z)})$
or does this mean it is correct for all x,y, and z of my knowledge base?
Finally, please let me outline that I am using fuzzy logic and I get a value between 0 and 1 for any assignment of the variables that express the truthness of the formula. I am using fuzzy logic to evaluate the formula for all combinations and consider any that is over my defined threshold of >0.9 as true and store them as facts. So what is the best way to express this by using logical and computer scientist terms and mathematical symbols?
Thanks in advance
First of all, let's split the knowledge base of instances into two groups:
$People=\{Max, Adam, Mark, Homer\}$
$Types=\{brother, mother, father\}$
I'm assuming that what you are looking for is how many times, the proposition $(\text{ isTypeOf(x,y)} \land \text{ isFriendOf(x,z)})$, is true, where all x and z take values from the set of People, and y take values from the set of types, i.e. there are $4\cdot4\cdot3=48$ combinations in total. If more than 90% of the instances of the proposition are true, then our newly-defined function f will return true, otherwise it will return false. Hopefully I have understood the question correctly.
As a computer scientist, you probably already know how to build the function f in a programming language so that it returns the desired results; however you are not quite sure how to build such a function in terms of mathematical logic/symbols.
First of all, let's consider what kinds of function we CAN "translate" from a programming language to a "mathematical language". The most basic example would be a plain function like the following (I will be using JavaScript):
In a mathematical language, the above function can be defined with the first-order statement $\forall x(f(x)=x+5)$. In short, whenever a "programming" function returns value, we can translate this in mathematical language as well.
Let's consider a more complicated function:
In mathematical language, the same function can be built as follows:
$\forall x((x<5 \implies f(x)=x+5)\land(\neg (x<5) \implies f(x)=x+10))$
A little more simplified: $\forall x((x<5 \implies f(x)=x+5)\land(x\geq5 \implies f(x)=x+10))$
In this same way, we can "translate" all if-else statements in mathematical language.
Another thing that can always be translated in mathematical language are recursive functions:
In mathematical language:
$\forall x((x>0 \implies f(x)=f(x-1)+5)\land(x=0 \implies f(x)=2))$
A more simplified version would be:
$\forall x(x>0 \implies f(x)=f(x-1)+5)\land f(0)=2$
In conclusion, for every function, we can translate return statements, if-else statements, and recursions in mathematical lannguage. We can NOT translate loops and declaration of variables and changing of their values (except for the function parameters and arguments). Both of the above can be avoided by using a recursive function to replace the loops and to declare parameters instead instead of normal variables.
The only thing that I have difficulty expressing in mathematical language is "looping" through a set in the same way that we loop through an array in programming. The reason for this is because unlike arrays, sets are unordered. Because of this, before I start building the function I will fix a random order on the sets of People and Types, so that e.g. People[0] returns Max, People[1] returns Adam, and so on. Though it is only a matter of notations at this point, I am not sure how to be more formal about the above step. I will also declare a function n (this already exists in mathematics) that returns the length of a set, e.g. $n_{People}=4$, or rather, $People.length=4$.
Consider the following function f, and convince yourself that it works. There are much, much easier and simpler ways to write a function that does the same thing (by being able to edit the parameter/argument values WITHOUT having to return the function at the same time), but those functions would unfortunately be impossible to translate into mathematical language.
All we used was return statements, if-else statements, and recursion. As such, the above function can certainly be translated into mathematical language. The following statements are true for all x, y, z, trueInstances and totalInstances:
$proposition(x,y,z)=isTypeOf(x,y)\land isFriendOf(x,z)$
$z<People.length-1 \land proposition(People[x], Types[y], People[z])\implies f(x,y,z,trueInstances,totalInstances)=f(x,y,z+1,trueInstances+1,totalInstances+1)$
$z<People.length-1 \land \neg proposition(People[x], Types[y], People[z])\implies f(x,y,z,trueInstances,totalInstances)=f(x,y,z+1,trueInstances,totalInstances+1)$
$z\geq People.length-1 \land y<Types.length-1 \land proposition(People[x], Types[y], People[z])\implies f(x,y,z,trueInstances,totalInstances)=f(x,y+1,0,trueInstances+1,totalInstances+1)$
$z\geq People.length-1 \land y<Types.length-1 \land \neg proposition(People[x], Types[y], People[z])\implies f(x,y,z,trueInstances,totalInstances)=f(x,y+1,0,trueInstances,totalInstances+1)$
$x<People.length-1 \land z\geq People.length-1 \land y\geq Types.length-1 \land proposition(People[x], Types[y], People[z])\implies f(x,y,z,trueInstances,totalInstances)=f(x+1,0,0,trueInstances+1,totalInstances+1)$
$x<People.length-1 \land z\geq People.length-1 \land y\geq Types.length-1 \land \neg proposition(People[x], Types[y], People[z])\implies f(x,y,z,trueInstances,totalInstances)=f(x+1,0,0,trueInstances,totalInstances+1)$
$x\geq People.length-1 \land z\geq People.length-1 \land y\geq Types.length-1 \land trueInstances/totalInstances>0.9 \implies f(x,y,z,trueInstances,totalInstances)=true$
$x\geq People.length-1 \land z\geq People.length-1 \land y\geq Types.length-1 \land trueInstances/totalInstances\leq 0.9 \implies f(x,y,z,trueInstances,totalInstances)=false$
There is a reason why such function are usually studied in computer science rather than mathematics, and the above monstrosity is one of them. Hopefully I haven't made too many typos, and I hope I was able to help!
Edit: Answering the comment from OP, yes, when making the first example I was assuming that the universe of discourse was the set of real numbers (or integers for that matter). That is, the parameter must always be a number for the return value to make sense. I wouldn't necessarily call it a mistake to say that the function takes a certain value "for all x", because the mistake doesn't lie in the "translation" of the function from programming to mathematics, rather the function already did not make sense for all possible arguments in its programming form (because we are already assuming that the argument is a number, otherwise "x+5" will probably fail to compile in the first place). However, if you already have a "universe" in mind when declaring the function, and are uncertain about how to include this universe in the "mathematical" form of the function, you can always do it in the following way:
$\forall x\in\mathbb{Z}(f(x)=x+5)$.
In the above we are EXPLICITLY specifying that for the following statement to be true, x must be an integer.