-
Notifications
You must be signed in to change notification settings - Fork 1
Support user-defined predicate call in annotation #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9609889
6961597
0709cec
383ccc7
d79e825
821cab2
2571c37
24d307c
ac1e098
7c10c7b
3bcd10c
fc933e0
73226a9
c42766f
1a5130e
0e6b907
ed72bbd
e896fdc
317955f
0db538c
e518af5
ad85386
8487ab4
acddb41
4ec9873
69d3455
df2a843
391eef4
bb61183
91a957c
dd67486
23f5e52
b4b1c9b
cd004d2
d50710f
2d4e198
4060e06
7270ca4
069b4c1
e4db838
92b702f
d848715
daba7b7
ed03484
a723c37
4c9e5d8
b03b58c
47bf162
8c533e0
53aeadd
c5abc9d
c6d49c8
0d92953
4ee1d9a
933bd10
ec34a5e
70c8705
50b3f23
fade2d5
39954df
04b379c
2ca04c6
3b25de5
5101b46
5f5f102
a48be41
c8c6cf0
8089bfb
e0e13f3
c3a550a
aec6494
53a77c6
70b2f48
7678fac
c5b9b5d
373f7d9
6c58785
4c1bfde
4016ac4
15e8600
38580dd
047954d
5a904bd
a96ddf6
96a6e37
cff43b7
f864b8b
56bb7e1
1600c05
efc4930
c9fb50b
63754db
0da1bd9
4cd0a34
3eb1b3a
f164624
45a5f09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -902,12 +902,87 @@ impl MatcherPred { | |
| } | ||
| } | ||
|
|
||
| // TODO: This struct is almost copy of `DatatypeSymbol`. Two traits maight be unified with aliases. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actually better to have different structs for different purposes; that makes them more resilient to change, since each might be updated for different reasons and in different ways in the future. |
||
| #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
| pub struct UserDefinedPredSymbol { | ||
| inner: String, | ||
| } | ||
|
|
||
| impl std::fmt::Display for UserDefinedPredSymbol { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
| self.inner.fmt(f) | ||
| } | ||
| } | ||
|
|
||
| impl<'a, 'b, D> Pretty<'a, D, termcolor::ColorSpec> for &'b UserDefinedPredSymbol | ||
| where | ||
| D: pretty::DocAllocator<'a, termcolor::ColorSpec>, | ||
| { | ||
| fn pretty(self, allocator: &'a D) -> pretty::DocBuilder<'a, D, termcolor::ColorSpec> { | ||
| allocator.text(self.inner.clone()) | ||
| } | ||
| } | ||
|
|
||
| impl UserDefinedPredSymbol { | ||
| pub fn new(inner: String) -> Self { | ||
| Self { inner } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
| pub struct UserDefinedPred { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This struct seems to be unused. I think it's more natural to rename UserDefinedPredSymbol to UserDefinedPred and remove this one. |
||
| symbol: UserDefinedPredSymbol, | ||
| args: Vec<Sort>, | ||
| } | ||
|
|
||
| impl<'a> std::fmt::Display for UserDefinedPred { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
| write!(f, "{}", self.symbol.inner) | ||
| } | ||
| } | ||
|
|
||
| impl<'a, 'b, D> Pretty<'a, D, termcolor::ColorSpec> for &'b UserDefinedPred | ||
| where | ||
| D: pretty::DocAllocator<'a, termcolor::ColorSpec>, | ||
| D::Doc: Clone, | ||
| { | ||
| fn pretty(self, allocator: &'a D) -> pretty::DocBuilder<'a, D, termcolor::ColorSpec> { | ||
| let args = allocator.intersperse( | ||
| self.args.iter().map(|a| a.pretty(allocator)), | ||
| allocator.text(", "), | ||
| ); | ||
| allocator | ||
| .text("user_defined_pred") | ||
| .append( | ||
| allocator | ||
| .text(self.symbol.inner.clone()) | ||
| .append(args.angles()) | ||
| .angles(), | ||
| ) | ||
| .group() | ||
| } | ||
| } | ||
|
|
||
| impl UserDefinedPred { | ||
| pub fn new(symbol: UserDefinedPredSymbol, args: Vec<Sort>) -> Self { | ||
| Self { | ||
| symbol, | ||
| args, | ||
| } | ||
| } | ||
|
|
||
| pub fn name(&self) -> &str { | ||
| &self.symbol.inner | ||
| } | ||
| } | ||
|
|
||
| /// A predicate. | ||
| #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
| pub enum Pred { | ||
| Known(KnownPred), | ||
| Var(PredVarId), | ||
| Matcher(MatcherPred), | ||
| UserDefined(UserDefinedPredSymbol), | ||
| } | ||
|
|
||
| impl std::fmt::Display for Pred { | ||
|
|
@@ -916,6 +991,7 @@ impl std::fmt::Display for Pred { | |
| Pred::Known(p) => p.fmt(f), | ||
| Pred::Var(p) => p.fmt(f), | ||
| Pred::Matcher(p) => p.fmt(f), | ||
| Pred::UserDefined(p) => p.fmt(f), | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -930,6 +1006,7 @@ where | |
| Pred::Known(p) => p.pretty(allocator), | ||
| Pred::Var(p) => p.pretty(allocator), | ||
| Pred::Matcher(p) => p.pretty(allocator), | ||
| Pred::UserDefined(p) => p.pretty(allocator), | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -958,6 +1035,7 @@ impl Pred { | |
| Pred::Known(p) => p.name().into(), | ||
| Pred::Var(p) => p.to_string().into(), | ||
| Pred::Matcher(p) => p.name().into(), | ||
| Pred::UserDefined(p) => p.inner.clone().into(), | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (nit) using |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -966,6 +1044,7 @@ impl Pred { | |
| Pred::Known(p) => p.is_negative(), | ||
| Pred::Var(_) => false, | ||
| Pred::Matcher(_) => false, | ||
| Pred::UserDefined(_) => false, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -974,6 +1053,7 @@ impl Pred { | |
| Pred::Known(p) => p.is_infix(), | ||
| Pred::Var(_) => false, | ||
| Pred::Matcher(_) => false, | ||
| Pred::UserDefined(_) => false, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -982,6 +1062,7 @@ impl Pred { | |
| Pred::Known(p) => p.is_top(), | ||
| Pred::Var(_) => false, | ||
| Pred::Matcher(_) => false, | ||
| Pred::UserDefined(_) => false, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -990,6 +1071,7 @@ impl Pred { | |
| Pred::Known(p) => p.is_bottom(), | ||
| Pred::Var(_) => false, | ||
| Pred::Matcher(_) => false, | ||
| Pred::UserDefined(_) => false, | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1606,6 +1688,14 @@ impl Clause { | |
| } | ||
| } | ||
|
|
||
| /// A definition specified using #![thrust::define_raw()] | ||
| /// | ||
| /// Those will be directly inserted into the generated SMT-LIB2 file. | ||
| #[derive(Debug, Clone)] | ||
| pub struct RawDefinition { | ||
| pub definition: String, | ||
| } | ||
|
|
||
| /// A selector for a datatype constructor. | ||
| /// | ||
| /// A selector is a function that extracts a field from a datatype value. | ||
|
|
@@ -1655,6 +1745,7 @@ pub struct PredVarDef { | |
| /// A CHC system. | ||
| #[derive(Debug, Clone, Default)] | ||
| pub struct System { | ||
| pub raw_definitions: Vec<RawDefinition>, | ||
| pub datatypes: Vec<Datatype>, | ||
| pub clauses: IndexVec<ClauseId, Clause>, | ||
| pub pred_vars: IndexVec<PredVarId, PredVarDef>, | ||
|
|
@@ -1665,6 +1756,10 @@ impl System { | |
| self.pred_vars.push(PredVarDef { sig, debug_info }) | ||
| } | ||
|
|
||
| pub fn push_raw_definition(&mut self, raw_definition: RawDefinition) { | ||
| self.raw_definitions.push(raw_definition) | ||
| } | ||
|
|
||
| pub fn push_clause(&mut self, clause: Clause) -> Option<ClauseId> { | ||
| if clause.is_nop() { | ||
| return None; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename parse_datatype_ctor_args to parse_arg_terms or something similar, because it's no longer used solely for datatype constructor arguments?