1+ //! Wrappers around CHC structures to display them in SMT-LIB2 format.
2+ //!
3+ //! The main entry point is the [`System`] wrapper, which takes a [`chc::System`] and provides a
4+ //! [`std::fmt::Display`] implementation that produces a complete SMT-LIB2.
5+ //! It uses [`FormatContext`] to handle the complexities of the conversion,
6+ //! such as naming convention and solver-specific workarounds.
7+ //! The output of this module is what gets passed to the external CHC solver.
8+
19use crate :: chc:: { self , format_context:: FormatContext } ;
210
11+ /// A helper struct to display a list of items.
312#[ derive( Debug , Clone ) ]
413struct List < T > {
514 open : Option < & ' static str > ,
@@ -79,6 +88,7 @@ impl<T> List<T> {
7988 }
8089}
8190
91+ /// A wrapper around a [`chc::Term`] that provides a [`std::fmt::Display`] implementation in SMT-LIB2 format.
8292#[ derive( Debug , Clone ) ]
8393struct Term < ' ctx , ' a > {
8494 ctx : & ' ctx FormatContext ,
@@ -202,6 +212,7 @@ impl<'ctx, 'a> Term<'ctx, 'a> {
202212 }
203213}
204214
215+ /// A wrapper around a [`chc::Atom`] that provides a [`std::fmt::Display`] implementation in SMT-LIB2 format.
205216#[ derive( Debug , Clone ) ]
206217pub struct Atom < ' ctx , ' a > {
207218 ctx : & ' ctx FormatContext ,
@@ -242,6 +253,7 @@ impl<'ctx, 'a> Atom<'ctx, 'a> {
242253 }
243254}
244255
256+ /// A wrapper around a [`chc::Formula`] that provides a [`std::fmt::Display`] implementation in SMT-LIB2 format.
245257#[ derive( Debug , Clone ) ]
246258pub struct Formula < ' ctx , ' a > {
247259 ctx : & ' ctx FormatContext ,
@@ -278,6 +290,7 @@ impl<'ctx, 'a> Formula<'ctx, 'a> {
278290 }
279291}
280292
293+ /// A wrapper around a [`chc::Body`] that provides a [`std::fmt::Display`] implementation in SMT-LIB2 format.
281294#[ derive( Debug , Clone ) ]
282295pub struct Body < ' ctx , ' a > {
283296 ctx : & ' ctx FormatContext ,
@@ -304,6 +317,7 @@ impl<'ctx, 'a> Body<'ctx, 'a> {
304317 }
305318}
306319
320+ /// A wrapper around a [`chc::Clause`] that provides a [`std::fmt::Display`] implementation in SMT-LIB2 format.
307321#[ derive( Debug , Clone ) ]
308322pub struct Clause < ' ctx , ' a > {
309323 ctx : & ' ctx FormatContext ,
@@ -340,6 +354,7 @@ impl<'ctx, 'a> Clause<'ctx, 'a> {
340354 }
341355}
342356
357+ /// A wrapper around a [`chc::DatatypeSelector`] that provides a [`std::fmt::Display`] implementation in SMT-LIB2 format.
343358#[ derive( Debug , Clone ) ]
344359pub struct DatatypeSelector < ' ctx , ' a > {
345360 ctx : & ' ctx FormatContext ,
@@ -363,6 +378,7 @@ impl<'ctx, 'a> DatatypeSelector<'ctx, 'a> {
363378 }
364379}
365380
381+ /// A wrapper around a [`chc::DatatypeCtor`] that provides a [`std::fmt::Display`] implementation in SMT-LIB2 format.
366382#[ derive( Debug , Clone ) ]
367383pub struct DatatypeCtor < ' ctx , ' a > {
368384 ctx : & ' ctx FormatContext ,
@@ -386,6 +402,7 @@ impl<'ctx, 'a> DatatypeCtor<'ctx, 'a> {
386402 }
387403}
388404
405+ /// A wrapper around a slice of [`chc::Datatype`] that provides a [`std::fmt::Display`] implementation in SMT-LIB2 format.
389406#[ derive( Debug , Clone ) ]
390407pub struct Datatypes < ' ctx , ' a > {
391408 ctx : & ' ctx FormatContext ,
@@ -423,6 +440,8 @@ impl<'ctx, 'a> Datatypes<'ctx, 'a> {
423440 }
424441}
425442
443+ /// A wrapper around a [`chc::Datatype`] that provides a [`std::fmt::Display`] implementation for the
444+ /// discriminant function in SMT-LIB2 format.
426445#[ derive( Debug , Clone ) ]
427446pub struct DatatypeDiscrFun < ' ctx , ' a > {
428447 ctx : & ' ctx FormatContext ,
@@ -458,6 +477,8 @@ impl<'ctx, 'a> DatatypeDiscrFun<'ctx, 'a> {
458477 }
459478}
460479
480+ /// A wrapper around a [`chc::Datatype`] that provides a [`std::fmt::Display`] implementation for the
481+ /// matcher predicate in SMT-LIB2 format.
461482#[ derive( Debug , Clone ) ]
462483pub struct MatcherPredFun < ' ctx , ' a > {
463484 ctx : & ' ctx FormatContext ,
@@ -507,6 +528,7 @@ impl<'ctx, 'a> MatcherPredFun<'ctx, 'a> {
507528 }
508529}
509530
531+ /// A wrapper around a [`chc::System`] that provides a [`std::fmt::Display`] implementation in SMT-LIB2 format.
510532#[ derive( Debug , Clone ) ]
511533pub struct System < ' a > {
512534 ctx : FormatContext ,
0 commit comments