-
Notifications
You must be signed in to change notification settings - Fork 221
Expand file tree
/
Copy pathboolean-expr-docs.factor
More file actions
128 lines (112 loc) · 3.3 KB
/
Copy pathboolean-expr-docs.factor
File metadata and controls
128 lines (112 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
! Copyright (C) 2018 Alexander Ilin.
! See https://factorcode.org/license.txt for BSD license.
USING: arrays help.markup help.syntax kernel ;
IN: boolean-expr
ABOUT: "boolean-expr"
ARTICLE: "boolean-expr" "Boolean expressions"
"The " { $vocab-link "boolean-expr" } " vocab demonstrates the use of Unicode symbols in source files and multi-method dispatch."
;
HELP: dnf
{ $values
{ "expr" □ }
{ "dnf" array }
}
{ $description "Convert the " { $snippet "expr" } " to Disjunctive Normal Form (DNF), i.e. an array of subexpressions, each not containing disjunctions. See " { $url "https://en.wikipedia.org/wiki/Disjunctive_normal_form" } "." }
{ $examples
{ $example "USING: boolean-expr prettyprint ;"
"X Y Z ⋀ ⋀ dnf ."
"{ { X Y Z } }"
}
{ $example "USING: boolean-expr prettyprint ;"
"X Y Z ⋁ ⋁ dnf ."
"{ { X } { Y } { Z } }"
}
} ;
HELP: expr.
{ $values
{ "expr" □ }
}
{ $description "Print the expression followed by newline." }
{ $examples
{ $example "USING: boolean-expr ;"
"X Y ⋁ X ¬ Y ⋀ ⋀ op."
"((X ⋀ (¬X ⋀ Y)) ⋁ (Y ⋀ (¬X ⋀ Y)))"
}
} ;
HELP: op.
{ $values
{ "expr" □ }
}
{ $description "Print the expression." }
{ $examples
{ $example "USING: boolean-expr ;"
"X Y ⋁ X ¬ Y ⋀ ⋀ op."
"((X ⋀ (¬X ⋀ Y)) ⋁ (Y ⋀ (¬X ⋀ Y)))"
}
} ;
{ expr. op. } related-words
HELP: satisfiable?
{ $values
{ "expr" □ }
{ "?" boolean }
}
{ $description "Return " { $link t } " if the " { $snippet "expr" } " can be true." }
{ $examples
{ $example "USING: boolean-expr prettyprint ;"
"⊤ satisfiable? ."
"t"
}
{ $example "USING: boolean-expr prettyprint ;"
"⊥ satisfiable? ."
"f"
}
{ $example "USING: boolean-expr prettyprint ;"
"X X ¬ ⋀ satisfiable? ."
"f"
}
{ $example "USING: boolean-expr prettyprint ;"
"X Y ⋁ X ¬ Y ¬ ⋀ ⋀ satisfiable? ."
"f"
}
{ $example "USING: boolean-expr prettyprint ;"
"X Y ⋁ X ¬ Y ⋀ ⋀ satisfiable? ."
"t"
}
} ;
HELP: ¬
{ $class-description "Logical negation (NOT)." $nl
{ $snippet "¬(¬A) " { $link ≣ } " A" } "."
} ;
HELP: →
{ $values
{ "x" □ } { "y" □ }
{ "expr" □ }
}
{ $description "Material implication (if..then)." $nl
{ $snippet "x→y" } " " { $link ≣ } " " { $link ¬ } "x" { $link ⋁ } "y"
} ;
HELP: ≣
{ $values
{ "x" □ } { "y" □ }
{ "expr" □ }
}
{ $description "Material equivalence (if and only if)." $nl
{ $snippet "(x≣y) ≣ ((x" } { $link ⋀ } { $snippet "y) " }
{ $link ⋁ } { $snippet " (" } { $link ¬ } { $snippet "x" } { $link ⋀ } { $link ¬ } { $snippet "y))" }
} ;
HELP: ⊕
{ $values
{ "x" □ } { "y" □ }
{ "expr" □ }
}
{ $description "Exclusive disjunction (XOR)." } ;
HELP: ⊤
{ $class-description "Logical tautology. This statement is unconditionally true." } ;
HELP: ⊥
{ $class-description "Logical contradiction. This statement is unconditionally false." } ;
HELP: ⋀
{ $class-description "Logical conjunction (AND)." } ;
HELP: ⋁
{ $class-description "Logical disjunction (OR)." } ;
HELP: □
{ $class-description "A union class of all classes defined in this vocab. In methods signatures it stands for \"any variable or expression\"." } ;