proc fuzzyAnd {x y} {expr {$x*$y}} proc fuzzyNot {x} {expr {1.-$x}} proc fuzzyNAND {x y} {expr {1.-$x*$y}} proc fuzzyTrue {} {expr {1.}} proc fuzzyFalse {} {expr {0.}} proc fuzzyOr {x y} {fuzzyNot [fuzzyAnd [fuzzyNot $x] [fuzzyNot $y]]} proc fuzzyXor {x y} { fuzzyOr [fuzzyAnd $x [fuzzyNot $y]] [fuzzyAnd [fuzzyNot $x] $y] } proc fuzzyEq {x y} {fuzzyNot [fuzzyXor $x $y]}

TV Maybe you want to bound the range of the functions symmetrically by soft limiting them between [-1,1] using:

set PId2 [expr acos(-1)] proc clampto1 x {global PId2; return [expr atan($x*$PId2)/$PId2]}Not distributive, the result would be, but fun.DKF: What on earth are you talking about? Fuzzy Logic works with (what can be thought of as) probabilities. The domain of each of the input values is [0,1], and given that, the range of the functions is [0,1] as well. Clamping is unnecessary.TV Sorry, I must have had my mind elsewhere, you are completely right that given the definition clamping is out of order.It's sort of electronics-like thinking, where signals are never guaranteed to be exactly bounded.Let's see if I follow the fuzzy logic reasoning, that has interested me long ago as a student, when I thought it was about general 'fuzzy' logic, not necessarily a certain interpretation of the concept.Assuming probabilities, we'd have that the probability of A and B is A*B, let's say P(a) = 0.5 and P(b) = 0.5, the combined probability is 0.25. Sort of OK, but it means we must assume for correct statistics to ripple through the logic that events, and the variables describing them are

*independent*.Related parts of a formula usually are not, for instance the

*probability*of fuzzyAnd(A,A)= pow(A,2) ...One could take geometric average instead, to make this better, but dealing with the whole subject right would take you into very interesting (basic but nontrivial) quantum physics integrals for doing these things, I guess.DKF: AIUI, fuzzy logic is known to be significantly flawed, but in an interesting and often practically useful way. (There are other ways of constructing FL systems.) IIRC, FL is often used in consumer electronics where it is easier to give FL to software engineers than train them to use probability properly, and given that the inputs are continuous (OK floating point) values anyway, this isn't too serious. wdb Significantly flawed? How and why?

AM See also: Rough setsAM (30 june 2006) Here are the beginnings of an Application of Fuzzy Logic.