/
Ontology.cl
1820 lines (1599 loc) · 68.6 KB
/
Ontology.cl
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; Modifications by Anders Weinstein 2002-2008
;;; Modifications by Brett van de Sande, 2005-2008
;;; Copyright 2009 by Kurt Vanlehn and Brett van de Sande
;;; This file is part of the Andes Intelligent Tutor Stystem.
;;;
;;; The Andes Intelligent Tutor System is free software: you can redistribute
;;; it and/or modify it under the terms of the GNU Lesser General Public
;;; License as published by the Free Software Foundation, either version 3
;;; of the License, or (at your option) any later version.
;;;
;;; The Andes Solver is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU Lesser General Public License for more details.
;;;
;;; You should have received a copy of the GNU Lesser General Public License
;;; along with the Andes Intelligent Tutor System. If not, see
;;; <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; KB/ontology: defines the expressions used in the Andes Knowledge Base
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; Engineers like to use the term "moment" instead of "torque"
;;;; This is turned on via the 'engineering-names problem feature.
(defun torque-switch (x y)
(if (and *cp* (member 'engineering-names (problem-features *cp*))) x y))
(defun moment-symbol (&optional junk) ;optional arg for use with nlg
(declare (ignore junk))
(torque-switch "M" "τ"))
(defun moment-name (&optional junk) ;optional arg for use with nlg
(declare (ignore junk))
(torque-switch "moment" "torque"))
(defun problem-axes (problem)
"return list of possible problem axes propositions."
(problem-atoms problem))
(defun problem-atoms (problem)
"return list of problem atomic propositions."
;; Start of with problem-specific ontology, then go
;; through list of bodies, etc.
(let ((results
(remove-if #'consp
(mapcar #'car (problem-english problem)))))
(dolist (prop
(second (find 'bodies (problem-choices problem) :key #'car)))
(pushnew prop results))
(dolist (prop (second
(find 'locations (problem-choices problem) :key #'car)))
(pushnew prop results))
(dolist (prop (second
(find 'positions (problem-choices problem) :key #'car)))
(pushnew prop results))
results))
(defun problem-vectors (problem)
"Return a list of vectors defined in a problem."
(if (problem-wm problem)
(mapcar #'third (remove '(vector . ?rest)
(problem-wm problem)
:test-not #'unify))
;; Qualitative problems do not have problem-wm set.
;; This retrieves any vectors from qualitative problems
;; with vector drawing.
(mapcar #'third (remove '(vector ?b ?quantity . ?rest)
(loop for x in (second (problem-graph problem))
append (collect-psmgraph-csdo-effects
(enode-path x)))
:test-not #'unify))))
(defun problem-couples (problem)
"Return a list of couples defined in a problem."
;; As of Oct. 2010, this only applies to problem static1t
(remove '(couple . ?rest)
(problem-givens problem)
:test-not #'unify))
(defun generate-subsets (set)
"List of all subsets of the problem atoms."
(let ((atoms (sort (copy-list set) #'string>))
result)
(dotimes (x (ash 1 (length atoms)))
(let (this)
(dotimes (i (length atoms))
(unless (= (logand x (ash 1 i)) 0)
(push (elt atoms i) this)))
(push this result)))
(remove nil result)))
(defun problem-bodies-and-compounds (problem)
(if t
;; Only use compound bodies that are explicitly declared.
;; This covers all solution quantities, but may be too
;; restrictive if student has trouble with defining
;; compounds.
(append
(mapcar #'second
(remove '(object . ?rest)
(problem-givens problem)
:test-not #'unify))
(problem-atoms problem))
;; generate compound from all problem atoms
(mapcar #'(lambda (x) (if (cdr x)
(append '(compound orderless) x)
(car x)))
(generate-subsets (problem-atoms problem)))))
;;; Quantity Terms:
(def-qexp dnum (dnum ?value ?unit :error ?err)
:new-english ((eval (format nil
"~A~:[~2*~;~A~A~]~@[ ~A~]"
(algebra ?value) ?err #\PLUS-MINUS_SIGN
?err (when ?unit (algebra ?unit))))))
;;;; vector quantities:
;; ex) "the position of the ball relative to the observer"
;; "the ball's relative position to the observer"
;; "the ball's position with respect to the observer"
(def-qexp relative-position (relative-position ?to-pt ?from-pt :time ?time)
:rank vector
:units |m|
:short-name "relative position"
;; see relative-vel
:new-english (or ((property-object (key "position") ?to-pt)
(preferred ((or "relative to" "with respect to" "from")
?from-pt))
(time ?time))
((property-object ("relative" (key "position")) ?to-pt)
(preferred ((or "from" "with respect to") ?from-pt))
(time ?time))))
;; "the car's displacement between T0 and T1"
(def-qexp displacement (displacement ?body :time ?time)
:rank vector
:units |m|
:short-name "displacement"
;; BvdS: is there a common abbreviation?
;; Can't use property-object, because "average" doesn't make sense.
:new-english ((the) (key "displacement")
(and (preferred (property ?body)) (time ?time))))
;; ex) "the average velocity of the car between T0 and T1"
;; "the car's average velocity between T0 and T1" (to do)
(def-qexp velocity (velocity ?body :time ?time)
:rank vector
:units |m/s|
:short-name "velocity"
:new-english (property-object (key (or "velocity" "vel." "vel")) ?body
:time ?time))
;; ex) "the velocity of the ball relative to the observer"
(def-qexp relative-vel (relative-vel ?to-pt ?from-pt :time ?time)
:rank vector
:units |m/s|
:short-name "relative velocity"
;; see relative-position
:new-english ((the)
(time-type ?time)
(or ((key (or "velocity" "vel." "vel")) (property ?to-pt)
(preferred ("relative to" ?from-pt)))
((allowed "relative")
(key (or "velocity" "vel." "vel")) (property ?to-pt)
(preferred ("with respect to" ?from-pt))))
(time ?time)))
(def-qexp accel (accel ?body :time ?time)
:rank vector
:units |m/s^2|
:short-name "acceleration"
:new-english (property-object (key (or "acceleration" "accel." "accel"))
?body :time ?time))
(def-qexp momentum (momentum ?body :time ?time)
:rank vector
:units |kg.m/s|
:short-name "momentum"
:new-english (property-object (key (or "momentum" "mom." "mom"))
?body :time ?time))
;; ex) "the constant normal force that the man acts on the crate"
;; "the constant normal force of the man acting on the crate"
;; "the average force exerted on the pier between T0 and T1" in dt3b
;; "the tension in the wire" in s13 ("wire" is not a defined object in s13)
;; "the frictional force on the aircraft"
;; "the frictional force against the aircraft"
;; "force due to gravity" Raj experiment subject Nov 2010.
;; For tension, need to distinguish scalar and vector
;; forms (see Bug #1719):
;; "tension in the string" (scalar case)
;; "tension force on the brick due to the string" (vector case)
;;
(def-qexp force (force ?body ?agent ?type :time ?time)
:rank vector
:units N
:short-name "force"
:new-english
((the)
(eval (when (time-intervalp ?time)
'(allowed (or "constant" "const." "const" "steady"
"average" "avg."))))
(eval (force-types ?type)
(?type . (mapcar #'car *force-types*)))
(or
;; This should handle "force of the man acting on the crate"
(and (preferred (object ?body))
(preferred (agent ?agent))
(time ?time))
;; case "the force that the man exerts on the crate"
(and ((or "that" "with which") ?agent (or "exerts on" "acts on") ?body)
(time ?time)))))
(defparameter *force-types*
;; Generally, we demand that the student specifies
;; the kind of force, if known. This might be a little problematic
;; for odd forces like "spring" or "thrust".
'((weight . (or ("force" (or "of" "due to") "gravity")
((or "weight" "gravitational" "grav." "grav") "force")))
(gravitational . (or ("force" (or "of" "due to") "gravity")
((or "gravitational" "weight" "grav." "grav") "force")))
;; "normal force exerted on a body by the surface" from Y&F
(normal . ("normal" (key "force")))
(tension . (or ((key "tension") (preferred "force"))
("pulling" (key "force"))
((key "force") "of" "tension")))
;; catch-all force. In this case, the force type is allowed.
(applied . ((allowed (or "applied" "external")) (key "force")))
(kinetic-friction . (or (((preferred "kinetic")
(or "friction" "frictional")) "force")
("force" "of" (preferred "kinetic") "friction")))
(static-friction . (or (((preferred "static")
(or "friction" "frictional")) "force")
("force" "of" (preferred "static") "friction")))
(electric . ((or "electric" "E" "coulomb") (key "force")))
(magnetic . ((or "magnetic" "B") (key "force")))
(buoyant . ((or "buoyant" "buoyancy") (key "force")))
(thrust . ("thrust" (key "force")))
(spring . ("spring" (key "force")))
(pressure . (or ((key "pressure") (allowed "force"))
((key "force") "of pressure")))
(drag . ((or "drag" "friction" "frictional") (key "force")))))
(defun force-types (type)
(or (cdr (assoc type *force-types*))
(warn "unknown force type ~A" type)
(format nil "~(~A~) force" type)))
(def-qexp net-force (net-force ?body :time ?time)
:rank vector
:units N
:short-name "net force"
:new-english ((the) (or "net" "total")
(key "force") (and (preferred (object ?body))
(time ?time))))
(def-qexp rotation-adj (rotation-adj)
:new-english (or "angular" "rotational" "orbital"
"rot." "ang." "orb." "rot" "ang") )
(def-qexp ang-displacement (ang-displacement ?body :time ?time)
:rank vector
:units |rad|
:short-name "angular displacement"
:new-english (property-object
((rotation-adj) (or "displacement" "disp." "disp"))
?body :time ?time))
(def-qexp ang-velocity (ang-velocity ?body :time ?time)
:rank vector
:units |rad/s|
:short-name "angular velocity"
:new-english (property-object
((rotation-adj) (key (or "velocity" "vel." "vel")))
?body :time ?time))
(def-qexp ang-accel (ang-accel ?body :time ?time)
:rank vector
:units |rad/s^2|
:short-name "rotational acceleration"
:new-english (property-object
((rotation-adj) (key (or "acceleration" "accel." "accel")))
?body :time ?time))
(def-qexp ang-momentum (ang-momentum ?body :time ?time)
:rank vector
:units |kg.m^2/s|
:short-name "angular momentum"
:new-english (property-object
((rotation-adj) (key (or "momentum" "mom." "mom")))
?body :time ?time))
(def-qexp torque (torque ?body ?agent :axis ?axis :time ?time)
:rank vector
:units |N.m|
:short-name "torque"
:new-english
((the) (key (eval (moment-name)))
(and (preferred (object ?body))
;; eval is a wrapper simply to specify agent
(eval `(preferred (agent ,?agent))
(?agent . (mapcar #'remove-time
;; torques are due to forces and couples
(append (remove 'force
(problem-vectors *cp*)
:key #'car :test-not #'eql)
(problem-couples *cp*)))))
(preferred (eval (when ?axis (list "about" ?axis))
;; include case where axis is omitted
(?axis . (cons nil (problem-axes *cp*)))))
(time ?time))))
(def-qexp net-torque (net-torque ?body ?axis :time ?time)
:rank vector
:units |N.m|
:short-name "net torque"
:new-english ((the) (or "net" "total") (key (eval (moment-name)))
(and (preferred (object ?body))
(preferred (eval (when ?axis (list "about" ?axis))
(?axis . (problem-axes *cp*))))
(time ?time))))
(def-qexp couple (couple orderless . ?bodies)
:new-english ((the) "couple between"
(conjoin (or "and" "&") . ?bodies)))
;; attributes of vectors:
(def-qexp compo (compo ?xyz ?rot ?vector)
:rank scalar
:units ?vector
:short-name "vector component"
:new-english ((or ((the) ?xyz (or "component" "compo." "compo"))
((the) (eval (format nil "~A-component" ?xyz)))
;; possessive is not allowed. ex) "the driver's
;; x-component of force on the driver"
)
(property ?vector))
)
(def-qexp mag (mag ?vector)
:rank scalar
:units ?vector
:restrictions nonnegative
:short-name "vector magnitude"
:new-english ((allowed "the value of")
;; "length"
(the) (or "magnitude" "mag." "mag" (allowed "strength"))
(property ?vector)))
(def-qexp dir (dir ?vector)
:rank scalar
:units |deg|
:short-name "vector direction"
:new-english ((the) (or "direction" "dir." "dir" (allowed "angle"))
(property ?vector)))
;; this is only used by implicit-eqns, so it should never be visible
;; to the user.
(def-qexp test-var (test-var . ?angle)
:units nil
;; See match-student-phrase0 where it is excluded from possible soughts
:restrictions (nonnegative not-possible-sought))
;; Special axis terms entered into the symbol table. These are not
;; used as quantities, but may need to be Englished.
;; See Bug #1685
(def-qexp axis (axis ?xyz ?angle)
:new-english ((the) (eval (nlg ?xyz 'adj)) "axis"
(eval (list (if (= ?angle 0) 'allowed 'preferred)
(format nil "at ~A degrees" ?angle)))))
;;;; General phrases
(def-qexp var-wrapper (variable . ?rest)
:new-English (case-sensitive (var . ?rest)))
(def-qexp property (property ?body)
;; "for" is exceptionally used
:new-english ("of" (or (variable ?body :namespace :objects)
;; eval as wrapper to set possible values
(eval ?body
(?body . (problem-bodies-and-compounds *cp*)))
)))
(def-qexp time-derivative (time-derivative ?property :agent ?agent :time ?time)
;; should work when agent or time are omitted.
:new-english ((the)
(or "change" "rate of change" "difference" "diff.")
(or "in" "of")
?property
(preferred "per unit time")
(and (preferred (agent ?agent)) (time ?time))))
(def-qexp time-type (time-type ?time)
;; These are redundant with time arguments, which are usually "preferred;"
;; make these "allowed" so that both don't show up in default form.
:new-english (eval (cond
((time-intervalp ?time)
;; to allow "constant", would have to look at problem
'(allowed (or "average" "avg." "avg")))
((time-pointp ?time)
;; to do "initial" or "final", would have to adjust
;; time ontology and look at problem times.
'(allowed (or "instantaneous" "instant." "instant")))
((null ?time) nil)
(t (warn "time-type: Bad time ~A" ?time)))))
;; ex) "the average speed of the car at time T1"
;; "the car's average speed at time T1" (to do!)
;; "the mass of the crate"
;; "the crate's mass" (to do!)
;; "the average velocity of the car between T0 and T1"
;; "the car's average velocity between T0 and T1" (to do)
;; "the car's displacement between T0 and T1" (to do)
;; Exclude "value of", without special help.
(def-qexp property-object (property-object ?property ?body
:modifier ?mod :time ?time)
;; Handles timeless case properly.
:new-english (or ((the) (time-type ?time)
?property ;the quantity
(and (preferred (property ?body)) ?mod (time ?time)))
;; See if "initial" or "final" is applicable.
(eval (let ((tp (collect-extremal-time-points *cp*)))
(when (member ?time tp)
`((the) ,(if (equal ?time (car tp))
"initial" "final")
,?property
(and ,?mod (preferred (property ,?body)))))))))
(defun collect-extremal-time-points (Problem)
"Collect any distinct min or max time points."
(let (min max)
(dolist (item (problem-wm problem))
(when (eql (car item) 'time)
(when (or (null min) (tbeforep (cadr item) min)) ;has timepointp test
(setf min (cadr item)))
(when (or (null max) (tbeforep max (cadr item))) ;has timepointp test
(setf max (cadr item)))))
(when (tbeforep min max) (list min max))))
(def-qexp preferred-the (the)
:new-english (preferred "the"))
(def-qexp object (object ?body)
;; eval wrapper to specify possible values for body.
:new-english (eval `((or "on" "acting on" "exerted on" "that acts on"
"applied on" "applied to" "against")
(or (variable ,?body :namespace :objects) ,?body))
;; include case where body is omitted
(?body . (problem-bodies-and-compounds *cp*))))
(def-qexp agent (agent ?body)
;;+syjung
;; checking the content of ?body by (expand-new-english ..) is
;; important for the case that it is missing (in elec4b, see Bug #1676)
:new-english (eval (when (expand-new-english ?body)
`((or "due to" "by" "from" "caused by" "exerted by" "of")
(or (variable ,?body :namespace :objects) ,?body)))
;; include case with no agent
(?body . (cons nil (problem-atoms *cp*)))))
(def-qexp agent-prep (agent-prep ?preposition ?body)
:new-english (eval (when (expand-new-english ?body)
`(,?preposition
(or (variable ,?body :namespace :objects) ,?body)))
;; include case with no agent
(?body . (cons nil (problem-atoms *cp*)))))
(def-qexp time (time ?time)
:new-english (eval (when ?time
`(preferred (time-not-omittable ,?time)))
;; add timeless as possibility.
(?time . (cons nil (get-problem-times)))))
(defun get-problem-times ()
(mapcar #'second
(remove '(time . ?rest) (problem-givens *cp*) :test-not #'unify)))
(def-qexp time-not-omittable (time-not-omittable ?time)
:new-english (eval (if (time-pointp ?time) (pp ?time)
;; else go back to Ontology
(new-english-find ?time))))
(def-qexp during (during ?ta ?tb)
:new-english (or ((or "between" "during")
(allowed ((the) (allowed "time") "interval") )
(eval (moment ?ta)) (or "and" "&")
(eval (moment ?tb)))
((or "from" "during") (eval (moment ?ta))
(or "to" "until") (eval (moment ?tb)))
;; allow other order for "between ta & tb"
;; Heckler did this when trying a problem.
((or "between" "during")
(allowed ((the) (allowed "time") "interval") )
(eval (moment ?tb)) (or "and" "&")
(eval (moment ?ta)))))
;;;; scalar quantities
;;; Only use time slot if feature changing-mass is included.
(def-qexp mass (mass ?body :time ?time)
:rank scalar
:symbol-base |m|
:short-name "mass"
:units |kg|
:restrictions positive
;; "ball's mass" problem s2e (to do)
:new-english (property-object (key "mass") ?body :time ?time))
;; the magnitude of the change of mass of ~A per unit time due to ~A~@[ ~A~]"
;; (nlg ?body) (nlg ?agent 'agent) (nlg ?time 'pp)
(def-qexp mass-change-magnitude (mass-change-magnitude ?body ?agent :time ?time)
:rank scalar
:symbol-base |dmdt|
:short-name "magnitude of mass change per unit time"
:units |kg/s|
:restrictions nonnegative
:new-english ((allowed ((the) "magnitude of"))
(time-derivative (mass ?body) :agent ?agent :time ?time)))
(def-qexp mass-per-length (mass-per-length ?rope)
:rank scalar
:symbol-base |\\lambda|
:short-name "mass per length"
:units |kg/m|
:restrictions nonnegative
:new-english (property-object (or "mass per length" "mass-per-unit-length"
"mass-per-length") ?rope)
)
;; Sophia: "the distance traveled"
;; "the distance of the aircraft" (not very good english)
;; "the distance"
(def-qexp distance (distance ?body :time ?time)
:rank scalar
:symbol-base |s|
:short-name "distance traveled"
:units |m|
:new-english (or
((the) (key (or "distance" "dist." "dist"))
(preferred (or "traveled" "travelled"
"travels" "moves" "moved"))
(and (preferred ("by" (or (variable ?body :namespace :objects)
?body)))
(time ?time)))
((property-object (key (or "distance" "dist." "dist")) ?body)
(and (allowed (or "traveled" "travelled" "travels"
"moves" "moved"))
(allowed "from the origin")
(time ?time)))))
;; ex) "the duration of time between T0 and T1"
;; "the time duration between T0 and T1"
;; "the duration between T0 and T1"
;; KVL "the duration of the blackbird flight" Bug #1815
(def-qexp duration (duration ?time)
:rank scalar
:symbol-base |t|
:short-name "duration of time"
:units |s|
:restrictions positive
:new-english ((the)
(or ((preferred "duration of") "time")
((preferred "time") "duration")
("duration"))
(time ?time)))
;; ex) "the value of the average speed of the aircraft between T0 and T1"
;; ex) "the value of average speed of the car at time T1"
;; "the car's average speed at time T1"
(def-qexp speed (speed ?body :time ?time)
:rank scalar
:symbol-base |v|
:short-name "speed"
:units |m/s|
:new-english (property-object (key "speed") ?body :time ?time)
)
;;ex) "the coeffienct of kinetic friction between the crate and the plain"
(def-qexp coef-friction
(coef-friction ?body1 ?body2 ?static-or-kinetic :time ?time)
:rank scalar
:symbol-base |\\mu|
:short-name "coef. of friction"
:units NIL ;; dimensionless
:new-english ((the) "coefficient of"
(preferred (eval (if (eql ?static-or-kinetic 'static) "static"
"kinetic")
(?static-or-kinetic . '(static kinetic))))
"friction"
(and (preferred
("between"
(conjoin (or "and" "&")
(or (variable ?body1 :namespace :objects)
?body1)
(or (variable ?body2 :namespace :objects)
?body2))))
(time ?time))))
;; "coefficient of drag for ~A moving through ~A"
;; (nlg ?b) (nlg ?medium 'at-time ?time)
(def-qexp coef-drag-turbulent (coef-drag ?b ?medium :type turbulent :time ?time)
:rank scalar
:symbol-base |K|
:short-name "coef. of drag"
:units |kg/m|
:new-english ("coefficient of drag for" ?b
(and (preferred ("through" ?medium))
(time ?time))))
;; see constants.cl, function enter-predefs
(def-qexp gravitational-acceleration (gravitational-acceleration ?planet)
:rank scalar
:symbol-base |g|
:short-name "gravitational acceleration"
:units |m/s^2|
:restrictions positive
;; Gianocolli: "acceleration due to gravity [on the Earth]"
;; Cummings .. "gravitational acceleration constant"
;; "the earth's local gravitational strength"
;; Hudson & Nelson "acceleration due to gravity at the surface of the earth"
;; "the acceleration of a freely falling object"
;; Walker "the acceleration produced by gravity on the Earth's surface"
;; "... gravitational strength ..."
;; "the acceleration of gravity [on [the surface of] the Earth]"
;; "free-fall acceleration"
;;
;; "the constant gravitational acceleration near the surface of the planet"
;; (kt10a)
:new-english ((allowed "the magnitude of")
(or ((the) (or "gravitational" "grav." "grav")
(key (or "acceleration" "accel." "accel"))
(allowed "constant"))
((the) (key (or "acceleration" "accel." "accel"))
(or ((or "due to" "caused by" "of" "produced by")
"gravity") "of a freely falling object"))
((the) "constant" (or "gravitational" "grav." "grav")
(key (or "acceleration" "accel." "accel")))
(property-object ("local gravitational" (key "strength"))
?planet)
("free-fall" (key "acceleration"))
)
(preferred ((or "at" "on" "near")
(property-object "surface" ?planet))))
)
;; Add Earth to Ontology as a universal name
;; Alternatively, it could be added to all problem ontologies
;; involving the earth.
(def-qexp the-Earth earth
:new-english ((the) "Earth"))
;(def-qexp unspecified unspecified
; :new-english (nil))
(post-process add-gravitational-acceleration (problem)
"if only the earth's gravity is used, add gravitational acceleration"
;; test whether other planets are involved in problem
(when (and (every #'(lambda (x) (eq (second x) 'earth))
(Filter-expressions '(near-planet ?p :body ?b)
(problem-givens problem)))
;; test whether acceleration for earth is needed
(member '(gravitational-acceleration earth)
(problem-varindex problem) :test #'unify :key #'qvar-exp)
;; test whether it has been done as predef already
(not (member '(define-var
(gravitational-acceleration ?place))
(problem-predefs problem) :key #'car :test #'unify)))
;; Add definition plus equation
;; The help system will give these an appropriate color
;; when the problem is loaded.
;; Not a good idea to have the positions hard-coded like this.
;; need to work out a scheme for positioning.
(push '((EQN (= |g_EARTH| (DNUM 9.8 |m/s^2|))) .
((:type . "equation") (:text . "g=9.8 m/s^2")))
(problem-predefs problem))
(push '((define-var (gravitational-acceleration earth)) .
((:type . "statement")
(:text . "g is the acceleration of gravity on earth")
(:symbol . "g")))
(problem-predefs problem))))
(def-qexp num-forces (num-forces ?body :time ?time)
:rank scalar
;:nlg-english ("the number of forces on ~A" (nlg ?body 'at-time ?time)))
:short-name "number of forces"
:new-english ((the) "number of forces"
(and (preferred ("on" ?body))
(time ?time))))
;; ex) "radius of the circular path"
;; "radius of the circular motion of the particle"
(def-qexp revolution-radius (revolution-radius ?body :time ?time)
:rank scalar
:symbol-base |r|
:short-name "radius of circular motion"
:units |m|
:restrictions positive
:new-english ((the) "radius" (preferred "of")
(preferred ((the) (preferred "circular")
(or "motion" "path")))
(preferred (property ?body))
(time ?time)))
;; Halliday and Resnick talk about work done by a force
;; "work done by the spring force"
;; Giancoli
;; "work done by a constant force ..."
;; "the work done by gravity ..."
;; "the work done by each force ..."
(def-qexp work (work ?b ?agent :time ?time)
:rank scalar
:symbol-base |W|
:short-name "work"
:units |J|
:new-english ((the) (allowed "average") (key "work") (preferred "done")
(and (preferred (object ?b))
(preferred (agent ?agent))
(time ?time))))
;; Halliday & Resnick
;; "work done on ... by all forces"
;; "total work done on ... by all forces that act on it"
;; Giancoli
;; "net work done on ..."
(def-qexp net-work (net-work ?body :time ?time)
:rank scalar
:units |J|
:short-name "net work"
:new-english (((the) (or "net" "total net" "total") (key "work")
(preferred "done")
(and (preferred (object ?body))
(allowed (agent "all forces"))
(time ?time)))))
;; Giancoli
;; "work done by non-conservative forces ..."
(def-qexp work-nc (work-nc ?body :time ?time)
:rank scalar
:units |J|
:short-name "work by non-conservative forces"
:new-english (((the) (allowed (or "total" "net")) (key "work")
(preferred "done")
(and (preferred (object ?body))
(preferred (agent "non-conservative forces"))
(time ?time)))))
;; (Young&Freeman's textbook):
;; "the power developed by the engine"
;; "the power generated by the engine"
;; "the power output of the engine applied to pushing the ship"
;; "the power supplied by the net force acting on a particle"
;; (by googling "power supplied by")
;; "the power supplied by the engine"
(def-qexp power (power ?b ?agent :time ?time)
:rank scalar
:symbol-base |P|
:short-name "power"
:units |W|
:new-english ((the) (allowed "instantaneous") "power"
(or ((preferred (or "developed" "generated" "supplied"))
(and (preferred (agent-prep (or "by" "due to" "from" "caused by" "exerted by" "of") ?agent))
;; (agent (or "by" "due to" "from" "caused by" "exerted by" "of") ?agent))
(preferred (object ?b))
(time ?time)))
("output" (preferred (agent-prep (or "of" "by" "due to" "from" "caused by" "exerted by") ?agent))
;;(agent (or "of" "by" "due to" "from" "caused by" "exerted by") ?agent))
(or "applied" "supplied")
(preferred (object ?b))
(time ?time)))))
(def-qexp net-power (net-power ?b :time ?time)
:rank scalar
:units |W|
:short-name "net power"
:new-english ((the) "net power"
(and (preferred ("supplied to" ?b))
(time ?time))))
(def-qexp net-power-out (net-power-out ?source :time ?time)
:rank scalar
:symbol-base |P|
:short-name "power output"
:units |W|
:new-english ((the) "total power produced"
(and (preferred ("by" ?source))
(time ?time))))
;;by syjung:
;; In the tutor hint in elec6b:
;; "the angle between the displacement of e between T0 and T1 and
;; the electric force on e by the unspecified between T0 and T1"
;; The hint can be:
;; (when two are in the same time interval):
;; "the angle between the displacement of e, and the electric force on e
;; between T0 and T1"
;; (when two are not in the same time interval):
;; "the angle between the displacement of e between T1 and T2, and the
;; electric force on e between T0 and T1"
;; It means that the time information can be displayed depending on the contents of ?vecs
;; This hint was generated by (conjoin (or "and" "&") . ?bodies)
;;
;; However, The hint should be shorter when each vector was defined with a variable name:
;; "the angle between d and f"
;;
(def-qexp angle-between (angle-between orderless . ?vecs)
:rank scalar
:units |deg|
:short-name "angle"
:restrictions nonnegative
;; To print the contents of ?vecs:
;; :new-english ( (eval (dolist (vec ?vecs) (format t "~A~%" vec) ?vecs))))
;;
;; ?vecs = '((DISPLACEMENT ELECTRON :TIME (DURING 1 2))
;; (FORCE ELECTRON EARTH WEIGHT :TIME (DURING 1 2)))
;; => '((DISPLACEMENT ELECTRON)
;; (FORCE ELECTRON EARTH WEIGHT :TIME (DURING 1 2)))
;; ?vecs= '((DISPLACEMENT ELECTRON TIME (DURING 1 2))
;; (FORCE ELECTRON UNSPECIFIED ELECTRIC :TIME (DURING 1 2)))
;; => '((DISPLACEMENT ELECTRON)
;; (FORCE ELECTRON UNSPECIFIED ELECTRIC :TIME (DURING 1 2)))
;;
;;ex) ?vecs=(a b c)
;; (mapcar .. ?vecs) = ((or (variable a) a) (or (variable b) b)
;; (or (variable c) c))
;;
;; Generally, we expect the objects to be already defined before
;; angle-between is defined. Thus, the variable names will be available.
:new-english ((the) (key "angle") "between"
(conjoin
(or "and" "&") .
(eval (mapcar
#'(lambda (x) `(or (variable ,x :namespace :objects)
,x))
?vecs)))))
(def-qexp total-energy (total-energy ?system :time ?time)
:rank scalar
:units |J|
:short-name "net mechanical energy"
:new-english (property-object
(or ((preferred (or "total" "net")) "mechanical"
(key "energy"))
(key "TME"))
?system
:time ?time))
(def-qexp kinetic-energy (kinetic-energy ?body :time ?time)
:rank scalar
:units |J|
:short-name "kinetic energy"
:new-english (property-object ((allowed (or "total" "net"))
(allowed (or "translational" "linear"))
(or ("kinetic" (key "energy")) (key "KE")))
?body :time ?time))
(def-qexp rotational-energy (rotational-energy ?body :time ?time)
:rank scalar
:units |J|
:short-name "kinetic energy"
:new-english (property-object ((allowed (or "total" "net"))
(preferred (rotation-adj))
(or ("kinetic" (key "energy")) "KE"))
?body :time ?time))
(def-qexp grav-energy (grav-energy ?body ?agent :time ?time)
:rank scalar
:units |J|
:short-name "potential energy"
:new-english ((the) (allowed "total") (or "gravitational" "grav")
(or ((preferred (or "potential" "pot." "pot")) (key "energy"))
"PE")
(and (preferred (property ?body))
(preferred (agent ?agent))
(time ?time))))
;; see bug 1463
(def-qexp spring-energy (spring-energy ?body ?spring :time ?time)
:rank scalar
:units |J|
:short-name "potential energy"
:new-english ((the) (allowed "elastic") (or ((or "potential" "pot" "spring")
(key "energy")) "PE")
(and (preferred (or (property ?body)
("transmittable to" ?body)))
;; always include spring, since that defines force type.
(agent ?spring)
(time ?time))))
;; "the extension (or compression) of the spring from its equilibrium position"
;; "the elongation of the spring" in Young&Freeman's textbook in page 221
(def-qexp compression (compression ?spring :time ?time)
:rank scalar
:symbol-base |d|
:short-name "compression distance"
:units |m|
:new-english ((the) (key (or "compression" "extension" "elongation"
"stretch") )
(allowed (or "distance" "displacement"))
(and (property ?spring)
(preferred ("from"
(or "its" "the" "her")
(or "equilibrium" "unstretched")
(preferred (or "position" "point" "length"))))
(time ?time))))
;; "sprint constant" or "force constant" in Young&Freeman's text book in page 221
(def-qexp spring-constant (spring-constant ?spring)
:rank scalar
:symbol-base |k|
:short-name "spring constant"
:units |N/m|
:restrictions positive
:new-english (property-object ((or "spring" "force") (key "constant"))
?spring))
(def-qexp height (height ?body ?zero-height :time ?time)
:rank scalar
:symbol-base |h|
:short-name "height"
:units |m|
:new-english
(property-object (key "height") ?body
;; Case with the zero height included.
;; Generally, we only have one zero height defined
;; in a problem, so we can default to not using it.
:modifier (allowed
((or "above" "relative to")
;; eval wrapper to include zero-height as possible
;; value
(or (eval ?zero-height
(?zero-height . (cons 'zero-height
(problem-atoms *cp*))))
((the) (allowed "level of")
"origin"))))
:time ?time))
;; default phrase, in absence of something sensible.
(def-qexp zero-height zero-height
:new-english (or ((the) (or "zero level" "axis" "horizontal axis" "origin"))
"zero"))
;; "the moment of inertia of ~A about ~A" (nlg ?body) (nlg ?axis 'at-time ?time)
(def-qexp moment-of-inertia (moment-of-inertia ?body :axis ?axis :time ?time)
:rank scalar ;; This is a particular component of the tensor
:symbol-base |I|
:short-name "moment of inertia"
:units |kg.m^2|
:restrictions positive
:new-english (property-object
"moment of inertia"
?body
:modifier (eval (when ?axis `(preferred ("about" ,?axis)))
(?axis . (problem-axes *cp*)))
:time ?time))
;; for dimensions of certain rigid bodies:
;; from Bob: "the length of the beam"
(def-qexp length (length ?body)
:rank scalar
:symbol-base ||
:short-name "length"
:units |m|
:new-english (property-object (key (or "length" "len" "len.")) ?body))
(def-qexp length-change (rate-of-change (length ?body))
:rank scalar
:symbol-base ||
:short-name "rate of change in length"
:units |m/s|
:new-english (time-derivative (property-object
(key (or "length" "len" "len."))
?body)))
(def-qexp width (width ?body)
:rank scalar
:symbol-base ||
:short-name "width"
:units |m|
:new-english ((property-object "width" ?body)))
(def-qexp num-torques (num-torques ?body ?axis :time ?time)
:rank scalar
:short-name "number of torques"
:new-english ((the) "number of" (eval (moment-name)) "on" ?body
(preferred (eval (when ?axis (list "about" ?axis))
(?axis . (problem-axes *cp*))))
(time ?time)))