Mercurial > dylan
view proof.org @ 6:b2f55bcf6853
fixed comments
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 28 Oct 2011 04:56:15 -0700 |
parents | b4de894a1e2e |
children |
line wrap: on
line source
1 #+TITLE: WFF 'n Proof2 #+AUTHOR: Dylan Holmes3 #+MATHJAX: align:"left" mathml:t path:"../MathJax/MathJax.js"4 #+STYLE: <link rel="stylesheet" type="text/css" href="../css/aurellem.css" />5 #+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t6 #+SETUPFILE: ../templates/level-0.org7 #+INCLUDE: ../templates/level-0.org8 #+BABEL: :noweb yes :results verbatim :cache yes11 * Introduction12 WFF 'n Proof is a competitive dice game designed to teach logic. The13 game is played with several dice whose faces are marked with logical14 symbols; the goal is to arrange the dice into /well-formed formulas/ (WFFs) \mdash{}15 expressions that are syntactically correct\mdash{}then to manipulate16 these formulas to form valid proofs.18 ** About the dice19 WFF and Proof has small cubes and large cubes which you use like20 dice. The small cubes have lower-case letters =p=, =q=, =r=, =s=, =i=,21 and =o= inscribed on their faces, whereas the big cubes have22 upper-case letters =C=, =A=, =K=, =E=, =N= and =R= on their faces. The23 lower-case letters stand for /propositions/ that can be either true or24 false, whereas the25 upper-case letters stand for certain logical connectives:28 | Symbol | Meaning |29 |--------+---------|30 | =C= | Implies |31 | =A= | Or |32 | =K= | And |33 | =E= | Equals |34 |--------+---------|35 | =N= | Not |37 ** Well-formed formulas38 An expression is a row of dice arranged left-to-right. An expression39 is a well-formed formula (WFF) if and only if40 - It is a =p=, =q=, =r=, or =s=; or41 - It is an =N= followed by a WFF; or42 - It is a =C=, =A=, =K=, or =E= followed by two WFFs.44 (Both the lower-case letters =i= and =o= and the upper-case letter =R=45 are special, and are not used in forming WFFs)47 * Games you can play with WFF 'n Proof48 ** Shake a WFF49 Shake a WFF is the simplest game; it teaches you to build and to50 recognize well-formed formulas, skills that are fundamental to more advanced games.52 #This game is for two or three players.53 Each player starts the game with two small cubes and one big cube;54 these cubes constitute each player's hand. Divide the remaining cubes55 evenly among the players so that each player has a pile of unused56 cubes. Also allow space for completed WFFs.58 At the start of each turn, all of the players toss their dice59 simultaneously; each player races to build the longest WFF possible60 out of his own dice. As soon as a player is finished\mdash{}either he61 has constructed the longest WFF possible or has found that it is impossible to make a WFF\mdash{}he62 calls out \ldquo{}WFF!\rdquo{} or \ldquo{}No WFF!\rdquo{}.64 When a player calls out \ldquo{}WFF!\rdquo{} or \ldquo{}No65 WFF!\rdquo{}, the other players must stop to validate the caller's66 claim. When a player confirms that the claim is correct, that player67 calls out \ldquo{}Check!\rdquo{}. Now, either all the players believe68 that the claim is correct, or they do not.71 - If all the players confirm that the claim is correct, the caller72 puts his WFF in the area for completed WFFs, then replenishes his73 supply of cubes by replacing each of the cubes in his WFF with a74 cube from his unused-cubes pile (each big cube must be replaced with75 a big cube, and each small cube must be replaced with a small cube),76 then takes an additional cube from his pile and receives one77 point. The turn then ends.79 - If, when checking the caller's claim, a player believes that the80 claim was made in error, the player calls out81 \ldquo{}Challenge!\rdquo{}, then points out the mistake:82 - If the caller has presented an expression that is not a WFF, the83 challenger shows that it is not a WFF.84 - If the caller has presented a WFF that is not the longest possible,85 the challenger shows how to make a longer WFF from the caller's86 cubes.87 - If it is possible to make a WFF from the caller's cubes but the88 caller claims it is impossible, the challenger shows how to make a89 WFF from the caller's cubes.90 The other players verify this challenge. If the challenge was made91 correctly, the challenging player wins a point and gains an extra92 cube from his pile whereas the calling player must return a cube to his93 pile. If the challenge was made wrongly, the challenger must return a94 cube to his pile. In either case, the turn ends.96 After the turn ends, the player can play another turn. The game ends97 when a certain number of cubes are in the area for completed WFFs;98 this number can be decided before the game begins.100 One final note is the rule for cubes:101 #+begin_quote102 *Cube Rule:* A player's hand must have either the same number of big103 cubes and small cubes, or one more small cube than big cube. When104 taking cubes from or returning cubes to your unusued cubes pile, you105 must make sure to follow this rule.106 #+end_quote113 * Misc115 #+srcname: proof116 #+begin_src clojure117 (ns wff.proof)119 (defn arity[x]120 (first121 (keep-indexed122 (fn[i f](if (nil? (f x)) nil i))123 [#{'p 'q 'r 's}124 #{'N}125 #{'C 'A 'K 'E}])))127 (defn wff?128 [& symbols]129 ((fn[stack symbols]130 ;;(println stack symbols)131 (if (or(empty? symbols)(empty? stack))132 (and(empty? symbols)(empty? stack))133 (let [n (arity (first symbols))]134 (if (nil? n)135 false136 (recur (concat (rest stack) (repeat n '*)) (rest symbols))))))137 '(*) symbols))139 #+end_src146 * COMMENT tangle148 #+begin_src clojure :tangle ./proof.clj149 <<proof>>150 <<other-proof>>151 #+end_src