Skip to content

Commit

Permalink
document RuleApplication
Browse files Browse the repository at this point in the history
  • Loading branch information
bddap committed Apr 9, 2021
1 parent 55978e7 commit 26debb6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ where
}

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
/// A proof element that has yet to be translated to a presentable form.
///
/// [crate::prove::prove] function does not immediately convert LowRuleApplication's to
/// [RuleApplication]'s. Rather, it converts only the LowRuleApplication's it is going to return
/// to the caller.
pub struct LowRuleApplication {
pub rule_index: usize,
pub instantiations: BTreeMap<usize, usize>,
}

impl LowRuleApplication {
/// Translate to a higher representation [RuleApplication]. The higher representation is
/// portable to other machines as long as those machines assume the same rule list.
/// This lower representation is not portable.
///
/// Panics
///
/// This function will panic if:
Expand Down
31 changes: 31 additions & 0 deletions src/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,37 @@ impl std::error::Error for CantProve {}

#[derive(Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
/// An element of a deductive proof. Proofs can be transmitted and later validatated as long as the
/// validator assumes the same rule list as the prover.
///
/// Unbound variables are bound to the values in `instanitations`. They are bound in order of
/// initial appearance.
///
/// Given the rule:
///
/// ```customlang
/// ifall
/// [?z ex:foo ?x DG]
/// then
/// [?x ex:bar ?z DG]
/// ```
///
/// and the RuleApplication:
///
/// ```customlang
/// RuleApplication {
/// rule_index: 0,
/// instantiations: vec!["foer", "bary"],
/// }
/// ```
///
/// The rule application represents the deductive proof:
///
/// ```customlang
/// [foer ex:foo bary DG]
/// therefore
/// [bary ex:bar foer DG]
/// ```
pub struct RuleApplication<Bound> {
/// The index of the rule in the implicitly associated rule list.
pub rule_index: usize,
Expand Down

0 comments on commit 26debb6

Please sign in to comment.