Merge remote branch 'master'
[prop.git] / prop-src / pat.ph
blob441d6452ba3f66437f2930203df12523ca2711a2
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 //  This file describes the analysis routines for patterns and match
4 //  decision trees.  These are used for mode analysis and determinism
5 //  analysis for logic clauses compilation.
6 //
7 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef patterns_h
9 #define patterns_h
11 #include "ir.ph"
12 #include "ast.ph"
13 #include "matchcom.ph"
15 ///////////////////////////////////////////////////////////////////////////////
17 //  Tests whether a pattern is subsumed by another.  Call the
18 //  error handler if false.
20 ///////////////////////////////////////////////////////////////////////////////
21 extern Bool subsumes (Pat,     Pat,     Bool verbose);
22 extern Bool subsumes (Pats,    Pats,    Bool verbose);
23 extern Bool subsumes (LabPats, LabPats, Bool verbose);
25 ///////////////////////////////////////////////////////////////////////////////
27 //  Convert a simple pattern into an unification pattern, i.e. one in
28 //  which pattern matching of the variable is explicitly modeled.
30 ///////////////////////////////////////////////////////////////////////////////
31 extern Pat     unifier_of (Pat);
32 extern Pats    unifier_of (Pats);
33 extern LabPats unifier_of (LabPats);
35 ///////////////////////////////////////////////////////////////////////////////
37 //  Thin a matching tree by discarding unreachable branches.
39 ///////////////////////////////////////////////////////////////////////////////
40 extern Match   thin (Match,    Pat);
41 extern Match * thin (int, Match [], Pats);
43 ///////////////////////////////////////////////////////////////////////////////
45 //  Routine to invert a pattern into a constructor expression.
46 //  If 'write mode' is on then convert pattern identifiers and wild cards
47 //  into logical variable constructors.
49 ///////////////////////////////////////////////////////////////////////////////
50 extern Exp pat2exp         (Pat);
51 extern Exp pat2constructor (Pat);
52 extern Exp pat2unifier     (Pat);
53 extern Bool write_mode;    // write mode during unification
55 #endif