Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

vallstAPI.h

Go to the documentation of this file.
00001 /*!\file
00002   Vallst's API.
00003   Vallst is a boolean constraint solver.
00004 
00005   See \ref VallstApiFuncsGrouped for a list of all API functions grouped into
00006   categories.
00007 */
00008 // (A comment marked with '!' is a doxygen comment and '\x' is a doxygen
00009 //  command. This is for generating documentation.)
00010 
00011 
00012 
00013 /*
00014     Copyright (C) 2004-2005 Daniel Vallstrom. All rights reserved.
00015 
00016     Unless explicitly acquired and licensed from Licensor under a license
00017     other than the Reciprocal Public License ("RPL"), the contents of this
00018     file are subject to the RPL Version 1.1, or subsequent versions as
00019     allowed by the RPL, and You may not copy or use this file in either
00020     source code or executable form, except in compliance with the terms
00021     and conditions of the RPL.
00022 
00023     You should be able to find a copy of the RPL (the "License") in a file
00024     named LICENSE that should come along with this file; if not, write to
00025     vallst@gmail.com.
00026 
00027     All software distributed under the License is provided in the hope
00028     that it will be useful, but WITHOUT ANY WARRANTY; without even the
00029     implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00030     PURPOSE. See the License for more details.
00031 */
00032 
00033 
00034 
00035 /*! \page VallstApiFuncsGrouped API functions grouped
00036     Here is a list of all API functions grouped into categories.
00037 
00038 
00039 \section allocSec Allocation
00040 
00041  - vallst_deleteInstance()       -- Deletes a vallst instance.
00042  - vallst_extendNrOfVars()       -- Extends the number of variables ready to be
00043                                     used.
00044  - vallst_newInstance()          -- Creates a new vallst problem instance.
00045  - vallst_propagateNrOf3ClausesEstimate()
00046                                  -- Propagates value.
00047  - vallst_propagateNrOfLitOccsEstimate()
00048                                  -- Propagates value.
00049  - vallst_setFstNrOfLevelsAllocSize()
00050                                  -- Sets flag.
00051  - vallst_setMaxHashLoad()       -- Sets max load.
00052  - vallst_setNonAxChunkSizeAxDep()
00053                                  -- Sets value.
00054  - vallst_setNonAxChunkSizeConst()
00055                                  -- Sets value.
00056  - vallst_setNonAxChunkSizeVarDep()
00057                                  -- Sets value.
00058  - vallst_setNrOf3ClausesEstimate()
00059                                  -- Sets the number of ternary clauses
00060                                     estimate.
00061  - vallst_setNrOfFreeChunksCap() -- Sets cap.
00062  - vallst_setNrOfLitOccsEstimate()
00063                                  -- Sets estimate of the number of literal
00064                                     occurrences, modulo special accounting.
00065 
00066 
00067 \section formulasSec Formulas and variables
00068 
00069  - vallst_addAxiom()             -- Adds an axiom.
00070  - vallst_addConsequence()       -- Adds a formula that should be a consequence
00071                                     of the axioms since the formula might be
00072                                     removed.
00073  - vallst_addNamedAxiom()        -- Adds a named axiom.
00074  - vallst_alterAxiomIncMT()      -- Adds to the constant in a more-than* axiom.
00075  - vallst_alterAxiomIncMTMKeepAboves()
00076                                  -- Adds to the constant in a <*-axiom keeping
00077                                     "aboves".
00078  - vallst_extendNrOfVars()       -- Extends the number of variables ready to be
00079                                     used.
00080  - vallst_formulaType()          -- Returns the type given a formula name.
00081  - vallst_getConst()             -- Returns the constant in a constraint.
00082  - vallst_getFullLitValue()      -- Returns the full status of a literal.
00083  - vallst_getKeepAboves()        -- Returns the keep-aboves flag.
00084  - vallst_getLitValue()          -- Returns the status of a literal.
00085  - vallst_getNrOfVarsAllocated() -- Returns the number of vars allocated for.
00086  - vallst_getTotalSum()          -- Returns the sum of the literal constants in
00087                                     a more-than-mult (<*) formula.
00088  - vallst_isConstraint()         -- Returns true iff a name is a constraint.
00089  - vallst_lessThanEqMultToMoreThanMult()
00090                                  -- Tranforms a >=*-formula into a <*-formula.
00091  - vallst_lessThanEqToMoreThan() -- Tranforms a >=-formula  into a <-formula.
00092  - vallst_neg()                  -- Returns the negation of a literal.
00093  - vallst_newVar()               -- Returns a new variable ready to be used.
00094  - vallst_setKeepAboves()        -- Sets flag.
00095  - vallst_setStartConst()        -- Sets value.
00096  - vallst_sumOpenTrue()          -- Sums up true and open lits in a constraint.
00097  - vallst_sumTrue()              -- Sums up true          lits in a constraint.
00098 
00099 
00100 \section searchSec Search
00101 
00102  - vallst_getAbortThreshold()    -- Returns nr of vars set to abort value.
00103  - vallst_getLevel()             -- Returns the current search level.
00104  - vallst_getNoAbortTime()       -- Returns time limit for no aborts.
00105  - vallst_makeCurrentAssumptionsSuggestions()
00106                                  -- Sets suggestions.
00107  - vallst_makeSearchAssumption() -- Makes a search assumption.
00108  - vallst_moveToLevel0()         -- Moves the current search state to level 0.
00109  - vallst_removeAssumptions()    -- Removes all search assumptions.
00110  - vallst_removeLastAssumption() -- Removes the last search assumption.
00111  - vallst_search()               -- Searches for a proof of false or a model.
00112  - vallst_setAbortThreshold()    -- Sets nr of vars set to abort.
00113  - vallst_setBufferResetFrequency()
00114                                  -- Sets the frequency.
00115  - vallst_setBufferSizeConst()   -- Sets value.
00116  - vallst_setBufferSizeNonAxDep()
00117                                  -- Sets value.
00118  - vallst_setBufferSizeVarDep()  -- Sets value.
00119  - vallst_setCCLeeway()          -- Sets proof improvement leeway.
00120  - vallst_setCreatePhantomConflictClauses()
00121                                  -- Sets the create-phantom-conflict-clauses
00122                                     flag.
00123  - vallst_setFirstRestart()      -- Sets the base/initial restart size.
00124  - vallst_setFstNrOfLevelsAllocSize()
00125                                  -- Sets flag.
00126  - vallst_setGoodClauseSize()    -- Sets what's to be considered good.
00127  - vallst_setGoodLevel()         -- Sets what's to be considered good.
00128  - vallst_setHeurAxSize()        -- Sets size.
00129  - vallst_setImproveProofLevel() -- Sets level threshold.
00130  - vallst_setKeepCCMetaMetaThreshold()
00131                                  -- Sets threshold.
00132  - vallst_setKeepConflictClauseLengthThreshold()
00133                                  -- Sets threshold.
00134  - vallst_setLooseTheoryMetaSizeLeeway()
00135                                  -- Set meta leeway used in loose mode.
00136  - vallst_setLooseTheorySizeLeeway()
00137                                  -- Set meta meta leeway used in loose mode.
00138  - vallst_setLooseTheorySizeLeewayKeep()
00139                                  -- Set leeway used in loose mode.
00140  - vallst_setLooseTimeLimitBase()
00141                                  -- Sets mode limit parameter.
00142  - vallst_setLooseTimeLimitMod() -- Sets mode limit parameter.
00143  - vallst_setMaxSkippedSimps()   -- Sets max skipped search simplifications.
00144  - vallst_setMetaMetaPruneEnd()  -- Sets the value.
00145  - vallst_setMetaMetaPruneFrequency()
00146                                  -- Sets the frequency.
00147  - vallst_setMetaMetaPruneStart()
00148                                  -- Sets the value.
00149  - vallst_setMetaPruneEnd()      -- Sets the value.
00150  - vallst_setMetaPruneFrequency()
00151                                  -- Sets the frequency.
00152  - vallst_setMetaPruneStart()    -- Sets the value.
00153  - vallst_setNextBatchSizeConst()
00154                                  -- Sets value.
00155  - vallst_setNoAbortTime()       -- Sets time limit for no aborts.
00156  - vallst_setPositiveHeurAxSign()
00157                                  -- Sets value.
00158  - vallst_setPositiveSign()      -- Sets value.
00159  - vallst_setPruningFunction()   -- Sets the pruning function.
00160  - vallst_setRandomBranchSign()  -- Sets random sign choice likelihood.
00161  - vallst_setRandomFormulaLit()  -- Sets random formula lit choice likelihood.
00162  - vallst_setRemoveTmpCauses()   -- Sets this flag.
00163  - vallst_setResetBuffersBetweenSearches()
00164                                  -- Sets flag.
00165  - vallst_setRestartFunc()       -- Sets restart batch size function.
00166  - vallst_setRestartPredefFunc() -- Chooses a predef. restart batch size
00167                                     function.
00168  - vallst_setRestartProlongCap() -- Sets cap.
00169  - vallst_setRestartStart()      -- Sets the start phase size.
00170  - vallst_setStartWithBinFstBcp()
00171                                  -- Sets flag.
00172  - vallst_setStrengthLeeway()    -- Sets the heuristic strength leeway.
00173  - vallst_setStrengthLeewayFormula()
00174                                  -- Sets the heuristic strength leeway for
00175                                     formulas.
00176  - vallst_setStrengthLeewaySize()
00177                                  -- Sets a hard strength leeway space size cap.
00178  - vallst_setStrengthLeewaySizeFormula()
00179                                  -- Sets a hard strength leeway space size cap
00180                                     for formulas.
00181  - vallst_setTightCCLeeway()     -- Sets tight proof improvement leeway.
00182  - vallst_setTightKeepCCThreshold()
00183                                  -- Set value used in tight mode.
00184  - vallst_setTightMetaMetaPruneEnd()
00185                                  -- Set value used in tight mode.
00186  - vallst_setTightMetaMetaPruneStart()
00187                                  -- Set value used in tight mode.
00188  - vallst_setTightMetaPruneStart()
00189                                  -- Set value used in tight mode.
00190  - vallst_setTightTheoryMetaSizeLeeway()
00191                                  -- Set meta leeway used in tight mode.
00192  - vallst_setTightTheorySizeLeeway()
00193                                  -- Set meta meta leeway used in tight mode.
00194  - vallst_setTightTheorySizeLeewayKeep()
00195                                  -- Set leeway used in tight mode.
00196  - vallst_setTightTimeLimitBase()
00197                                  -- Sets mode limit parameter.
00198  - vallst_setTightTimeLimitMod() -- Sets mode limit parameter.
00199  - vallst_setUseDoppelganger()   -- Sets flag.
00200 
00201 
00202 \section simpSec Simplification
00203 
00204  - vallst_compactifyVars()       -- Removes gaps in the variables.
00205  - vallst_getSubstEqus()         -- Returns flag.
00206  - vallst_permuteVars()          -- Permute the variables moving related
00207                                     variables closer together.
00208  - vallst_pruneTheory()          -- Prunes the theory.
00209  - vallst_setConvert3ClausesIntoEqus()
00210                                  -- Sets the convert-3-clauses flag.
00211  - vallst_setSimpTimeLimitFast() -- Sets time limit for fast simplifications.
00212  - vallst_setSimpTimeLimitSlow() -- Sets time limit for slow simplifications.
00213  - vallst_setSimpSetting()       -- Setting for main bcp based fast
00214                                     simplification.
00215  - vallst_setSimpSettingSlow()   -- Setting for main bcp based slow
00216                                     simplification.
00217  - vallst_setSubstEqus()         -- Sets flag.
00218  - vallst_simplify()             -- Simplifies the problem fast. BCP based.
00219  - vallst_simplifySlow()         -- Simplifies the problem slow. BCP based.
00220  - vallst_substEqus()            -- Substitutes vars p<->a in equivalences.
00221 
00222 
00223 \section symSec Symmetry detection
00224 
00225  - vallst_symmetrySearch()       -- Searches for symmetries.
00226 
00227 
00228 \section parsingSec Parsing
00229 
00230  - vallst_closeInTheoryFile()    -- Closes the in-theory file.
00231  - vallst_getInTheoryFile()      -- Returns the in-theory file.
00232  - vallst_getInTheoryFileName()  -- Returns the in-theory file name.
00233  - vallst_setPBVarPrefixChar()   -- Sets flag.
00234  - vallst_getProblemType         -- Returns the problem type.
00235  - vallst_parseCommandLineOptions()
00236                                  -- Parses options.
00237  - vallst_readInTheoryBody()     -- Reads the body of the in-theory.
00238  - vallst_readInTheoryHead()     -- Reads the head (i.e. the prologue) of the
00239                                     in-theory.
00240  - vallst_setIgnorePrologue()    -- Sets the ignore-prologue flag.
00241  - vallst_setInTheoryFile()      -- Sets the in-theory file.
00242  - vallst_setInTheoryFileName()  -- Sets the in-theory file name.
00243  - vallst_setProblemType         -- Sets the problem type.
00244  - vallst_setVarMapFile()        -- Sets the pb variable map file.
00245  - vallst_setVarMapFileName()    -- Sets the pb variable map file name.
00246 
00247 
00248 \section printSec Printing
00249 
00250  - vallst_closeChangingSettingFile()
00251                                  -- Closes the changing-setting file.
00252  - vallst_closeOutTheoryFile()   -- Closes the out-theory file.
00253  - vallst_getChangingSettingFile()
00254                                  -- Returns the changing-setting file.
00255  - vallst_getChangingSettingFileName()
00256                                  -- Returns the changing-setting file name.
00257  - vallst_getCompleteModel()     -- Returns the complete-model flag.
00258  - vallst_getOutTheoryFile()     -- Returns the out-theory file.
00259  - vallst_getOutTheoryFileName() -- Returns the out-theory file name.
00260  - vallst_getPrintChangingSetting()
00261                                  -- Returns the print-changing-setting flag.
00262  - vallst_getPrintOutTheory()    -- Returns the print-out-theory flag.
00263  - vallst_getResultFile()        -- Returns the result file.
00264  - vallst_getResultFileName()    -- Returns the result file name.
00265  - vallst_getVerbosityVector()   -- Returns the verbosity vector.
00266  - vallst_hashStateCheck()       -- Prints detailed hash info.
00267  - vallst_printAllGgcditTours()  -- Prints all ggcdit tours.
00268  - vallst_printChangingSetting() -- Prints changing settings.
00269  - vallst_printChangingSettingToFile()
00270                                  -- Prints changing settings to supplied file.
00271  - vallst_printEstimatedPrologues()
00272                                  -- Prints estimated prologue values.
00273  - vallst_printGgcditTour()      -- Prints a tour.
00274  - vallst_printHashInfo()        -- Prints easily obtainable hash info.
00275  - vallst_printModel()           -- Prints the current value of variables.
00276  - vallst_printNrOfUncheckedVars()
00277                                  -- Prints nr of unchecked vars.
00278  - vallst_printNrOfVarsSet()     -- Prints nr of vars set.
00279  - vallst_printOpenTheory()      -- Prints the current theory but without the
00280                                     variable history.
00281  - vallst_printPrologues()       -- Prints hindsighted prologue values.
00282  - vallst_printSettings()        -- Prints option settings.
00283  - vallst_printTheory()          -- Prints the current theory.
00284  - vallst_printTheoryToFile()    -- Prints the theory to a supplied file.
00285  - vallst_printTimePassed()      -- Prints the cpu time used.
00286  - vallst_printVallstResult()    -- Prints a short string corresponding to a
00287                                     VallstResult.
00288  - vallst_printVarHistory()      -- Prints the variable history.
00289  - vallst_setChangingSettingFile()
00290                                  -- Sets the changing-setting file.
00291  - vallst_setChangingSettingFileName()
00292                                  -- Sets the changing-setting file name.
00293  - vallst_setCompleteModel()     -- Sets the complete-model flag.
00294  - vallst_setOutTheoryFile()     -- Sets the out-theory file.
00295  - vallst_setOutTheoryFileName() -- Sets the out-theory file name.
00296  - vallst_setPrintChangingSetting()
00297                                  -- Sets the print-changing-setting flag.
00298  - vallst_setPrintOutTheory()    -- Sets the print-out-theory flag.
00299  - vallst_setResultFile()        -- Sets the result file.
00300  - vallst_setResultFileName()    -- Sets the result file name.
00301  - vallst_setVerbosityLevel()    -- Sets the verbosity level.
00302  - vallst_setVerbosityVector()   -- Sets the verbosity vector.
00303 
00304 
00305 \section callbackSec Callback
00306 
00307  - vallst_setCallback()          -- Sets the callback function.
00308 
00309 
00310 \section nameAllocSec Formula name allocation
00311 
00312  - vallst_extendFormulaNameArray()
00313                                  -- Extends a name array.
00314  - vallst_newFormulaNameArray()  -- Returns a new formula name array.
00315 
00316 
00317 \section graphCodingSec Graph coding
00318 
00319  - vallst_ggcditEdgeToLit()      -- Maps an (i,j) edge to a vallst literal.
00320  - vallst_ggcditLitToEdge()      -- Maps a literal to the corresponding edge.
00321  - vallst_ggcditLitToEdgeFst()   -- Maps a literal to first node of edge.
00322 
00323 
00324 \section optimizationSec Optimization
00325 
00326  - vallst_getBreadthFstOptStrat()
00327                                  -- Returns the optimization strategy flag.
00328  - vallst_maxConstraints()       -- Maximizes constraint constants.
00329  - vallst_setBreadthFstOptStrat()
00330                                  -- Sets the optimization strategy flag.
00331 
00332 
00333 \section seedSec Seed
00334 
00335  - vallst_getSeed()              -- Gets the seed used.
00336  - vallst_setSeed()              -- Sets the seed.
00337 
00338 
00339 \section timerSec Timers
00340 
00341  - vallst_setTimeLimitInMilliSec()
00342                                  -- Sets the overall time limit in
00343                                     milliseconds.
00344  - vallst_setTimeLimitInSec()    -- Sets the overall time limit in seconds.
00345 
00346 
00347 */
00348 
00349 
00350 
00351 #ifndef vallstAPI_H
00352 #define vallstAPI_H
00353 
00354 
00355 #ifdef __cplusplus
00356 extern "C"
00357 {
00358 #endif
00359 
00360 
00361 #include <stdint.h>
00362 #include <stdbool.h>
00363 #include <limits.h>
00364 #include <stdio.h>
00365 #include <time.h>
00366 
00367 
00368 
00369 // Types. -------------------------------------------------------------
00370 
00371 
00372 //! The main structure containing everything.
00373 typedef struct VallstInstance_ VallstInstance;
00374 
00375 /*! The type for literals. 2, 3, 4, ... are literals.
00376 
00377       (If you want you can change this to e.g. uint16_t. See note in
00378     vallstTypes.h.)
00379 */
00380 typedef uint32_t VallstLiteral;
00381 
00382 //! The maximum value of the type VallstLiteral
00383 #define VallstLiteral_MAX UINT32_MAX
00384 
00385 //! A type for counting literals.
00386 typedef VallstLiteral VallstLiteralN;
00387 
00388 //! A type for counting formulas.
00389 typedef uint32_t VallstFormulaN;
00390 
00391 //! The maximum value of the type VallstFormulaN
00392 #define VallstFormulaN_MAX UINT32_MAX
00393 
00394 
00395 
00396 // Some special values with special meaning.
00397 
00398 //! No prologue nrOfVars was present. This is not treated as an error.
00399 #define VallstLiteralN_noPrologueNrOfVars (VallstLiteral_MAX)
00400 
00401 //! Parse error.
00402 #define VallstLiteralN_parseError         (VallstLiteral_MAX-1)
00403 
00404 //! File error.
00405 #define VallstLiteralN_fileError          (VallstLiteral_MAX-2)
00406 
00407 //! An undefined VallstFormulaN.
00408 #define VallstFormulaN_undef VallstFormulaN_MAX
00409 
00410 
00411 
00412 //! A result type used for various functions.
00413 typedef enum
00414 {
00415     VallstResult_proofOfFalse,       //!< A proof of false was found.
00416     VallstResult_model,              //!< A model was found.
00417     VallstResult_timeLimitExceeded,  //!< The time limit has been exceeded.
00418     VallstResult_interupt,           //!< An interupt signal was received.
00419     VallstResult_notEnoughMemory,    //!< Not enough memory could be allocated.
00420     VallstResult_fileError,          //!< Some file error occurred.
00421     VallstResult_parseError,         //!< A parse error occurred.
00422     //VallstResult_error,              // Other error. Not used.
00423 
00424     //! There is no model where the extra search assumptions are true as well.
00425     VallstResult_proofOfFalseGivenSearchAssumptions,
00426 
00427     //! Model where the extra search assumptions are true as well.
00428     VallstResult_modelOfSearchAssumptions,
00429 
00430     //! VallstResult_other* constants are for miscellaneous other results.
00431     VallstResult_other,
00432     // VallstResult_other1,
00433     // ...
00434     //! VallstResult_otherIntMax ensures that the VallstResult type is large.
00435     VallstResult_otherIntMax = INT_MAX
00436 
00437 } VallstResult;
00438 
00439 
00440 
00441 //! A type for formula formats.
00442 typedef VallstLiteralN VallstFormulaType;
00443 
00444 /*!\t
00445   For any formula a you can easily introduce a Tseitin name p for the
00446   formula such that p<=>a --- disregarding global types.
00447 
00448   Formulas of type >=* and >= aren't supported directly. Instead you have to
00449   transform them into <*- and <-formulas. See
00450   vallst_lessThanEqMultToMoreThanMult() and vallst_lessThanEqToMoreThan().
00451 
00452   (Negated) equivalences will be normalized so that all the literals in them
00453   are unnegated. E.g. <->{-p,-q,-r} will be turned into -<->{p,q,r} where
00454   p, q and r are variables.
00455 */ /*\{*/ /*!\u*/ //\{
00456 
00457 //! Arbitrary long disjunction, \/{...}.
00458 #define VallstFormulaType_clause          (VallstLiteral_MAX-1)
00459 
00460 
00461 /*! Arbitrary long equivalence, <->{...} (i.e p1<->p2<->p3<->p4<->...<->pn
00462    (saying that an even number of the literals are true if n is even and saying
00463    that an odd number of the literals are true if n is odd)).
00464 */
00465 #define VallstFormulaType_equivalence     (VallstLiteral_MAX-5)
00466 
00467 //! Arbitrary long negated equivalence (xor), -<->{...}
00468 //! (i.e -(p<->q<->r<->s<->...)).
00469 #define VallstFormulaType_negEquivalence  (VallstLiteral_MAX-4)
00470 
00471 
00472 /*! Arbitrary long constraint on the form c < p+q+r+..., where c is a constant.
00473     I.e. the formula says that at least c+1 of p,q,... should be true.
00474 
00475       With c=0, the formula is equivalent to a disjunction and it's slightly
00476     more efficient to use the clause form. Note though that there can be good
00477     reasons for using c=0, namely in cases where you later on might want to
00478     increase the constant.
00479 
00480       See vallst_lessThanEqToMoreThan() for transforming a >=-formula into a
00481     <-formula.
00482 */
00483 #define VallstFormulaType_moreThan        (VallstLiteral_MAX-6)
00484 
00485 /*!\v
00486     For formulas p\/a where a is of more-than type.
00487       With this type you can Tseitin name more-than formulas without using
00488     more-than-mult: Let a be c < q0 + .. + qn. Then p <=> a is equivalent to
00489     -p \/ a and p \/ -a where -a can be expressed as n-c < -q0 + ... + -qn.
00490       Having more-than-dis means that the more-than type isn't strictly
00491     necessary. However, using more-than rather than more-than-dis when
00492     possible is a little bit more efficient and transparent.
00493       Note that if you are looking for a p \/ /\{q0,...,qn} formula type
00494     you can use more-than-dis with c=n, i.e. p \/ n<q0+...+qn.\w
00495 */
00496 #define VallstFormulaType_moreThanDis     (VallstLiteral_MAX-7)
00497 
00498 /*! Arbitrary long constraint on the form c < d0*p0 + d1*p1 + ... where c and
00499     di are constants.
00500 
00501       A Tseitin name p for a more-than-mult formula a = c < +{di*pi} can be
00502     defined like this: q \/ a <=> c < +{di*pi} + (c+1)*q. Also,
00503     +{di} = +{di*pi} + +{di*-pi}. Hence, -a <=> c >= +{di*pi} <=>
00504     c >= +{di} - +{di*-pi} <=> +{di*-pi} >= +{di} - c <=>
00505     +{di}-c-1 < +{di*-pi}. Therefor p <=> a can be expressed by translating
00506     -p \/ a and p \/ -a. See vallst_lessThanEqMultToMoreThanMult() for
00507     transforming a >=*-formula into a <*-formula.
00508 
00509       Negative constants are not allowed. You can transform negative literal
00510     constants like this:  c < ... + -d*p + ...  <=>  c+d < ... + d*-p + ...
00511 
00512       If the formula is very long you might want to input d0, d1,... in
00513     increasing order since internally they will be sorted that way using an
00514     algorithm which is fast on already increasing formulas but which might be
00515     slow on non-increasing formulas.
00516 
00517       Excessive variable constants, as in e.g. 3 < 9*p + 7*q + 5*r + ..., are
00518     allowed and could be useful if you plan on incrementing the main constant,
00519     3, later on (see vallst_addNamedAxiom() and axiom altering functions).
00520     Though, rather than using excessive constants you might want to use
00521     vallst_alterAxiomIncMTMKeepAboves() instead.
00522     
00523 */
00524 #define VallstFormulaType_moreThanMult    (VallstLiteral_MAX-8)
00525 
00526 
00527 /*! \a0
00528     The meaning of the global axiom type VallstFormulaType_ggcdiTour is
00529     that any solution interpreted as nodes and edges in a complete directed
00530     irreflexive graph, assuming a canonical coding, must be a tour (i.e. a
00531     Hamiltonian cycle (visiting every node in the graph)).
00532 
00533       This formula type only covers the non-local part of formulas stating
00534     that the solution is a tour. Accompanying this formula must be the
00535     concluding local part. Otherwise the meaning and behaviour of the 
00536     solver is undefined.
00537 
00538       Here is an example that will clear things up:
00539     Suppose that you have a problem involving a complete directed irreflexive
00540     graph with n nodes 0,1...n-1. n is the dimension (dim) and the graph
00541     has n*(n-1) edges. Suppose that any solution to the problem must result
00542     in a tour of the graph; confer the asymmetric traveling salesperson
00543     problem, atsp. Let the graph be coded by variables p(i,j) with i!=j,
00544     i<n and j<n. p(i,j) will be true iff the edge (i,j) in the graph will be
00545     used in the solution. Assume that in actual fact p(i,j) will be
00546     represented by vallst literals q, q+2, q+4... where q is some offset 
00547     start vallst literal, e.g. 2. q may be odd. If q is 2 then let edge
00548     (0,1) be represented by vallst variable 2, (0,2) by 4, (0,3) by 6,
00549     (1,0) by 2*((n-1)+1), (1,2) by 2*((n-1)+2), (2,0) by 2*(2*(n-1)+1)... 
00550       The local part of formulas saying that a solution must be a tour says
00551     that each node has at most 1 in-edge and 1 out-edge, and at least
00552     1 in-edge and 1 out-edge:
00553 
00554         -     for all i<n,  n-3 < +{-p(i,j): j!=i, j<n}
00555         -     for all i<n,  n-3 < +{-p(j,i): j!=i, j<n}
00556         -     for all i<n,  \/{p(i,j): j!=i, j<n}
00557         -     for all i<n,  \/{p(j,i): j!=i, j<n}
00558 
00559     Then if you add a non-local tour axiom with vallst literal start q
00560     and with dimension n, you are ensured that any solution is a tour.
00561     The call to vallst_addAxiom() would be
00562     vallst_addAxiom( vi, [q,n], 2, VallstFormulaType_ggcdiTour ).
00563 
00564     As said, the tour type assumes the canonical coding of the graph
00565     described above. For a further definition of the canonical coding and
00566     utilities, see the macros vallst_ggcditEdgeToLit() and
00567     vallst_ggcditLitToEdge() (where dim is n above).
00568 */
00569 #define VallstFormulaType_ggcdiTour       (VallstLiteral_MAX-9)
00570 
00571 
00572 /*! Marks that the formula has been erased. 
00573 
00574       Although you can't use this type directly, you might still encounter
00575     this type because formulas can be erased by vallst. Say e.g. that you have
00576     named an axiom b which later gets erased by vallst (e.g. because it's
00577     simplified away or recognized to be subsumed). Then you have a name of an
00578     erased axiom and if you e.g. call vallst_formulaType() with the name you
00579     will get VallstFormulaType_erased back.
00580 */
00581 #define VallstFormulaType_erased          (VallstLiteral_MAX-10)
00582 
00583 /*\}*/ //\}
00584 
00585 
00586 
00587 //! A result type used for callback functions.
00588 typedef enum
00589 {
00590     VallstCallbackResult_continue,   //!< Continue as normal.
00591     VallstCallbackResult_interupt,   //!< Interupt and possibly save what has 
00592                                      //!  been achieved so far.
00593     VallstCallbackResult_otherIntMax = INT_MAX
00594 
00595 } VallstCallbackResult;
00596 
00597 
00598 
00599 //! Each bit in a verbosity vector decides if some particular info should be
00600 //! printed when appropriate. See \r2 below for what each bit means.
00601 typedef uint64_t VallstVerbosityVector;
00602 
00603 /*!\m Masks for the verbosity vector */
00604 /*\{*/ /*!\o*/ //\{
00605 
00606 //! Warns when space dependent on the number of variables needs to be extended.
00607 #define VallstVerbosity_varExtensionWarning ( (VallstVerbosityVector)1 << 0 )
00608 
00609 //! Warns when an empty (i.e. false) clause is added. Also warns about e.g.
00610 //! -<->{} I think. Not sure if every case that one wants to catch is caught.
00611 #define VallstVerbosity_emptyClauseWarning  ( (VallstVerbosityVector)1 << 1 )
00612 
00613 //! Gives you notice if you miss to oversee the allocation of the theory
00614 //! memory so that vallst will have to do it for you.
00615 #define VallstVerbosity_theoryMemNotice     ( (VallstVerbosityVector)1 << 2 )
00616 
00617 //! Prints info about a search when it's finished.
00618 #define VallstVerbosity_searchDetails       ( (VallstVerbosityVector)1 << 3 )
00619 
00620 //! Prints any model found.
00621 #define VallstVerbosity_printModel          ( (VallstVerbosityVector)1 << 4 )
00622 
00623 //! Prints parse error messages.
00624 #define VallstVerbosity_parseError          ( (VallstVerbosityVector)1 << 5 )
00625 
00626 //! Prints messages about other errors that the program will recover from and
00627 //! then continue.
00628 #define VallstVerbosity_lesserError         ( (VallstVerbosityVector)1 << 6 )
00629 
00630 //! Prints a brief notice of the result of the proof search.
00631 #define VallstVerbosity_printResult         ( (VallstVerbosityVector)1 << 7 )
00632 
00633 //! Prints info about how many variables are set and unchecked.
00634 #define VallstVerbosity_varsSet             ( (VallstVerbosityVector)1 << 8 )
00635 
00636 //! Prints the seed.
00637 #define VallstVerbosity_printSeed           ( (VallstVerbosityVector)1 << 9 )
00638 
00639 //! Prints the cpu time used.
00640 #define VallstVerbosity_time                ( (VallstVerbosityVector)1 << 10 )
00641 
00642 //! Prints some, easily obtainable, info about the hash-table.
00643 #define VallstVerbosity_hashInfo            ( (VallstVerbosityVector)1 << 11 )
00644 
00645 //! Prints option settings.
00646 #define VallstVerbosity_printSettings       ( (VallstVerbosityVector)1 << 12 )
00647 
00648 //! Prints hindsighted prologue values. See \ref vallst.c for an example.
00649 #define VallstVerbosity_printPrologues      ( (VallstVerbosityVector)1 << 13 )
00650 
00651 //! Prints estimated prologue values. See \ref vallst.c for an example.
00652 #define VallstVerbosity_printEstimatedPrologues  \
00653                                             ( (VallstVerbosityVector)1 << 14 )
00654 
00655 //! Gives notice when clauses are converted to an equivalence.
00656 #define VallstVerbosity_equConversionNotice ( (VallstVerbosityVector)1 << 15 )
00657 
00658 //! Prints info about non-axioms.
00659 #define VallstVerbosity_nonAxInfo           ( (VallstVerbosityVector)1 << 16 )
00660 
00661 //! Prints info about optimization parts of a problem.
00662 #define VallstVerbosity_optimizeInfo        ( (VallstVerbosityVector)1 << 17 )
00663 
00664 //! Gives notice when an already existing clause is added.
00665 #define VallstVerbosity_redundancyNotice    ( (VallstVerbosityVector)1 << 18 )
00666 
00667 //! Prints message about failure to double the hash table size. The program
00668 //! will recover from this error and then continue.
00669 #define VallstVerbosity_lesserHashError     ( (VallstVerbosityVector)1 << 19 )
00670 
00671 
00672 //! Prints progress info during the simplification process.
00673 #define VallstVerbosity_simpProgressDetails ( (VallstVerbosityVector)1 << 22 )
00674 
00675 //! Gives notice when a proof improvement attempt failed to prove false.
00676 #define VallstVerbosity_failedProofImprovementNotice  \
00677                                             ( (VallstVerbosityVector)1 << 23 )
00678 
00679 //! Prints info about proof improvements during search as they happen.
00680 #define VallstVerbosity_proofImprovementDetails  \
00681                                             ( (VallstVerbosityVector)1 << 24 )
00682 
00683 //! Prints detailed info about a the hash-table during consistency checks.
00684 #define VallstVerbosity_hashDetails         ( (VallstVerbosityVector)1 << 25 )
00685 
00686 //! Prints info about restarts during the search as they occur.
00687 #define VallstVerbosity_restartDetails      ( (VallstVerbosityVector)1 << 26 )
00688 
00689 //! Prints detailed progress info during the search.
00690 #define VallstVerbosity_progressDetails     ( (VallstVerbosityVector)1 << 27 )
00691 
00692 //! Prints detailed info about a the search branching heuristic.
00693 #define VallstVerbosity_branchingDetails    ( (VallstVerbosityVector)1 << 28 )
00694 
00695 //! Gives notice of a midair pruning.
00696 #define VallstVerbosity_midairPruneNotice   ( (VallstVerbosityVector)1 << 29 )
00697 
00698 //! Prints various not too interesting midair pruning details.
00699 #define VallstVerbosity_midairPruneDetails  ( (VallstVerbosityVector)1 << 30 )
00700 
00701 //! Gives notice when a contradiction is found but not acted on.
00702 #define VallstVerbosity_ignoredContradictionNotice  \
00703                                             ( (VallstVerbosityVector)1 << 31 )
00704 
00705 /*\}*/ //\}
00706 
00707 
00708 
00709 //! The type for names for formulas.
00710 typedef void * VallstFormulaName;
00711 
00712 
00713 //! A dynamic array of type VallstFormulaName.
00714 typedef struct VallstFormulaNames_ VallstFormulaNames;
00715 
00716 //! A dynamic array of type VallstFormulaName.
00717 struct VallstFormulaNames_
00718 {
00719     VallstFormulaName * names;         //!< The start of the array.
00720     VallstFormulaN nrOfNames;          //!< The current number of active names.
00721     VallstFormulaN nrOfAllocatedNames; //!< The physical length of the array.
00722 
00723 };
00724 
00725 
00726 
00727 /*!\d4 Problem types */
00728 /*\{*/ /*!\n1*/ //\{
00729 
00730 //! For some general default settings.
00731 #define VallstProblemType_default 0
00732 
00733 //! Means that the type is undefined at the moment. If the undefined value
00734 //! doesn't apply and something is needed, the same settings as for
00735 //! VallstProblemType_default will be used.
00736 #define VallstProblemType_undef   1
00737 
00738 //! For asymmetric traveling salesperson problems.
00739 #define VallstProblemType_atsp    2
00740 
00741 //! For symmetric traveling salesperson problems.
00742 #define VallstProblemType_tsp     3
00743 
00744 //! For pseudo boolean, (o)pb, problems. Only meant for problems where the
00745 //! input is on (restricted) (o)pb form.
00746 #define VallstProblemType_pb      4
00747 
00748 /*\}*/ //\}
00749 
00750 
00751 
00752 /*!\j Allocation */ // -----------------------------------------------
00753 //\{
00754 
00755 
00756 // vallst_deleteInstance       -- Deletes a vallst instance.
00757 
00758 
00759 /*! Returns a new vallst problem instance. NULL is returned iff a new instance
00760     couldn't be created, which can only happen due to insufficient memory.
00761 
00762       nrOfVars is meant to be a roughly minimal upper bound for the number of
00763     variables, like in the DIMACS cnf prologue. Any value including 0 will work
00764     though and if you don't have any good guess of a roughly minimal upper
00765     bound just use any value as long as it isn't much larger than the largest
00766     variable to be used.
00767 
00768       If nrOfVars is 0, no variable space will be allocated. Using nrOfVars=0
00769     is useful for memory efficiency reasons if you at first don't know how many
00770     variables that are used. If you later learn of a roughly minimal upper
00771     bound on the variables you can call vallst_extendNrOfVars().
00772     See vallst.c for an example.
00773 
00774       nrOf3ClausesEstimate is meant to be an estimate of the number of ternary
00775     clauses. It's not important that nrOf3Clauses is exactly accurate but any
00776     fairly accurate estimate might be helpful for memory efficiency reasons.
00777 
00778       You can use nrOf3ClausesEstimate=0, and then later, before adding
00779     ternary clauses, set an estimate with vallst_setNrOf3ClausesEstimate() and
00780     propagate the value by calling vallst_propagateNrOf3ClausesEstimate().
00781     See vallst.c for an example.
00782 
00783       If you know that there will be ternary clauses but have no idea of how
00784     many, just use any value not too large, e.g. 0. The only motive behind 
00785     this number of ternary clauses estimate is to improve efficiency a little;
00786     it's not very important.
00787 
00788       nrOfLitOccsEstimate is supposed to be a possibly rough estimate of the
00789     number of literal/constant occurrences in the input theory modulo "special
00790     accounting". The special accounting works like this: Occurrences in unit
00791     formulas or binary disjunctions don't count at all; add 1 for each
00792     formula (that isn't unit or a binary disjunction); add 1 for each formula
00793     that isn't a ternary disjunction (and not unit or a binary disjunction);
00794     add 2 for each <*-formula; the count for ggcdit is exactly 4. For example,
00795     the count for c < c1*p1 + ... + cn*pn  would be 1 + 2*n + 1 + 1 + 2.
00796 
00797       It's not important that the estimate is exactly accurate but any fairly
00798     accurate estimate might be helpful for memory efficiency reasons. Try to
00799     make it an upper bound. You could also set the value to some fraction of
00800     the "correct" value. Just try not to get a too low value.
00801 
00802       You can use nrOfLitOccsEstimate = VallstFormulaN_undef, and then later,
00803     before adding formulas, set an estimate with
00804     vallst_setNrOfLitOccsEstimate() and propagate the value by calling
00805     vallst_propagateNrOfLitOccsEstimate(). See vallst.c for an example.
00806 */
00807 VallstInstance * vallst_newInstance( VallstLiteralN nrOfVars,
00808                                      VallstFormulaN nrOf3ClausesEstimate,
00809                                      VallstFormulaN nrOfLitOccsEstimate );
00810 
00811 
00812 /*! See vallst_newInstance() for a description.
00813     Returns true iff not enough memory could be allocated.
00814 
00815       Nothing is done if the nrOf3ClausesEstimate in vi is undefined, i.e.
00816     equals VallstFormulaN_undef.
00817 */
00818 bool vallst_propagateNrOf3ClausesEstimate( VallstInstance * vi );
00819 
00820 
00821 /*! See vallst_newInstance() for a description.
00822     Returns true iff not enough memory could be allocated.
00823 
00824       Nothing is done if the theory memory is already set up somehow, i.e.
00825     the theory memory isn't NULL.
00826 
00827       If the nrOfLitOccsEstimate in vi is undefined, i.e. equals
00828     VallstFormulaN_undef, nrOfLitOccsEstimate in vi will be set to some
00829     value first before propagation.
00830 
00831       If it's possible, try to set the number of variables, explicitly or
00832     implicitly, before calling this function since some heuristic size value
00833     function will use that variable value. See e.g. vallst.c.
00834 */
00835 bool vallst_propagateNrOfLitOccsEstimate( VallstInstance * vi );
00836 
00837 
00838 /*! Sets the fstNrOfLevelsAlloc size.
00839 
00840       If no smaller value can be seen to be enough, like e.g. the number of
00841     variables, this value will be used as a first allocation size of
00842     nr-of-levels dependent arrays.
00843 
00844       This value can at most only have some minor memory allocation
00845     efficiency impact.
00846 */
00847 void vallst_setFstNrOfLevelsAllocSize( VallstInstance * vi,
00848                                        VallstLiteralN size );
00849 
00850 
00851 //! Sets max load. Decides how many hash entries are allowed before resizing.
00852 //! Resizing is done when maxLoad < nrOfEntries/tableSize.
00853 void vallst_setMaxHashLoad( VallstInstance * vi, double maxLoad );
00854 
00855 
00856 //! Sets the value. It determines the size addition to the non-axiom chunk
00857 //! size relative to the size of the axiom chunks.
00858 void vallst_setNonAxChunkSizeAxDep( VallstInstance * vi, double value );
00859 
00860 //! Sets the value. It determines the size of a constant addition to the
00861 //! non-axiom chunk size.
00862 void vallst_setNonAxChunkSizeConst( VallstInstance * vi,
00863                                     VallstFormulaN value );
00864 
00865 //! Sets the value. It determines the size addition to the non-axiom chunk size
00866 //! relative to the number of variables allocated for.
00867 void vallst_setNonAxChunkSizeVarDep( VallstInstance * vi, double value );
00868 
00869 
00870 /*! Sets the number of ternary clauses estimate.
00871 
00872       It's not important that the estimate is exactly accurate but any fairly
00873     accurate estimate might be helpful for memory efficiency reasons.
00874 */
00875 void vallst_setNrOf3ClausesEstimate( VallstInstance * vi,
00876                                      VallstFormulaN pNrOf3Clauses );
00877 
00878 
00879 /*! Sets cap.
00880 
00881       Only 'cap' number of free chunks are guaranteed to be kept.
00882     The rest are freed occasionally, handing the memory back to the system.
00883 */
00884 void vallst_setNrOfFreeChunksCap( VallstInstance * vi, unsigned int cap );
00885 
00886 
00887 /*! Sets the number of literal occurrences estimate, modulo special accounting.
00888     See vallst_newInstance().
00889 
00890       It's not important that the estimate is exactly accurate but any fairly
00891     accurate estimate might be helpful for memory efficiency reasons. Try to
00892     make it an upper bound.
00893 */
00894 void vallst_setNrOfLitOccsEstimate( VallstInstance * vi,
00895                                     VallstFormulaN pNrOfLitOccs );
00896 
00897 
00898 //\}
00899 
00900 
00901 
00902 /*!\x Formulas and variables */ // -----------------------------------
00903 //\{
00904 
00905 /*! Adds an axiom. New unit clauses will be put as unchecked w.r.t bcp.
00906 
00907       Literals are represented by 2, 3, 4,... 2 is the first variable. 3 is
00908     the negation of the first variable. In general 2n is the nth variable and
00909     2n+1 is the negation of the nth variable.
00910 
00911       'size' is the size of the formula to add, i.e. the length of 'axiom'.
00912 
00913       E.g. if the formula is a ternary clause 3\/6\/8, 'size' should be 3,
00914     type should be VallstFormulaType_clause and axiom should be [3,6,8].
00915 
00916       E.g. 1 < p+q+r is represented as [1,p,q,r] (where p, q and r are numbers
00917     representing literals) and the size is 4.
00918 
00919       2 < 3*p + 2*q + r + s is represented as [2,3,p,2,q,1,r,1,s] with size 9.
00920 
00921       p \/ c<q+r+s is represented as [p,c,q,r,s] with size 5.
00922 
00923       The axiom array might be altered.
00924 
00925       VallstResult_other is returned if no other value is applicable.
00926     VallstResult_model is never returned. Neither is
00927     VallstResult_modelOfSearchAssumptions, nor
00928     VallstResult_proofOfFalseGivenSearchAssumptions.
00929 
00930       For <*-formulas a variable p is allowed to occur as many times as you
00931     like, both positively and negatively. I.e. the literal list may look like
00932     ...d*p...e*p...f*-p...g*p...h*-p...
00933 
00934       For more-than and more-than-dis formulas it's an error if a literal
00935     occurs twice with the same sign, i.e. if the literal list looks like
00936     ...p...p... or ...-p...-p... where p is a variable. ...p...-p... is allowed
00937     though.
00938 
00939       If the type is more-than-dis and the formula is p\/a, then p and -p are
00940     allowed to occur in a.
00941 
00942       Literal constants in <*-formulas may be 0, like e.g. in c < ...0*p....
00943 
00944       You may use 0 and 1 as false and true constants if you like. (This of
00945     course only works here and not for the file parser where 0 marks the end
00946     of formulas.)
00947 
00948       If you have unit-clauses to add it might be slightly more efficient to
00949     supply them first.
00950 
00951       You might want to add the more important axioms, like e.g. a conclusion
00952     if there is something like that, last. This is for efficiency reasons
00953     since some heuristics go through the axioms from the last one to the
00954     first one. There might also be some sort of sos-like strategy in use
00955     where only the last n axioms will be considered.
00956 
00957       It might be good to have strong (short) formulas before weak (long)
00958     ones. (Consider though also the above paragraph.)
00959 */
00960 VallstResult vallst_addAxiom( VallstInstance * vi,
00961                               VallstLiteral * axiom,
00962                               VallstLiteralN size,
00963                               VallstFormulaType type );
00964 
00965 
00966 /*! Adds a formula that should be a consequence of the axioms since the formula
00967     might be removed. (It's guaranteed though that formulas with less than 4(?)
00968     literals won't be removed.)
00969 
00970       The formula must be a cnf clause, otherwise VallstResult_parseError is
00971     return.
00972 
00973       Otherwise it works like vallst_addAxiom().
00974 */
00975 VallstResult vallst_addConsequence( VallstInstance * vi,
00976                                     VallstLiteral * nonAxiom,
00977                                     VallstLiteralN size,
00978                                     VallstFormulaType type );
00979 
00980 
00981 /*! Adds a named axiom.
00982 
00983       Works like vallst_addAxiom() except that a name of the axiom is placed in
00984     *namePtr for future reference. The return value might also be different,
00985     see below. If namePtr is NULL, nothing extra is done at all and
00986     vallst_addNamedAxiom() will work exactly like vallst_addAxiom().
00987 
00988       Note that even if you successfully called vallst_addNamedAxiom() creating
00989     a new axiom, the axiom might internally have been tranformed into something
00990     you might not have expected. E.g. even if you input a long more-than-dis
00991     axiom, this might be turned into a binary clause.
00992 
00993       If a new axiom b was created, and b isn't a binary disjunction, then
00994     VallstResult_other will be returned and namePtr will be updated if it isn't
00995     NULL.
00996 
00997       Important to note is that binary clauses are treated in a special way
00998     because it's not very convenient or feasible to give them names like for
00999     other formulas. Instead, if a new axiom b was created, and b is a binary
01000     disjunction, either because the input was a binary clause or the input was
01001     transformed into a binary clause internally, then when a name is requested
01002     for b, *namePtr will be assigned 'axiom' (*namePtr = axiom) and the two
01003     disjuncts in the binary clause will be placed at the first two positions,
01004     [0..1], in the *namePtr/axiom array. VallstResult_other is returned.
01005 
01006       If no axiom was created and no already existing formula was found to be
01007     equivalent to 'axiom', (e.g. because the axiom was found inconsistent
01008     and vallst_addNamedAxiom() therefor returned VallstResult_proofOfFalse),
01009     *namePtr will be assigned NULL.
01010 
01011       If no axiom was created because 'axiom' was found to already be true,
01012     *namePtr will be assigned NULL and VallstResult_other+1 will be returned.
01013 
01014       If no axiom was created but, or rather because, 'axiom' was found to be
01015     equivalent to a literal, p, *namePtr will be assigned 'axiom' (*namePtr =
01016     axiom), p will be placed in the first position ([0]) in the *namePtr/axiom
01017     array (axiom[0] = p) and VallstResult_other+2 will be returned (and p will
01018     of course be set to true).
01019 
01020       If no axiom was created because 'axiom' was found to be equivalent to an
01021     already existing axiom b, then *namePtr will be assigned 'axiom'
01022     (*namePtr = axiom) when b is a binary clause; *namePtr will be a name of b
01023     when b isn't a binary clause. The equivalent axiom b is a disjunction and
01024     the disjuncts in b are placed in the first positions, [0..k], in the
01025     *namePtr/axiom array. Also, vallst_addNamedAxiom() will return
01026     VallstResult_other+1+size where size is the number of literals in b so that
01027     e.g. VallstResult_other+1+2 will be returned when 'axiom' is found to be
01028     equivalent to a binary disjunction.
01029 
01030       Here is a summary:
01031 
01032        - VallstResult_other: new axiom created with name *namePtr.
01033                              For created bin clause p\/q, *namePtr = [p,q,...]
01034        - VallstResult_other+1: 'axiom' true;        *namePtr = NULL
01035        - VallstResult_other+2: 'axiom' <=> p;       *namePtr = [p,...]
01036        - VallstResult_other+3: 'axiom' <=> p\/q;    *namePtr = [p,q,...]
01037        - VallstResult_other+4: 'axiom' <=> b <=> p\/q\/r; *namePtr is a name of
01038                                                     b; array = [p,q,r,...]
01039 
01040     Note that in the above summary, [...] denotes the 'axiom' array provided
01041     as an argument to the function. Hence it is of a temporary nature and may
01042     very well be overwritten (by the owner of the axiom array; indeed,
01043     overwriting it is probably the natural and common thing to do eventually).
01044 
01045       As things are at the moment, no value greater than VallstResult_other+4
01046     will ever be returned; 'axiom' will not be found to be equivalent to e.g.
01047     a disjunction with 4 disjuncts.
01048 
01049       You can use vallst_formulaType() to find out the type of a formula name.
01050 
01051       Getting a name for an axiom is useful e.g. for axiom strengthening:
01052     Assume e.g. that you have got a model for a theory and want to make the
01053     theory stronger, e.g. by incrementing the constant in a more-than axiom, to
01054     see if the stronger theory has a model or not. To do that you can just call
01055     some alter-axiom function to make the theory stronger and keep everything
01056     else, including all derived consequences of the previous theory, as it is.
01057 */
01058 VallstResult vallst_addNamedAxiom( VallstInstance * vi,
01059                                    VallstLiteral * axiom,
01060                                    VallstLiteralN size,
01061                                    VallstFormulaType type,
01062                                    VallstFormulaName * namePtr );
01063 
01064 
01065 /*! Adds c to the constant in a more-than (<), more-than-mult (<*) or
01066     more-than-dis (<\/) axiom.
01067 
01068       Returns VallstResult_parseError if 'name' isn't a name of a formula of
01069     more-than* type or if the level isn't 0. VallstResult_notEnoughMemory is
01070     returned in case not enough memory could be allocated.
01071     VallstResult_proofOfFalse may also be returned. Otherwise, Vallst_other is
01072     returned.
01073 
01074       Note that only strengthening of axioms is supported. 
01075     As a consequence you can't keep Tseitin names of <*-axioms that you alter
01076     because the p\/-a part would get weaker when the constant is increased.
01077     (Intuitively, if you strengthen a and have p<->a and -p is used positively
01078     elsewhere, that would weaken the theory, which isn't supported.)
01079     (If you want to weaken/undo something you can either use search
01080     assumptions; or you can save the theory/state and then later revert back
01081     to the saved theory/state.)
01082 */
01083 VallstResult vallst_alterAxiomIncMT( VallstInstance * vi,
01084                                      VallstFormulaName name,
01085                                      VallstLiteralN c );
01086 
01087 
01088 /*! Like vallst_alterAxiomIncMT() but also adds c to any literal constant d in
01089     'name' that is greater than the current constraint constant. 'name' must
01090     be of <* type.
01091 */
01092 VallstResult vallst_alterAxiomIncMTMKeepAboves( VallstInstance * vi,
01093                                                 VallstFormulaName name,
01094                                                 VallstLiteralN c );
01095 
01096 
01097 /*! Extends the number of variables ready to be used. true is returned iff the
01098     extension failed --- which can only happen due to insufficient memory.
01099 
01100       nrOfVars is meant to be a roughly minimal upper bound for the number of
01101     variables, like in the DIMACS cnf prologue. Any value will work though and
01102     if you don't have any good guess of a roughly minimal upper bound don't use
01103     this function. This function only exists for memory efficiency purposes and
01104     you are never required to use it. If nrOfVars is less than or equal to the
01105     current value, nothing will be done.
01106 
01107       You should, for efficiency reasons, try to use this function if you have
01108     an already built theory (that you e.g. just have decided) and you now want
01109     to extend or change the theory with a known number of variables.
01110 */
01111 bool vallst_extendNrOfVars( VallstInstance * vi, VallstLiteralN nrOfVars );
01112 
01113 
01114 /*! Returns the type of the formula with name formulaName.
01115 
01116       To follow vallst_addNamedAxiom(), vallst_formulaType() will return 1,
01117     representing the true constant, if formulaName is NULL. It will return
01118     VallstFormulaType_clause if *formulaName isn't a type (refer to the
01119     vallst_addNamedAxiom() case where formulaName = axiom = [p,...] where p is
01120     a literal and not a type).
01121 */
01122 VallstFormulaType vallst_formulaType( VallstFormulaName formulaName );
01123 
01124 
01125 //! Returns the constant in a formula of type <, <\/ or <*. Returns
01126 //! VallstLiteralN_parseError if the formula is of wrong type.
01127 VallstLiteralN vallst_getConst( VallstFormulaName name );
01128 
01129 
01130 /*! Returns the full status of literal p. 0 is returned iff p is held false
01131     (i.e. -p is true). 1 is returned iff p is held true. Otherwise p is open
01132     and 2 is returned.
01133 */
01134 int vallst_getFullLitValue( VallstInstance * vi, VallstLiteral p );
01135 
01136 
01137 //! Returns the keep-aboves flag. If true, constant-aboves will be kept aboves
01138 //! e.g. in vallst standalone if constraint constants are to be increased.
01139 //! See vallst_alterAxiomIncMTMKeepAboves() and vallst.c.
01140 bool vallst_getKeepAboves( VallstInstance * vi );
01141 
01142 
01143 /*! Returns the status of literal p. true is returned iff p is held true.
01144     Otherwise false is returned.
01145 */
01146 bool vallst_getLitValue( VallstInstance * vi, VallstLiteral p );
01147 
01148 
01149 //! Returns the number of variables that has been allocated for.
01150 VallstLiteralN vallst_getNrOfVarsAllocated( VallstInstance * vi );
01151 
01152 
01153 /*! Returns the sum of the literal constants in a more-than-mult (<*) formula.
01154     Takes constant time. Returns VallstLiteralN_parseError if the formula is
01155     of the wrong type.
01156 */
01157 VallstLiteralN vallst_getTotalSum( VallstFormulaName name );
01158 
01159 
01160 //! Returns true iff name is a constraint (i.e. of type <, <* or <\/).
01161 //! If name is NULL, false will be returned.
01162 bool vallst_isConstraint( VallstFormulaName name );
01163 
01164 
01165 /*! Tranforms a >=*-formula into a <*-formula using
01166     c >= +{di*pi} <=> +{di}-c-1 < +{di*-pi}.
01167 
01168       For example, [3,2,p,3,q,1,r] (size=7) with type >=*, representing
01169     3 >= 2p+3q+1r, is transformed into the equivalent [2,2,-p,3,-q,1,-r] with
01170     type <*, representing 2 < 2*'-p'+3*'-q'+1*'-r', where p, q,... are numbers.
01171 
01172       Returns true iff +{di}-c-1 < 0, i.e. c >= +{di}, in which case a isn't
01173     altered. I.e. if true is returned, the formula a is a tautology and can
01174     be ignored.
01175 */
01176 bool vallst_lessThanEqMultToMoreThanMult( VallstLiteral * a,
01177                                           VallstLiteralN size );
01178 
01179 
01180 /*! Tranforms a >=-formula into a <-formula using
01181     c >= p1+...+pn <=> n-c-1 < +{-pi}.
01182 
01183       For example, [2,p,q,r] (size=4) with type >=, representing 2 >= p+q+r,
01184     is transformed into the equivalent [0,-p,-q,-r] with type <, representing
01185     0 < '-p'+'-q'+'-r', where p, q,... are numbers.
01186 
01187       Returns true iff n-c-1 < 0, i.e. c >= n, in which case a isn't altered.
01188     I.e. if true is returned, the formula a is a tautology and can be ignored.
01189 */
01190 bool vallst_lessThanEqToMoreThan( VallstLiteral * a,
01191                                   VallstLiteralN size );
01192 
01193 
01194 //! Returns -p, i.e. the negation of the literal p.
01195 VallstLiteral vallst_neg( VallstLiteral p );
01196 
01197 
01198 
01199 /*
01200   vallst_newVar               -- Returns a new variable ready to be used.
01201 */
01202 
01203 
01204 
01205 //! Sets flag. If true, constant-aboves will be kept aboves
01206 //! e.g. in vallst standalone if constraint constants are to be increased.
01207 //! See vallst_alterAxiomIncMTMKeepAboves() and \ref vallst.c.
01208 void vallst_setKeepAboves( VallstInstance * vi, bool b );
01209 
01210 
01211 /*! Sets the main constant for an (a)tsp. This value will be used when the
01212     formula is parsed and nowhere else. The edge sum formula will be
01213     (min) c >= d0*p0 + ... + dn*pn. Any value