Page Numbers: Yes First Page: 1
Heading:
November 10, 1976 7:04 PM[newKRL]<winograd>cryptunits.krl1
Units for Cryptarithmetic program (unfinished)
# Blank
self/Instance: A Letter with value = 0
# Column↑1
1:WhenAllKnown({topLetter, bottomLetter, sumLetter}, LISP (ClassifyColumn))
WhenAnyDescribed({carryIn, carryOut, sum}, LISP (CheckPossibilities))
WhenAnyKnown({carryIn, carryOut, sum},
LispApply (LISP ProcessColumn, My self))
self:↑2 A Summation with sum = My sum
2: Comment("further described in doing ClassifyColumn")
leftNeighbor: ↑carry1: A Column with
carryIn = Using My carryOut
10 ~ 1
0 ~ 0
rightNeighbor: ↑carry2: A Column with
carryOut = Using My carryIn
1 ~ 10
0 ~ 0
carryIn:↑3 3: WhenKnown(DescribeEval(My leftNeighbor, My carry1))
An Integer; Or(0, 1)
carryOut:↑4 4:WhenKnown(DescribeEval(My rightNeighbor, My carry2))
WhenKnown(DescribeEval(My sum, My sumBound))
An EvenNumber; Or(0, 1)
sum:↑5 5: WhenKnown(DescribeEval(My sumLetter, My sum1))
↑sumBound: Using My carryOut
1 ~ AtLeast(10)
0 ~ AtMost(9)
An Integer
MemberOf(IntegerInterval(0, 19))
topLetter: A Letter
bottomLetter: A Letter
sumLetter: ↑sum1:A Letter with value = OnesDigit(My sum)
# ColumnDescription↑1
1:Comment("The following trigger causes each ColumnDescription unit (e.g.
OneBlank) to have a trigger which will be called when it is used
as a template for a column. TryStrategy in turn applies The
matchDesc to get The bindings.")
WhenIdentified(LISPApply (LISP AddTrigger,
\WhenIdentified (LISP (TryStrategy))))
InitialStrategy: A LispAction
RepeatableStrategies: SetOf(\A LispAction)
# EvenNumber↑1
1: ToTestExistence (LISP (PROG((x (Item (this instance)))
(RETURN (AND (NUMBERP X)
(EQ (IREMAINDER x 2) 0)))))
self: An Integer
# Hypothesis
base: A Thing
assumption: A Description
status: Or(Impossible, Possible)
# NeitherAddendKnown↑11: WhenIdentified (LISP (TryStrategy))
self/Instance: A ColumnDescription with
strategy = LISP ProcessNeitherKnown
# OddNumber↑11: ToTestExistence (LISP (PROG((x (Item (this instance)))
(RETURN
(AND (NUMBERP X)
(EQ (IREMAINDER x 2)
1)))))
self: An Integer
# OneAddendKnown ↑11: WhenIdentified (LISP (TryStrategy))
self/Instance: A ColumnDescription with
strategy = LISP ProcessOneKnown
knownDigit: An Integer
mysteryLetter: A Letter
# NoBlanks↑11: WhichIs FurtherSpecified \Column
WhenIdentified (LISP (TryStrategy))
self/Instance: A ColumnDescription
self:A Column with
topLetter = Not(Blank)
bottomLetter = Not(Blank)
A Summation with
summands = {My carryIn,
The value from a Letter thatIs My topLetter,
The value from a Letter thatIs My bottomLetter}
# OneBlank↑11:WhichIs FurtherSpecified \Column
WhenIdentified (LISP (TryStrategy))
self/Instance: A ColumnDescription with
strategy = LISP ProcessOneBlank
matchDesc = My mDesc
self: ↑mDesc: Or ([A Column with topLetter = Blank
A Sum with
summands = {My carryIn,
The value from a Letter
thatIs My bottomLetter}]
[A Column with bottomLetter = Blank
A Sum with
summands = {My carryIn,
The value from a Letter
thatIs My topLetter}])
# TwoBlanks↑11:WhichIs FurtherSpecified \Column
WhenIdentified (LISP (TryStrategy))
self/Instance: A ColumnDescription with
strategy = LISP ProcessTwoBlanks
self: A Column with
topLetter = Blank
bottomLetter = Blank
A Column with
sum = 1
carryIn = 1
A Summation with summands = {My carryIn}
# Problem↑11:WhenIdentified (LISP (SETQ currentProblem (this instance)))
WhenAllKnown ({topWord, bottomWord, sumWord},
LISP (SetUpProblem))
topWord: A String
bottomWord: A String
sumWord: A String
columns: SequenceOf(\A Column)
freeDigits:↑2 SetOf(\An Integer)
2: A DecreasingSet with initialValue = IntegerInterval(0, 9)
lettersAppearing: SetOf(\A Letter); A Set with cardinality = 10
freeLetters:↑3
SetOf(\A Letter)
SubsetOf(My lettersAppearing)
3: An EliminationSet with
initialValue = My lettersAppearing
filter = \Not(CanGetIt (\The value from
A Letter thatIs This element))
# SumEqualsAddend↑11:WhichIs FurtherSpecified \Column
WhenIdentified (LISP (TryStrategy))
WhenDescribed (LISPApply (LISP ProcessSumEq,
My self))
self/Instance: A ColumnDescription with
strategy = LISP ProcessSumEq
carryOut: ↑22: WhenKnown (Apply [My loneDesc] My loneLetter)]]
***fix***[WhenKnown (Apply [My loneDesc] My loneLetter)]]
loneLetter: ↑loneDesc: A Letter
Using My carryOut
0 ~ A Letter with value = 0
10 ~ A Letter with value = 9
doubledLetter: A Letter
# Summation
summands: SetOf(\An Integer)
sum: An Integer
# Variable
possibleValues:
newConstraint: