1 | !7 |
2 | |
3 | replace Var with ValuelessVar. |
4 | replace VarMap with Map<Var, O>. |
5 | |
6 | abstract sclass Prop implements IStatement, IFieldsToList {} |
7 | |
8 | static withToList record $HappensBefore$<A, B>(A event1, B event2) extends Prop {} |
9 | static withToList record $HappensAtDay$<A, B>(A event, B y) extends Prop {} |
10 | static withToList record $LessThan$<A, B>(A x, B y) extends Prop {} |
11 | static withToList record $BiggerThanOrEqualTo$<A, B>(A x, B y) extends Prop {} |
12 | static withToList record $AnyIntBiggerThan(O x) {} |
13 | static withToList record $is$(O a, O b) {} |
14 | |
15 | // full define $LessThan(int x, int y) = x < y; |
16 | static Bool checkProposition(Prop p) { |
17 | if p is $LessThan$(int x, int y) { ret x < y; } |
18 | if p is $BiggerThanOrEqualTo$(int x, int y) { |
19 | ret not(checkProposition($LessThan$(x, y))); |
20 | } |
21 | null; |
22 | } |
23 | |
24 | static VarMap fillVariablesInProposition(Prop p) { |
25 | if p is $LessThan$(int x, Var y) { |
26 | $AnyIntBiggerThan |
27 | } |
28 | } |
29 | |
30 | p-exp { |
31 | assertEqualsVerbose(true, checkProposition($LessThan$(1, 5))); |
32 | assertEqualsVerbose(false, checkProposition($LessThan$(5, 1))); |
33 | assertEqualsVerbose(null, checkProposition($LessThan$("what", "ever"))); |
34 | assertEqualsVerbose(false, checkProposition($BiggerThanOrEqualTo$(1, 5))); |
35 | assertEqualsVerbose(true, checkProposition($BiggerThanOrEqualTo$(5, 1))); |
36 | assertEqualsVerbose(null, checkProposition($BiggerThanOrEqualTo$("what", "ever"))); |
37 | } |
Began life as a copy of #1025427
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025428 |
Snippet name: | Propositions to objects, step 3: infer a variable (dev.) |
Eternal ID of this version: | #1025428/1 |
Text MD5: | 125112ed91b23e05c093ee8f9b2dd223 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-28 23:28:26 |
Source code size: | 1388 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 242 / 439 |
Referenced in: | [show references] |