Logic - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Logic : Boolean : Logic Package : Logic/Random

Logic

 Random
 construct a random Boolean function

 Calling Sequence Random(alpha, opts)

Parameters

 alpha - list or set of symbols representing the alphabet of literals opts - (optional) options, as specified below.

Options

 The opts parameter is used to specify one or more additional properties of the Array. If a property is included in the calling sequence, it must be an equation of the form keyword = value. The permissible options are described in this section.
 clauses=c
 Specifies the number of clauses in the generated formula. The default is the size of the alphabet alpha.
 form=fname
 Specifies the form of boolean canonical formula to produce. Valid options are DNF (disjunctive normal form), CNF (conjunctive normal form), or MOD2 (arithmetic modulo 2). The default is DNF.
 literals=l
 Specifies the number of literals appearing in each clause. A literal in this context is either a symbol from the alphabet or the negation of such a symbol. The default is the size of the alphabet alpha.

Description

 • The Random command returns a random Boolean expression using the symbols from alpha.
 • The Boolean expression returned is in a specific canonical form with respect to the symbols in alpha. By default, disjunctive normal form is used.

Examples

 > $\mathrm{with}\left(\mathrm{Logic}\right):$
 > $\mathrm{Random}\left(\left\{a,b\right\}\right)$
 $\left({a}{\wedge }{b}\right){\vee }\left({¬}{a}{\wedge }{¬}{b}\right)$ (1)
 > $\mathrm{Random}\left(\left[X,Y,Z\right]\right)$
 $\left({X}{\wedge }{Y}{\wedge }{Z}\right){\vee }\left({Y}{\wedge }{¬}{X}{\wedge }{¬}{Z}\right){\vee }\left({¬}{X}{\wedge }{¬}{Y}{\wedge }{¬}{Z}\right)$ (2)
 > $\mathrm{Random}\left(\left[a,b\right],\mathrm{form}=\mathrm{CNF}\right)$
 $\left({a}{\vee }{¬}{b}\right){\wedge }\left({¬}{a}{\vee }{¬}{b}\right)$ (3)
 > $\mathrm{Random}\left(\left[a,b,c\right],\mathrm{form}=\mathrm{CNF},\mathrm{clauses}=10,\mathrm{literals}=3\right)$
 $\left({a}{\vee }{b}{\vee }{c}\right){\wedge }\left({a}{\vee }{b}{\vee }{¬}{c}\right){\wedge }\left({a}{\vee }{c}{\vee }{¬}{b}\right){\wedge }\left({a}{\vee }{¬}{b}{\vee }{¬}{c}\right){\wedge }\left({b}{\vee }{c}{\vee }{¬}{a}\right){\wedge }\left({¬}{a}{\vee }{¬}{b}{\vee }{¬}{c}\right)$ (4)
 > $\mathrm{Random}\left(\left\{a,b,c\right\},\mathrm{form}=\mathrm{MOD2}\right)$
 ${a}{}{b}{}{c}{+}{b}{}{c}{}\left({a}{+}{1}\right){+}{c}{}\left({a}{+}{1}\right){}\left({b}{+}{1}\right)$ (5)
 Compatibility

 See Also

## Was this information helpful?

 Please add your Comment (Optional) E-mail Address (Optional) What is ? This question helps us to combat spam