Internals
PAndQ.union_typeof
— Functionunion_typeof(xs)
Equivalent to Union{map(typeof, xs)...}
.
Solvers
Z3
PAndQ.Z3
— ModuleZ3
This module provides an interface to z3_jll.jl.
PAndQ.Z3.Library
— ModuleLibrary
PAndQ.Z3.add_clause
— Functionadd_clause(context, solver, clause)
PAndQ.Z3.Solutions
— TypeSolutions
Base.IteratorSize
— MethodIteratorSize(::Type{Solutions})
Examples
julia> Base.IteratorSize(PAndQ.Z3.Solutions)
Base.SizeUnknown()
Base.eltype
— Methodeltype(::Type{Solutions})
The type of the elements generated by a Solutions
iterator.
Examples
julia> eltype(PAndQ.Z3.Solutions)
Vector{Bool} (alias for Array{Bool, 1})
Base.isdone
— Methodisdone
Base.iterate
— Methoditerate
PicoSAT
PAndQ.PicoSAT
— ModulePicoSAT
This module provides an interface to libpicosat_jll.jl.
Library
PAndQ.PicoSAT.picosat_init
— Functionpicosat_init()
Construct a new PicoSAT instance and return a pointer to it.
PAndQ.PicoSAT.picosat_reset
— Functionpicosat_reset(pico_sat)
Destruct the pico_sat
instance.
PAndQ.PicoSAT.picosat_add
— Functionpicosat_add(pico_sat, literal)
Append the literal
to the pico_sat
instance's current disjunctive clause.
PAndQ.PicoSAT.picosat_adjust
— Functionpicosat_adjust
PAndQ.PicoSAT.picosat_variables
— Functionpicosat_variables(pico_sat)
Return the number of unique atoms in the pico_sat
instance.
PAndQ.PicoSAT.picosat_print
— Functionpicosat_print(pico_sat, file)
Write the DIMACS format of the pico_sat
instance's proposition to the given file
.
PAndQ.PicoSAT.picosat_sat
— Functionpicosat_sat(pico_sat, limit)
Search for a satisfiable assignment of the pico_sat
instance's proposition and return 0
, 10
, or 20
if the status is unknown, satisfiable, or unsatisfiable, respectively.
PAndQ.PicoSAT.picosat_deref
— Functionpicosat_deref(pico_sat, atom)
Return the assignment of the atom
, where 1
, -1
, and 0
indicate true
, false
, and unknown, respectively.
This function must be called after verifying that the status of picosat_sat
is satisfiable.
Utilities
PAndQ.PicoSAT.add_clause
— Functionadd_clause(pico_sat, clause)
Mutate the pico_sat
instance's proposition to be the conjunction of itself and the disjunctive clause
.
PAndQ.PicoSAT.initialize
— Functioninitialize(clauses, n)
Return a PicoSAT pointer with its proposition being a conjunction of the disjunctive clauses
.
PAndQ.PicoSAT.Solutions
— TypeSolutions
Solutions(clauses)
A stateful iterator of valuations that satisfy the given proposition.
Calling finalize
on this iterator will first check whether it has already been finalized. If not, it will call picosat_reset
on its PicoSAT pointer and set the pointer equal to C_NULL
.
Base.eltype
— Methodeltype(::Type{Solutions})
The type of the elements generated by a Solutions
iterator.
Examples
julia> eltype(PAndQ.PicoSAT.Solutions)
Vector{Bool} (alias for Array{Bool, 1})
Base.IteratorSize
— MethodIteratorSize(::Type{Solutions})
Since counting the number of Solutions
to a proposition is intractable, its IteratorSize
is Base.SizeUnknown
.
Examples
julia> Base.IteratorSize(PAndQ.PicoSAT.Solutions)
Base.SizeUnknown()
Base.isdone
— Methodisdone(solutions::Solutions, pico_sat = solutions.pico_sat)
Return a Bool
ean whether the pico_sat
instance can yield any more solutions without advancing the Solutions
iterator.
Finalize the iterator if it has not yet been finalized and is done.
Base.iterate
— Methoditerate(solutions::Solutions, pico_sat = solutions.pico_sat)
If the status of pico_sat
is satisfiable, return a Tuple
of the current solution and pico_sat
. Otherwise, finalize
the solutions
and return nothing
.
PAndQ.PicoSAT.print_dimacs
— Functionprint_dimacs(io, clauses, n)
Print the DIMACS format of the conjunctive clauses
.
Examples
julia> PAndQ.PicoSAT.print_dimacs(stdout, [[-1, -2], [1, 2]], 2)
p cnf 2 2
-1 -2 0
1 2 0
julia> PAndQ.PicoSAT.print_dimacs(stdout, [[1, -2], [-1, 2]], 2)
p cnf 2 2
1 -2 0
-1 2 0
Interface
PAndQ.Interface.InterfaceError
— TypeInterfaceError{F <: Function, O <: Operator} <: Exception
InterfaceError(::F, ::O)
An Exception
indicating that the function of type F
has not been implemented for the value of type T
.
Base.showerror
— Functionshowerror(::IO, ::InterfaceError)
Print a message indicating to implement a method of an interface.
PAndQ.Interface.@interface
— Macro@interface(f, xs...)
Define a fallback method that throws an InterfaceError
.
Operators
PAndQ.NullaryOperator
— TypeNullaryOperator
The Union
of Nullary Operators.
PAndQ.UnaryOperator
— TypeUnaryOperator
The Union
of Unary Operators.
PAndQ.BinaryOperator
— TypeBinaryOperator
The Union
of Binary Operators.
PAndQ.NaryOperator
— TypeNaryOperator
The Union
of Nary Operators.
PAndQ.AndOr
— TypePropositions
PAndQ.Kind
— TypeKind
Types
PAndQ.AbstractSyntaxTree
— TypeAbstractSyntaxTree
A proposition represented by an abstract syntax tree.
See also Operator
.
Examples
julia> PAndQ.AbstractSyntaxTree(⊤)
⊤
julia> @atomize PAndQ.AbstractSyntaxTree(¬, [p])
¬p
julia> @atomize PAndQ.AbstractSyntaxTree(and, [PAndQ.AbstractSyntaxTree(p), PAndQ.AbstractSyntaxTree(q)])
p ∧ q
AbstractTrees.jl
AbstractTrees.children
— Functionchildren(::AbstractSyntaxTree)
Return an iterator over the child nodes of the given proposition.
See also AbstractSyntaxTree
.
Examples
julia> @atomize PAndQ.children(¬p)
1-element Vector{PAndQ.AbstractSyntaxTree}:
p
julia> @atomize PAndQ.children(p ∧ q)
2-element Vector{PAndQ.AbstractSyntaxTree}:
p
q
AbstractTrees.nodevalue
— Functionnodevalue(::AbstractSyntaxTree)
Return the Operator
of the proposition's root node.
See also AbstractSyntaxTree
.
Examples
julia> @atomize PAndQ.nodevalue(¬p)
¬
julia> @atomize PAndQ.nodevalue(p ∧ q)
∧
AbstractTrees.printnode
— Functionprintnode(::IO, ::Union{Operator, AbstractSyntaxTree}; kwargs...)
Print the representation of the proposition's root node.
See also Operator
and AbstractSyntaxTree
.
Examples
julia> @atomize PAndQ.printnode(stdout, p)
p
julia> @atomize PAndQ.printnode(stdout, ¬p)
¬
julia> @atomize PAndQ.printnode(stdout, p ∧ q)
∧
Utility
Base.:==
— Function::AbstractSyntaxTree == ::AbstractSyntaxTree
Base.hash
— Functionhash(::AbstractSyntaxTree, ::UInt)
PAndQ.deconstruct
— Functiondeconstruct(p)
Return (nodevalue(p), children(p))
.
See also nodevalue
and children
.
Examples
julia> @atomize PAndQ.deconstruct(p)
(PAndQ.AbstractSyntaxTree(:p), PAndQ.AbstractSyntaxTree[])
julia> @atomize PAndQ.deconstruct(¬p)
(not, PAndQ.AbstractSyntaxTree[PAndQ.AbstractSyntaxTree(:p)])
julia> @atomize PAndQ.deconstruct(p ∧ q)
(and, PAndQ.AbstractSyntaxTree[PAndQ.AbstractSyntaxTree(:p), PAndQ.AbstractSyntaxTree(:q)])
PAndQ.child
— FunctionPAndQ.atomize
— Functionatomize(x)
If x
is a symbol, return an expression that instantiates it as a variable if it is undefined in the caller's scope. If isexpr(x, :$)
, return an expression that instantiates it as a constant. If x
is a different expression, traverse it with recursive calls to atomize
. Otherise, return x.
PAndQ.distribute
— Functiondistribute(p)
Given a proposition in negation normal form, return that proposition in conjunction normal form.
PAndQ.prune
— Functionprune(p, atoms = AbstractSyntaxTree[], mapping = Dict{AbstractSyntaxTree, Int}())
PAndQ.reconstruct
— Functionreconstruct(clauses, atoms)
Printing
Semantics
Base.convert
— Functionconvert(::Type{<:AbstractSytnaxTree}, p)
See also AbstractSyntaxTree
.
Base.promote_rule
— Functionpromote_rule