#### Prolog problem

How should I go about modifying this code to be able to perform arithmetic operations on the numerical values?

Code:
```% File:  e.p
%      - convert a text number to a numeral
%      - Using grammars
%      - Extracting "value" from sentence (semantics)
%      - removes restriction that all numbers of form dddd
%      - handles "teens"

:- consult('aux.p').

cvt :-
read_sentence(Sentence),
butlast(Sentence,Sentenc),
Sentenc \== [quit],
write_sentence(Sentenc), !,
(
phrase(four_digit(Value),Sentenc,[]),
write_string(" -- translation succeeded"),
nl,
write_string("yielding value "),
write(Value),
write_string(" decimal.");
write_string(" -- translation failed")
),
nl,
cvt.

cvt.

four_digit(Value) -->
thousands(V1), three_digit(V2), {Value is 1000 * V1 + V2}.

three_digit(Value) -->
hundreds(V1), two_digit(V2), {Value is 100 * V1 + V2}.

two_digit(Value) --> tens(V1), one_digit(V2), {Value is 10 * V1 + V2}.
two_digit(Value) --> teens(V), {Value is V}.

one_digit(Value) --> ones(V), {Value is V}.

thousands(Value) --> digit(V), thousand, {Value is V}.
thousands(0) --> [].

hundreds(Value) --> digit(V), hundred, {Value is V}.
hundreds(0) --> [].

tens(Value) --> digity_thing(V), {Value is V}.
tens(0) --> [].

teens(Value) --> teen_thing(V), {Value is V}.

ones(Value) --> digit(V), {Value is V}.
ones(0) --> [].

thousand --> [thousand].
hundred --> [hundred].

digity_thing(2) --> [twenty].
digity_thing(3) --> [thirty].
digity_thing(4) --> [forty].
digity_thing(5) --> [fifty].
digity_thing(6) --> [sixty].
digity_thing(7) --> [seventy].
digity_thing(8) --> [eighty].
digity_thing(9) --> [ninety].

teen_thing(10) --> [ten].
teen_thing(11) --> [eleven].
teen_thing(12) --> [twelve].
teen_thing(13) --> [thirteen].
teen_thing(14) --> [fourteen].
teen_thing(15) --> [fifteen].
teen_thing(16) --> [sixteen].
teen_thing(17) --> [seventeen].
teen_thing(18) --> [eighteen].
teen_thing(19) --> [nineteen].

digit(1) --> [one].
digit(2) --> [two].
digit(3) --> [three].
digit(4) --> [four].
digit(5) --> [five].
digit(6) --> [six].
digit(7) --> [seven].
digit(8) --> [eight].
digit(9) --> [nine].```