Re: solving for pilog variables

2016-11-27 Thread dean
Joe
Yes that's cracked it! I can see you've given values to @A and @B before
solving for @C but in Prolog I wasn't aware that the order mattered...There
again the calculation is being done in Lisp.
As a result of Alex's response this morning I added more parenthesis and
that seemed to solve what I was doing last night. I'll have to check you're
level of bracketing against mine.

Alex
I'm just trying to get Profit from Sales - Cogs and was struggling to
produce a minus predicate in pilog i.e. harnessing picolisps '-'. Sorry for
not being clear.

The problem is...for each item...Sales, Profit etc...I'll rarely have a
single value to work with ...just a list... so the formulae do more than
just get an end result...they also choose which of the numbers in the
various lists "work" together.

Thank you both for your examples. That's really helped.
Best Regards
Dean


On 27 November 2016 at 17:59, Alexander Burger  wrote:

> Hi Dean
>
> On Sun, Nov 27, 2016 at 05:42:21PM +, dean wrote:
> > (prove (goal '(   (^ @X (- (-> @A) (-> @B) )) (equal @A 4) (equal @B 2)
> )))
> > -> NIL
> >
> > -> wasn't the "one" in this case
>
> I'm not sure I understand the problem, but the most natural way for a
> diff predicate is perhaps
>
>: (be - (@A @B @Diff)
>   (^ @Diff (- (-> @A) (-> @B))) )
>-> -
>
>: (? @X 7  @Y 3  (- @X @Y @Res))
> @X=7 @Y=3 @Res=4
>
>:  (? (- 10 3 @X))
> @X=7
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: solving for pilog variables

2016-11-27 Thread Alexander Burger
Hi Dean

On Sun, Nov 27, 2016 at 05:42:21PM +, dean wrote:
> (prove (goal '(   (^ @X (- (-> @A) (-> @B) )) (equal @A 4) (equal @B 2) )))
> -> NIL
> 
> -> wasn't the "one" in this case

I'm not sure I understand the problem, but the most natural way for a
diff predicate is perhaps

   : (be - (@A @B @Diff)
  (^ @Diff (- (-> @A) (-> @B))) )
   -> -

   : (? @X 7  @Y 3  (- @X @Y @Res))
@X=7 @Y=3 @Res=4

   :  (? (- 10 3 @X))
@X=7

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: solving for pilog variables

2016-11-27 Thread Joe Bogner
dean,

does this help? I don't know pilog well but was just playing around

: (prove (goal '(  (equal @A 5) (equal @B 2) (^ @C (- (-> @A) (-> @B) )  
-> ((@A . 5) (@B . 2) (@C . 3))



On Sun, Nov 27, 2016 at 12:42 PM, dean  wrote:
> (prove (goal '(   (^ @X (- (-> @A) (-> @B) )) (equal @A 4) (equal @B 2) )))
> -> NIL
>
> -> wasn't the "one" in this case
>
> On 27 November 2016 at 17:34, dean  wrote:
>>
>> Oopslet me try this
>>
>> (-> @X) in place of @X in the lisp clause
>>
>>
>> On 27 November 2016 at 16:38, dean  wrote:
>>>
>>> In preparation to do a predicate 'minus' I thought I see how to use lisp
>>> '-' within pilog.
>>> The first statement works re getting a 100% lisp calculation out to pilog
>>> but
>>> I think I need to pass in pilog variables and apply - to them...unless
>>> pilog has a -.
>>> Many apologies if I should know how to do this.
>>>
>>>
>>> : (prove (goal '(   (^ @X (- 4 2))  (equal @A 4)  (equal @B 2)
>>> )))
>>> -> ((@X . 2) (@A . 4) (@B . 2))
>>>: (prove (goal '(   (^ @X (- @A @B))  (equal @A 4)  (equal @B 2)
>>> )))
>>>  -> NIL
>>>
>>>
>>> On 27 November 2016 at 08:46, dean  wrote:

 Ok I'll keep trying and thank you for the pointers.
 Best Regardsd
 Dean

 On 27 November 2016 at 07:33, Alexander Burger 
 wrote:
>
> Hi Dean,
>
> > #(prove (goal '(equal 3 @X)   ))
>
> 'goal' needs a list of clauses:
>
>: (prove (goal '((equal 3 @X
>-> ((@X . 3))
>
>
> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 4))   )))
> > #-> NIL
> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 3))   )))
> > #-> ((@X . 3))
>
> OK
>
>
> > #(prove (goal '(
> > #(equal @Profit (- @Sales @Cogs))
>
> Did you define a '-' predicate?
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


>>>
>>
>
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: solving for pilog variables

2016-11-27 Thread dean
(prove (goal '(   (^ @X (- (-> @A) (-> @B) )) (equal @A 4) (equal @B 2) )))
-> NIL

-> wasn't the "one" in this case

On 27 November 2016 at 17:34, dean  wrote:

> Oopslet me try this
>
> (-> @X) in place of @X in the lisp clause
>
>
> On 27 November 2016 at 16:38, dean  wrote:
>
>> In preparation to do a predicate 'minus' I thought I see how to use lisp
>> '-' within pilog.
>> The first statement works re getting a 100% lisp calculation out to pilog
>> but
>> I think I need to pass in pilog variables and apply - to them...unless
>> pilog has a -.
>> Many apologies if I should know how to do this.
>>
>>
>> : (prove (goal '(   (^ @X (- 4 2))  (equal @A 4)  (equal @B
>> 2) )))
>> -> ((@X . 2) (@A . 4) (@B . 2))
>>: (prove (goal '(   (^ @X (- @A @B))  (equal @A 4)  (equal @B
>> 2) )))
>>  -> NIL
>>
>>
>> On 27 November 2016 at 08:46, dean  wrote:
>>
>>> Ok I'll keep trying and thank you for the pointers.
>>> Best Regardsd
>>> Dean
>>>
>>> On 27 November 2016 at 07:33, Alexander Burger 
>>> wrote:
>>>
 Hi Dean,

 > #(prove (goal '(equal 3 @X)   ))

 'goal' needs a list of clauses:

: (prove (goal '((equal 3 @X
-> ((@X . 3))


 > #: (prove (goal '( (equal 3 @X) (member @X (1 2 4))   )))
 > #-> NIL
 > #: (prove (goal '( (equal 3 @X) (member @X (1 2 3))   )))
 > #-> ((@X . 3))

 OK


 > #(prove (goal '(
 > #(equal @Profit (- @Sales @Cogs))

 Did you define a '-' predicate?

 ♪♫ Alex
 --
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

>>>
>>>
>>
>


Re: solving for pilog variables

2016-11-27 Thread dean
Oopslet me try this

(-> @X) in place of @X in the lisp clause


On 27 November 2016 at 16:38, dean  wrote:

> In preparation to do a predicate 'minus' I thought I see how to use lisp
> '-' within pilog.
> The first statement works re getting a 100% lisp calculation out to pilog
> but
> I think I need to pass in pilog variables and apply - to them...unless
> pilog has a -.
> Many apologies if I should know how to do this.
>
>
> : (prove (goal '(   (^ @X (- 4 2))  (equal @A 4)  (equal @B 2)
> )))
> -> ((@X . 2) (@A . 4) (@B . 2))
>: (prove (goal '(   (^ @X (- @A @B))  (equal @A 4)  (equal @B
> 2) )))
>  -> NIL
>
>
> On 27 November 2016 at 08:46, dean  wrote:
>
>> Ok I'll keep trying and thank you for the pointers.
>> Best Regardsd
>> Dean
>>
>> On 27 November 2016 at 07:33, Alexander Burger 
>> wrote:
>>
>>> Hi Dean,
>>>
>>> > #(prove (goal '(equal 3 @X)   ))
>>>
>>> 'goal' needs a list of clauses:
>>>
>>>: (prove (goal '((equal 3 @X
>>>-> ((@X . 3))
>>>
>>>
>>> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 4))   )))
>>> > #-> NIL
>>> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 3))   )))
>>> > #-> ((@X . 3))
>>>
>>> OK
>>>
>>>
>>> > #(prove (goal '(
>>> > #(equal @Profit (- @Sales @Cogs))
>>>
>>> Did you define a '-' predicate?
>>>
>>> ♪♫ Alex
>>> --
>>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>>
>>
>>
>


Re: solving for pilog variables

2016-11-27 Thread dean
In preparation to do a predicate 'minus' I thought I see how to use lisp
'-' within pilog.
The first statement works re getting a 100% lisp calculation out to pilog
but
I think I need to pass in pilog variables and apply - to them...unless
pilog has a -.
Many apologies if I should know how to do this.


: (prove (goal '(   (^ @X (- 4 2))  (equal @A 4)  (equal @B 2)
)))
-> ((@X . 2) (@A . 4) (@B . 2))
   : (prove (goal '(   (^ @X (- @A @B))  (equal @A 4)  (equal @B
2) )))
 -> NIL


On 27 November 2016 at 08:46, dean  wrote:

> Ok I'll keep trying and thank you for the pointers.
> Best Regardsd
> Dean
>
> On 27 November 2016 at 07:33, Alexander Burger 
> wrote:
>
>> Hi Dean,
>>
>> > #(prove (goal '(equal 3 @X)   ))
>>
>> 'goal' needs a list of clauses:
>>
>>: (prove (goal '((equal 3 @X
>>-> ((@X . 3))
>>
>>
>> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 4))   )))
>> > #-> NIL
>> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 3))   )))
>> > #-> ((@X . 3))
>>
>> OK
>>
>>
>> > #(prove (goal '(
>> > #(equal @Profit (- @Sales @Cogs))
>>
>> Did you define a '-' predicate?
>>
>> ♪♫ Alex
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>
>


Re: solving for pilog variables

2016-11-27 Thread dean
Ok I'll keep trying and thank you for the pointers.
Best Regardsd
Dean

On 27 November 2016 at 07:33, Alexander Burger  wrote:

> Hi Dean,
>
> > #(prove (goal '(equal 3 @X)   ))
>
> 'goal' needs a list of clauses:
>
>: (prove (goal '((equal 3 @X
>-> ((@X . 3))
>
>
> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 4))   )))
> > #-> NIL
> > #: (prove (goal '( (equal 3 @X) (member @X (1 2 3))   )))
> > #-> ((@X . 3))
>
> OK
>
>
> > #(prove (goal '(
> > #(equal @Profit (- @Sales @Cogs))
>
> Did you define a '-' predicate?
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: solving for pilog variables

2016-11-26 Thread Alexander Burger
Hi Dean,

> #(prove (goal '(equal 3 @X)   ))

'goal' needs a list of clauses:

   : (prove (goal '((equal 3 @X
   -> ((@X . 3))


> #: (prove (goal '( (equal 3 @X) (member @X (1 2 4))   )))
> #-> NIL
> #: (prove (goal '( (equal 3 @X) (member @X (1 2 3))   )))
> #-> ((@X . 3))

OK


> #(prove (goal '(
> #(equal @Profit (- @Sales @Cogs))

Did you define a '-' predicate?

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


solving for pilog variables

2016-11-26 Thread dean
I'm quite shaky on this so started with a simple example and added stuff.
Unfortunately, I've come off the rails somewhere but am not sure wjy or
what to do about it.
Any advice...much appreciated.


#(prove (goal '(equal 3 @X)   ))

#: (prove (goal '( (equal 3 @X) (member @X (1 2 4))   )))
#-> NIL
#: (prove (goal '( (equal 3 @X) (member @X (1 2 3))   )))
#-> ((@X . 3))

#(prove (goal '(
#(equal @Profit (- @Sales @Cogs))
#(member @Profit (100 200 300))
#(member @Sales (100 250 300))
#(member @Cogs (100 50 300))
##   )))


(prove (goal '( (equal @Profit (- @Sales @Cogs)) (member @Profit (100 200
300)) (member @Sales (100 250 300)) (member @Cogs (100 50 300)) )))