
Ok so I wrote and update function update :: Node -> [Node] It takes in a Node and returns a list of the Nodes that result from assigning True to an unassigned atom in one case and False in the other (ie. a case split). The list returned has two nodes as elements. One node contains the formula with an atom assigned True and the model updated with this assignment, and the other contains the formula with the atom assigned False and the model updated to show this. The lists of unassigned atoms of each node are also updated accordingly. This function makes use of an assign function to make the assignments. It also uses the chooseAtom function to select the literal to assign. update :: Node -> [Node] update (formula, (atoms, model)) = [(assign (chooseAtom atoms, True) formula, (remove (chooseAtom atoms) atoms, ((chooseAtom atoms,True)) `insert` model)) , (assign (chooseAtom atoms, False) formula, (remove (chooseAtom atoms) atoms, ((chooseAtom atoms, False) `insert` model)) )] Now I have to do the same thing but this time I must implement a variable selection heuristic.this should replace the chooseAtom and I'm supposed to write a function update2 using it type Atom = String type Literal = (Bool,Atom) type Clause = [Literal] type Formula = [Clause] type Model = [(Atom, Bool)] type Node = (Formula, ([Atom], Model)) update2 :: Node -> [Node] update2 = undefined So my question is how can I create a heurestic and to implement it into the update2 function ,that shoud behave identical to the update function ?

1. Atom: The Atom is the datatype used to describe Atomic Sentences or propositions. These are basically represented as a string. 2. Literal: Literals correspond to either atoms or negations of atoms. In this implementation each literal is represented as a pair consisting of a boolean value, indicating the polarity of the Atom, and the actual Atom. Thus, the literal ‘P’ is represented as (True,"P") whereas its negation ‘-P’ as (False,"P"). 2 3. Clause: A Clause is a disjunction of literals, for example PvQvRv-S. In this implementation this is represented as a list of Literals. So the last clause would be [(True,"P"), (True,"Q"), (True,"R"),(False,"S")]. 4. Formula: A Formula is a conjunction of clauses, for example (P vQ)^(RvP v-Q)^(-P v-R). This is the CNF form of a propositional formula. In this implementation this is represented as a list of Clauses, so it is a list of lists of Literals. Our above example formula would be [[(True,"P"), (True,"Q")], [(True,"R"), (True,"P"), (False,"Q")], [(False, "P"), (False,"P")]]. 5. Model: A (partial) Model is a (partial) assignment of truth values to the Atoms in a Formula. In this implementation this is a list of (Atom, Bool) pairs, ie. the Atoms with their assignments. So in the above example of type Formula if we assigned true to P and false to Q then our model would be [("P", True),("Q", False)] -- View this message in context: http://haskell.1045720.n5.nabble.com/Update2-tp3392490p3392589.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
participants (2)
-
Patrick M
-
PatrickM