# HG changeset patch # User Adam Chlipala # Date 1223223139 14400 # Node ID 15e2b3485dc4d68673e0d6fe3c14303c0096ba91 # Parent f295a64bf9fd715a9a7530dc722563fdaae6fb8e Subset exercises diff -r f295a64bf9fd -r 15e2b3485dc4 src/Subset.v --- a/src/Subset.v Sun Oct 05 11:34:09 2008 -0400 +++ b/src/Subset.v Sun Oct 05 12:12:19 2008 -0400 @@ -758,3 +758,27 @@ : {t : type | hasType (Plus (Nat 1) (Bool false)) t} + {(forall t : type, ~ hasType (Plus (Nat 1) (Bool false)) t)} ]] *) + + +(** * Exercises *) + +(** All of the notations defined in this chapter, plus some extras, are available for import from the module [MoreSpecif] of the book source. + +%\begin{enumerate}%#
    # +%\item%#
  1. # Write a function of type [forall n m : nat, {n <= m} + {n > m}]. That is, this function decides whether one natural is less than another, and its dependent type guarantees that its results are accurate.#
  2. # + +%\item%#
  3. # %\begin{enumerate}%#
      # + %\item%#
    1. # Define [var], a type of propositional variables, as a synonym for [nat].#
    2. # + %\item%#
    3. # Define an inductive type [prop] of propositional logic formulas, consisting of variables, negation, and binary conjunction and disjunction.#
    4. # + %\item%#
    5. # Define a function [propDenote] from variable truth assignments and [prop]s to [Prop], based on the usual meanings of the connectives. Represent truth assignments as functions from [var] to [bool].#
    6. # + %\item%#
    7. # Define a function [bool_true_dec] that checks whether a boolean is true, with a maximally expressive dependent type. That is, the function should have type [forall b, {b = true} + {b = true -> False}]. #
    8. # + %\item%#
    9. # Define a function [decide] that determines whether a particular [prop] is true under a particular truth assignment. That is, the function should have type [forall (truth : var -> bool) (p : prop), {propDenote truth p} + { ~propDenote truth p}]. This function is probably easiest to write in the usual tactical style, instead of programming with [refine]. [bool_true_dec] may come in handy as a hint.#
    10. # + %\item%#
    11. # Define a function [negate] that returns a simplified version of the negation of a [prop]. That is, the function should have type [forall p : prop, {p' : prop | forall truth, propDenote truth p <-> ~propDenote truth p'}]. To simplify a variable, just negate it. Simplify a negation by returning its argument. Simplify conjunctions and disjunctions using De Morgan's laws, negating the arguments recursively and switching the kind of connective. [decide] may be useful in some of the proof obligations, even if you do not use it in the computational part of [negate]'s definition. Lemmas like [decide] allow us to compensate for the lack of a general Law of the Excluded Middle in CIC.#
    12. # +#
    #%\end{enumerate}% #
  4. # + +%\item%#
  5. # Implement the DPLL satisfiability decision procedure for boolean formulas in conjunctive normal form, with a dependent type that guarantees its correctness. An example of a reasonable type for this function would be [forall f : formula, {truth : tvals | formulaTrue truth f} + {forall truth, ~formulaTrue truth f}]. Implement at least "the basic backtracking algorithm" as defined here: + %\begin{center}\url{http://en.wikipedia.org/wiki/DPLL_algorithm}\end{center}% + #
    http://en.wikipedia.org/wiki/DPLL_algorithm
    # +It might also be instructive to implement the unit propagation and pure literal elimination optimizations described there or some other optimizations that have been used in modern SAT solvers.#
  6. # + +#
#%\end{enumerate}% *)