/usr/share/axiom-20170501/src/algebra/PMPLCAT.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | )abbrev package PMPLCAT PatternMatchPolynomialCategory
++ Author: Manuel Bronstein
++ Date Created: 9 Jan 1990
++ Date Last Updated: 20 June 1991
++ Description:
++ This package provides pattern matching functions on polynomials.
PatternMatchPolynomialCategory(S,E,V,R,P) : SIG == CODE where
S : SetCategory
E : OrderedAbelianMonoidSup
V : OrderedSet
R : Join(Ring, OrderedSet, PatternMatchable S)
P : Join(PolynomialCategory(R, E, V), ConvertibleTo Pattern S)
N ==> NonNegativeInteger
PAT ==> Pattern S
PRS ==> PatternMatchResult(S, P)
RCP ==> Record(val:PAT, exponent:N)
RCX ==> Record(var:V, exponent:N)
SIG ==> with
patternMatch : (P, PAT, PRS, (V, PAT, PRS) -> PRS) -> PRS
++ patternMatch(p, pat, res, vmatch) matches the pattern pat to
++ the polynomial p. res contains the variables of pat which
++ are already matched and their matches; vmatch is the matching
++ function to use on the variables.
-- This can be more efficient than pushing down when the variables
-- are recursive over P (for example, kernels)
if V has PatternMatchable S then
patternMatch : (P, PAT, PRS) -> PRS
++ patternMatch(p, pat, res) matches the pattern pat to
++ the polynomial p; res contains the variables of pat which
++ are already matched and their matches.
CODE ==> add
import PatternMatchTools(S, R, P)
import PatternMatchPushDown(S, R, P)
if V has PatternMatchable S then
patternMatch(x, p, l) ==
patternMatch(x, p, l, patternMatch$PatternMatchPushDown(S,V,P))
patternMatch(x, p, l, vmatch) ==
generic? p => addMatch(p, x, l)
(r := retractIfCan(x)@Union(R, "failed")) case R =>
patternMatch(r::R, p, l)
(v := retractIfCan(x)@Union(V, "failed")) case V =>
vmatch(v::V, p, l)
(u := isPlus p) case List(PAT) =>
(lx := isPlus x) case List(P) =>
patternMatch(lx::List(P), u::List(PAT),
(l1:List(P)):P +-> +/l1, l,
(p1:P,p2:PAT,p3:PRS):PRS +-> patternMatch(p1, p2, p3, vmatch))
(u := optpair(u::List(PAT))) case List(PAT) =>
failed?(l := addMatch(first(u::List(PAT)), 0, l)) => failed()
patternMatch(x, second(u::List(PAT)), l, vmatch)
failed()
(u := isTimes p) case List(PAT) =>
(lx := isTimes x) case List(P) =>
patternMatchTimes(lx::List(P), u::List(PAT), l,
(p1:P,p2:PAT,p3:PRS):PRS +-> patternMatch(p1, p2, p3, vmatch))
(u := optpair(u::List(PAT))) case List(PAT) =>
failed?(l := addMatch(first(u::List(PAT)), 1, l)) => failed()
patternMatch(x, second(u::List(PAT)), l, vmatch)
failed()
(uu := isPower p) case Record(val:PAT, exponent:PAT) =>
uur := uu::Record(val:PAT, exponent: PAT)
(ex := isExpt x) case RCX =>
failed?(l := patternMatch((ex::RCX).exponent::Integer::P,
uur.exponent, l, vmatch)) => failed()
vmatch((ex::RCX).var, uur.val, l)
optional?(uur.exponent) =>
failed?(l := addMatch(uur.exponent, 1, l)) => failed()
patternMatch(x, uur.val, l, vmatch)
failed()
((ep := isExpt p) case RCP) and ((ex := isExpt x) case RCX) and
(ex::RCX).exponent = (ep::RCP).exponent =>
vmatch((ex::RCX).var, (ep::RCP).val, l)
failed()
|