Predicates and Logic

From Observation Notes Analysis:
7 + 3 reporting 10 Reporter blocks can report different kinds of values. The plus block, for example, reports a number. Predicates are blocks that always report a Boolean value (either true or false).
    Try to evaluate these without using snap, and then check your answers by building the blocks.
  1. Determine what each of these Boolean expressions will report (without using snap):
    1. not (false)
    2. 22 + 78 = 100
    3. -37 > 34
    4. Talk with Another Pair
    5. 2.17 > 2.7
    6. true and false
    7. true and not (false)
    8. true or false
    9. false or not (false)
  2. Determine what each of these Boolean expressions will report:
    1. not ((55 + 44) = 100)
    2. ((55 + 44) = 100) or ((55 + 44) < 100)
    3. (round 4.7) = 4.7

Now, you will create some more tools that you may use often, especially for complicated programming tasks.

  1. Reopen your "U2L1-Predicates" file.
  2. snap has a "greater than" operator (>), an "equal" operator (=), and a "less than" operator (<) built in, but doesn't have a "greater than or equal to" (>=) operator.
    5 >= 3 5 >= 5 3 >= 5

    Build a greater than or equal to b and test it well to make sure it does what you expect.

    creating an infix predicate

    • When you type the block's title in the Make a block dialog, choose the hexagonal predicate block shape.
    • To set the block's name >= between the two input slots, use the left plus sign in the Block Editor. left plus sign
    • You may find one or more of these Boolean operators helpful:

      and, or, not blocks

    There are several correct ways to do this! As long as your block gives the right true and false answers, it's correct.

  3. Is this on the AP? If not, do we need to teach this vocabulary?
    Operators like a times b that stand in between their two inputs are called infix operators. Operators like sqrt of that stand before their inputs are called prefix operators. When we write n! to mean "n factorial," the "!" is a postfix operator—it comes after its input n factorial
 
  1. Build a predicate that tests to see if its input is an integer. integer?-4=(with-result-true) integer?-4-point-1(with-result-false)

    You may find round a number useful.