kill(all)$

maxima :programming, 'defrule' ,version 1.0b
peter.vlasschaert@gmail.com,28/04/2020

example : noncommutative multiplication
================================

matchdeclare([x,y],nonscalarp);

defrule(f1,x.y+y,(x+1).y);

declare([a,b],nonscalar);

p1:a.b+b;

apply1(p1,f1);

first example:
==========

matchdeclare (s1, constantp, s2,constantp,[t1, t2], lambda ([e], not constantp (e)));
defrule (f2a, A (s1*t1, s2*t2), s1.s2 . A (t1, t2));
defrule (f2b,A(t1*s1,t2*s2),s2.s1.A(t1,t2));

non diferent result : noncommutative & commutative.
reason :. trough *, same result.

declare(C1,constant,C2,constant);

w1:A(C1*f(x),C2*g(x));

apply1(w1,f2a);

w2:A(f(x)*C1,g(x)*C2);

apply1(w2,f2b);

because : f2a,f2b =>  s1,s2 same result

define : new operator ,Δ,ΔΔ
======================
same : result , prefix or infix ,a1,b1,c1

method 1:   doesn't work very good
========
use: defrule

prefix("Δ");

defrule(proddeltax,a1*Δ(b1*c1),Δ(a1*b1)+Δ(a1*c1));

apply1(a1*Δ(b1*c1),proddeltax);

apply1(ax1*Δ(bx1*cx1),proddeltax);

method 2:    work very good
========
use :definition

matchdeclare(ax,true,bx,true,cx,true);

"ΔΔ"(a,b,c):=a+b+c;

ΔΔ (x,y,y);

ΔΔ (3,f(y),y);

rem : infix operator,between two atoms
==============================
see :fourth example

infix("→");

"→"  (a,b) := a * b;

c → d;

kill("→");

use : remove are kill

5 → 3;

rem :incorrect syntax → is not infix operator

second example:
=============

matchdeclare([a2,b2,c2],true);

defrule(f3,km(a2,b2,c2),kn(a2,b2)/c2);

apply1(km(yy,2,3),f3);

apply1(km(yy,km(1,2,3),4),f3);

kn(a2,b2):=a2+b2;

apply1(km(1,2,3),f3);

thrid example
==========

single :not atom(x)
===========================
2e) → predx(x):=not atom(x)
1e)→ matchdeclare(e1,predx)
double : not atom(x)  &  op(x)="+"
============================
2e) → predy(x) := not atom(x) and op(x)="+"
1e) → matchdeclare(z,predy)

info : G(x1+x2+x3+...xn) =G(x1)+G(x2)+......G(xn)+x1*x2*..xn

1e)
-----
predicate ,instruction

predy(xx) := not atom(xx) and op(xx)="+";

2e)
-----

matchdeclare(z,predy);

defrule
---------

defrule(f4,G(z),apply("+",map(G,args(z)))+apply("*",args(z)));

apply1 (to protect evaluation),or applyb1
---------
rem : simp:false ? option set to false =>  simp:false

simp;

apply1(G(a4+b4+c4+d4),f4);

applyb1(G(a4+b4+c4+d4),f4);

applyb1(G(1+2+3+4+e4),f4);

fourth example
============

infix("°");

check :command,false or true

is(a°b=b°a);

option : for infix operator

declare("°",commutative);

is(a°b=b°a);

info rules
=======

disprule(all);

propvars(matchdeclare)
===================

propvars(matchdeclare);

printprops(all,matchdeclare)
======================

printprops(all,matchdeclare);

clear  rules
=========
remove :all rules →     clear_rules()  , command to use

 ========================================================================================

simple example :Rules and patterns in Maxima
→  Michel Talon
→  February 19,2019
====================================
ref :http://maxima.sourceforge.net/docs/tutorial/en/talon-pattern.pdf

dot product , noncommutative
----------------------------------------

1e)  matchdeclare
==============

matchdeclare(ay,true,by,true);

2e) defrule
=========

a) define
-------------

defrule(f5,ay.by,ay*by);

b) get info from rule
---------------------------

disprule(f5);

3e) apply1
========

w1:(u+v)*(uu+vv+5);
apply1(w1,f5);

4e) regular : 'maxima commands'
==========================

expand(%);

5e) innerworks
============
below : lisp ( = programming language ( only for info ))

       :lisp(symbol-function           '$f5);

------------------------------------------------------------------------------------------------------

article above :defrule,defmatch,let rules  (let,letsimp,trace,letrat:true,remlet)
tellsimp,tellsimpafter
------------------------------------------------------------------------------------------------------
info :quaternions ,ref (article ;clifford.mac, quantum field theory)

special :example → operator  (infix =   °  &  prefix= Δ,ΔΔ )
=============

reason to forget everything

kill(all)$

infix("°");
matchdeclare(a,true,b,true);
defrule (f1,"Δ"(a,b),a ° b);
defrule (f2,"ΔΔ"(a,b),b ° a);
declare("°",commutative);
is(rhs(Δ(x,y))=rhs(ΔΔ(x,y)));

infix("°");
matchdeclare(a,true,b,true);
defrule (f1,"Δ"(a,b),a ° b);
defrule (f2,"ΔΔ"(a,b),b ° a);
declare("°",commutative);
pa:is(rhs(Δ(x,y))=rhs(ΔΔ(x,y)));

info :special problem
================

disprule(all);

propvars(matchdeclare);

printprops(all,matchdeclare);