In my extensive experience in the field of foundry engineering, I have observed that casting defects persistently undermine product quality and yield rates, posing significant challenges to manufacturing efficiency. These casting defects, ranging from porosity to shrinkage, are often complex in nature and rooted in multifaceted process variables. Traditional methods for diagnosing casting defects heavily rely on human expertise, which is not only scarce but also difficult to codify into explicit mathematical models. This limitation motivated me to design and implement an expert system specifically tailored for analyzing casting defects. The primary goal was to encapsulate the tacit knowledge of seasoned foundry experts into a computational framework that could assist in identifying defect types, pinpointing their causes, and recommending preventive measures. This system, which I refer to as the Casting Defects Analysis Expert System (CDAES), leverages artificial intelligence techniques to emulate expert reasoning, thereby making specialized knowledge accessible to a broader audience, including small-scale foundries that may lack in-house expertise.
The significance of such a system cannot be overstated. Casting defects have been a perennial issue throughout the history of metal casting, leading to substantial economic losses due to scrap and rework. By developing an expert system, I aimed to create a tool that not only aids in defect diagnosis but also serves as an educational resource for foundry personnel. The system is built using PROLOG, a language renowned for its suitability in expert system development due to its symbolic reasoning capabilities. It operates independently of the PROLOG environment, running directly under DOS, which enhances its practicality for industrial settings. In this article, I will detail the architecture, functionality, and implementation of CDAES, emphasizing how it addresses the intricacies of casting defects analysis through a modular design that includes a knowledge base, inference engine, database, human-machine interface, and explanation facility.

The core challenge in analyzing casting defects lies in the non-deterministic nature of the underlying processes. Unlike mechanical or thermal phenomena that can be described by differential equations, casting defects often emerge from a confluence of factors such as alloy composition, pouring temperature, mold design, and cooling rates. These factors interact in ways that are best understood through heuristic knowledge accumulated over years of practice. To capture this, I structured the expert system around a rule-based paradigm, where expert insights are encoded as production rules. The system’s architecture, as illustrated in Figure 1, comprises five interconnected modules: the knowledge base, inference engine, database, human-machine interface, and explanation mechanism. Each module plays a distinct role in facilitating the diagnosis of casting defects, ensuring that the system is both robust and user-friendly.
The knowledge base is the heart of the system, storing all relevant information about casting defects. I organized this knowledge hierarchically, categorizing casting defects into seven major classes based on their morphological characteristics. This tree-like structure allows for efficient reasoning by narrowing down the search space during diagnosis. The classes include: (1) Porosity and Hole Defects, (2) Excess Material Defects, (3) Surface Defects, (4) Incomplete Casting Defects, (5) Shape Deviation Defects, (6) Inclusion Defects, and (7) Crack and Cold Shut Defects. Each class is further subdivided into specific defect types, enabling precise identification. For instance, under Porosity and Hole Defects, we have subcategories like blowholes, shrinkage cavities, and pinholes. This classification is summarized in Table 1, which provides a clear overview of the defect taxonomy used in the system.
| Major Class | Subcategories (Examples) | Key Characteristics |
|---|---|---|
| Porosity and Hole Defects | Blowholes, Shrinkage Cavities, Pinholes, Gas Porosity | Presence of voids or cavities in the casting, often with smooth or rough walls. |
| Excess Material Defects | Flash, Swells, Penetration, Rat Tails | Unwanted metal projections on the casting surface. |
| Surface Defects | Sand Inclusions, Chemical Burn-On, Metal Penetration | Imperfections on the casting surface affecting finish. |
| Incomplete Casting Defects | Misruns, Cold Shuts, Pour Shortages | Castings that are partially formed or missing sections. |
| Shape Deviation Defects | Warpage, Mismatches, Core Shifts | Deviations from the intended geometry of the casting. |
| Inclusion Defects | Slag Inclusions, Oxide Films, Foreign Material | Non-metallic or metallic impurities embedded in the casting. |
| Crack and Cold Shut Defects | Hot Tears, Cold Cracks, Cold Shuts | Fractures or discontinuities in the casting structure. |
To represent knowledge within each defect category, I employed production rules of the form: IF THEN . These rules encapsulate the logical relationships between defect features and their identities. For example, a rule for identifying a shrinkage cavity might be: IF the defect is a hole-type defect AND it occurs at a hot spot or last solidification zone AND the hole is large and concentrated THEN the defect is a shrinkage cavity. In PROLOG syntax, this is expressed as: $$ \text{shrinkage\_cavity :- hole\_defect, location(hot\_spot), size(large\_concentrated).} $$ Here, the predicates represent conditions that must be satisfied for the conclusion to hold. The knowledge base currently contains approximately 80 such rules, covering a wide spectrum of casting defects. This rule-based approach allows for modular knowledge addition, making the system adaptable to new insights or defect types.
The inference engine is responsible for applying these rules to user inputs to deduce defect types. I implemented a backward-chaining reasoning strategy, which starts with a hypothesis (e.g., a specific casting defect) and works backward to verify it by gathering evidence from the user. This method is particularly effective for diagnostic tasks where the goal is to confirm or rule out possibilities based on observable symptoms. The engine interacts with the knowledge base by matching user responses against rule premises. For instance, if a user reports a defect that is a hole in the casting, the engine might prompt: “Is the hole located at a hot spot or last solidification area?” Based on the answer, it traverses the rule tree until a definitive identification is made. The process can be formalized as: $$ \text{Goal: } G \quad \text{Subgoals: } S_1, S_2, \dots, S_n \quad \text{where } G \leftarrow S_1 \land S_2 \land \dots \land S_n $$ This logical deduction ensures that the system’s conclusions are consistent with expert reasoning patterns.
Complementing the knowledge base is a database that stores detailed information on the causes and preventive measures for each casting defect. Once the inference engine identifies a defect, it queries this database to retrieve relevant explanations and recommendations. The database is structured as a set of facts in PROLOG, linking defect names to causal factors and solutions. For example, for shrinkage cavities, the database might list causes such as excessive liquid shrinkage, high pouring temperature, or inadequate feeding systems, along with preventive measures like using chills, optimizing riser design, or controlling alloy composition. This integration allows the system to provide comprehensive advice beyond mere identification, addressing the root causes of casting defects. The database can be represented as: $$ \text{cause(shrinkage\_cavity, [excessive\_shrinkage, high\_pouring\_temp]).} $$ $$ \text{prevention(shrinkage\_cavity, [use\_chills, optimize\_risers]).} $$ This structured storage facilitates quick retrieval and enhances the system’s utility as a troubleshooting tool.
The human-machine interface is designed to be intuitive, requiring no prior knowledge of the system’s internal workings. I adopted a menu-driven approach where users interact with the system through a series of prompts and selections. Upon launching, the main menu offers two options: (1) Diagnose a Defect, and (2) Consult on a Known Defect. If the user chooses diagnosis, the system guides them through a question-answer session, asking about defect characteristics such as location, appearance, and size. Questions are phrased in plain language, e.g., “Is the defect a hole in the casting?” Users respond with ‘Y’ for yes or ‘N’ for no, simplifying the interaction. For known defects, the system displays a list of all defect types, allowing users to select one and immediately access cause-and-prevention information. This interface ensures that foundry workers, regardless of their technical background, can effectively use the system to address casting defects issues.
To enhance transparency and user trust, I incorporated an explanation mechanism that clarifies the system’s reasoning process. Whenever the system poses a question, it provides a brief explanation of why that question is relevant and what it signifies in the context of casting defects analysis. For instance, when asking about defect location, the system might add: “This helps determine if the defect is related to solidification patterns.” This feature demystifies the inference steps, allowing users to follow the logic and learn from the interaction. The explanation module is implemented by associating each rule with a textual description that is displayed during reasoning. In PROLOG, this can be achieved using extra-logical predicates to output messages. For example: $$ \text{explain(hole\_defect) :- write(‘Hole defects indicate porosity or shrinkage issues in casting.’).} $$ This not only aids in user education but also fosters confidence in the system’s recommendations, as users can verify the rationale behind each conclusion.
The implementation of CDAES was carried out entirely in PROLOG, chosen for its native support for symbolic manipulation and rule-based programming. The code was compiled into an executable file, enabling it to run on standard DOS-based computers without requiring a PROLOG interpreter. This portability is crucial for deployment in industrial environments where software compatibility can be a constraint. During development, I focused on optimizing the rule set for accuracy and efficiency, drawing knowledge from foundry manuals and consultations with experienced engineers. A key aspect was validating the system through test cases, such as diagnosing common casting defects like shrinkage cavities or gas porosity. The runtime instance in Figure 2 illustrates a typical session where the system identifies a shrinkage cavity and outputs its causes and preventions. This practical validation confirmed that the system could replicate expert judgments with high reliability.
To further elucidate the system’s functionality, let me describe a concrete example. Suppose a user observes a defect in a cast component: a large, rough-walled cavity located at a thick section. They initiate the diagnosis mode. The system first asks: “Is the defect a hole?” The user responds ‘Y’. Next, it queries: “Is the hole located at a hot spot or last solidification area?” The user answers ‘Y’. Then, it asks: “Is the hole large and concentrated?” Again, ‘Y’. Based on these responses, the inference engine matches the rule for shrinkage cavities and concludes: “The defect is a shrinkage cavity.” It then retrieves from the database the causes: alloy shrinkage, high pouring temperature, poor feeding design, etc., and preventive measures: use of chills, riser optimization, control of composition. This entire process is completed within seconds, demonstrating the system’s efficiency in analyzing casting defects.
The system’s knowledge base is extensible, allowing for the incorporation of new rules as more is learned about casting defects. For instance, emerging defect types related to advanced alloys or novel casting processes can be added by defining new production rules. The modular architecture ensures that such updates do not disrupt existing functionality. Moreover, the system can be integrated with other foundry software, such as simulation tools for solidification analysis, to provide a more holistic approach to defect prevention. However, it is important to note that the system’s effectiveness depends on the quality and comprehensiveness of the encoded knowledge. Regular updates based on field data and expert feedback are essential to maintain its relevance in dynamic manufacturing contexts.
In terms of performance, the system handles typical queries with minimal computational overhead, thanks to the efficient backward-chaining algorithm. The response time is nearly instantaneous for most defects, as the rule set is relatively small yet precise. User feedback from pilot deployments indicated high satisfaction with the interface and explanation features, particularly among novice foundry personnel who benefited from the educational aspect. The system has proven especially useful in diagnosing intermittent casting defects that are difficult to attribute to a single cause, as it systematically explores all possible factors through targeted questioning.
Reflecting on the development process, I encountered several challenges, such as translating vague expert heuristics into crisp logical rules and ensuring the system’s adaptability to diverse casting scenarios. To address these, I employed iterative refinement, testing the system with real defect cases and adjusting rules based on discrepancies. This iterative approach underscores the importance of collaboration between knowledge engineers and domain experts in building effective expert systems for casting defects analysis.
Looking ahead, there are opportunities to enhance CDAES by incorporating machine learning techniques to automatically update the knowledge base from historical defect data. Additionally, a graphical user interface (GUI) could replace the text-based menu for improved usability. However, the current version already meets its core objective: providing a reliable, accessible tool for diagnosing and mitigating casting defects. By democratizing expert knowledge, it contributes to higher quality standards and reduced waste in foundry operations.
In conclusion, the Casting Defects Analysis Expert System represents a practical application of AI in manufacturing. Its design, centered on a rule-based knowledge base and backward-chaining inference, effectively addresses the complexities of casting defects diagnosis. The system’s modularity, user-friendly interface, and explanation capabilities make it a valuable asset for foundries seeking to improve their quality control processes. As casting technologies evolve, such expert systems will play an increasingly vital role in ensuring product integrity and operational efficiency. Through this work, I have demonstrated that computational tools can bridge the gap between empirical expertise and systematic problem-solving, ultimately leading to fewer casting defects and higher productivity in the metal casting industry.
To summarize the technical aspects, the system’s rule-based reasoning can be formalized using first-order logic. Let $D$ represent a defect, $F$ a set of features, and $R$ a set of rules. The diagnosis process is: $$ D \in \text{Defects} \quad \text{if} \quad \exists R_i \in R \text{ such that } F \models \text{premise}(R_i) \text{ and } \text{conclusion}(R_i) = D. $$ Here, $\models$ denotes logical entailment based on user inputs. The backward-chaining algorithm reduces this to a search problem over the rule graph, with complexity $O(n \cdot m)$ where $n$ is the number of rules and $m$ is the number of features. In practice, for 80 rules and ~20 features per defect, this is computationally trivial.
Furthermore, the economic impact of reducing casting defects can be quantified. If $C_s$ is the scrap cost per defective casting, $P_d$ is the defect rate, and $N$ is the production volume, then annual savings $S$ from using the expert system can be estimated as: $$ S = N \cdot P_d \cdot C_s \cdot \eta $$ where $\eta$ is the fractional reduction in defects achieved through system-guided interventions. For a medium-sized foundry producing 10,000 castings annually with a 5% defect rate and $C_s = \$100$, even a 20% reduction ($\eta = 0.2$) yields $S = 10,000 \times 0.05 \times 100 \times 0.2 = \$10,000$ per year. This highlights the tangible benefits of deploying such systems.
In closing, I believe that the continued refinement of expert systems for casting defects analysis will empower foundries to achieve new levels of quality and efficiency. By leveraging AI to encapsulate and disseminate human expertise, we can transform how manufacturing challenges are approached, making defect prevention more proactive and data-driven. The journey from heuristic knowledge to algorithmic reasoning is not without hurdles, but the rewards—in terms of reduced waste, improved product performance, and enhanced competitiveness—are well worth the effort.
