other
(in-package "SATLINK")
other
(include-book "std/util/define" :dir :system)
other
(include-book "std/basic/defs" :dir :system)
other
(include-book "std/basic/arith-equivs" :dir :system)
other
(include-book "centaur/fty/fixequiv" :dir :system)
other
(set-tau-auto-mode nil)
other
(local (add-default-post-define-hook :fix))
other
(define varp (x) :parents (cnf) :short "Representation of a Boolean variable." :long "<p>A variable is now represented as just a natural number, and the abstract data type wrapper described below is no longer used (we found it too hard to reason about). We're preserving the documentation below for reference, but it's no longer true.</p> <p>Think of a <b>VARIABLE</b> as an abstract data type that represents a Boolean variable. A variable has an <i>index</i> that can be used to distinguish it from other variables. The interface for working with variables is simply:</p> <dl> <dt>@(call varp) → @('bool')</dt> <dd>Recognize valid identifiers.</dd> <dt>@('(make-var index)') → @('id')</dt> <dd>Construct an identifier with the given given a natural number index.</dd> <dt>@('(var->index id)') → @('index')</dt> <dd>Get the index from an identifier.</dd> </dl> <p>In the implementation, variables are nothing more than natural numbers. That is, @(see varp) is just @(see natp), while @('make-var') and @('var->index') are logically just @(see nfix) and in the execution are the identity.</p> <p>Why, then, bother with a variable type at all? We use (for efficiency) integer encodings of related data types like variables and literals. Treating these as separate types helps us avoid confusing them for one another when we write programs.</p> <p>A very nice presentation of this idea is found in <a href='http://blog.ezyang.com/2010/08/type-kata-newtypes/'>Type Kata: Distinguishing different data with the same underlying representation</a>, a blog post by Edward Z. Yang.</p>" (natp x) :returns (bool booleanp :rule-classes :tau-system) /// (defthm varp-compound-recognizer (equal (varp x) (natp x)) :rule-classes :compound-recognizer))
other
(add-macro-alias var-fix nfix)
other
(add-macro-alias var-equiv nat-equiv)
other
(defsection varp-reasoning :parents (varp) :short "Basic rules for reasoning about identifiers.")