[Haskell-beginners] Data structure for Propositional Logic formulas

Christian Maeder Christian.Maeder at dfki.de
Thu Oct 13 14:09:30 CEST 2011


Am 13.10.2011 13:24, schrieb Benedict Eastaugh:
> On 13 October 2011 10:12, Christian Maeder<Christian.Maeder at dfki.de>  wrote:
>
>> Why do most people like duplicate or repeated code?
>
> Hi Christian,
>
> I can't speak for most people, but I like my data types to encode the
> semantics of the domain. In this case, the connectives are logical
> devices that allow the formation of new well-formed formulae from old
> ones. I also think it's a mistake to consider them, in their guise as
> operators, to be any different from negation save in their arity. In
> my code they are on a par, and any extension to include new n-ary
> connectives would be straightforward and natural.
>
> (There are other unary and binary logical operators which happen not
> to be listed; I simply included the most commonly used ones, rather
> than add NAND, XOR, etc. As Daniel pointed out, merely including
> negation and disjunction allows the formation of a truth-functionally
> complete system. One can also do this with just NAND or NOR.)
>
> The duplication is, ultimately, fairly minor, so doing what you
> suggest also seems like overkill: it's not as though I'm going to be
> adding another five or ten connectives any time soon. Your version,
> while admittedly shorter, makes the code more complex and less
> readable, for no gain in expressiveness and a very minor improvement
> in brevity.

I did (and do) not mean to offend you, but reading duplicated code is 
rather hard, because you'll have to take care if it is really the same 
code or if there are minor differences introduced on purpose or by 
(copy-paste) accident.

Cheers Christian

>
> Benedict
>



More information about the Beginners mailing list