Contract-Based Design #
Assume-guarantee contracts for subsystem composition. This module addresses the most common cause of emergent failure: implicit assumptions that are not discharged by any other subsystem's guarantees.
A Contract carries a formal proof that its assumption implies its guarantee.
A list of contracts is CompositionSound when every contract's assumption is
entailed by the conjunction of other contracts' guarantees (plus a base
environmental assumption). This check is a type-level obligation, so missing
assumptions surface at build time rather than at integration.
Design Notes #
Contract.validis the local proofassume → guarantee.CouplingConstraintcaptures properties that genuinely cross subsystem boundaries and cannot be expressed as a local per-subsystem invariant.- The composition check uses logical implication rather than syntactic
equality on propositions, which sidesteps the lack of
DecidableEq Prop.
Contract: subsystem-level assume-guarantee pair with a validity proof.
- name : String
Contract identifier (used for traceability and diagnostics).
- assume : Prop
What the subsystem requires from its environment.
- guarantee : Prop
What the subsystem guarantees in return.
Local validity: if the assumption holds, so does the guarantee.
Instances For
The guarantee of a discharged contract is provable.
CouplingConstraint: a cross-cutting property that involves multiple subsystems and is not reducible to any single subsystem's invariant. Examples include total power budget, mass budget, thermal coupling, electromagnetic compatibility, and communication-link budgets.
- name : String
Constraint identifier.
Names of subsystems participating in this constraint.
- property : Prop
The cross-cutting property.
- evidence : self.property
Proof that the property holds.
Instances For
Number of subsystems a constraint couples.
Instances For
ContractedSystem: a set of contracts together with coupling constraints and a proof that every contract's assumption has been discharged.
All subsystem contracts.
- couplings : List CouplingConstraint
Cross-cutting coupling constraints.
Every contract assumption is discharged. Constructing this system requires producing a proof for each assumption — this is where the integration story becomes machine-checked.
Instances For
Every contract's guarantee holds in a well-formed contracted system.
Number of contracts in a contracted system.
Equations
- cs.contractCount = cs.contracts.length
Instances For
Number of coupling constraints in a contracted system.
Equations
- cs.couplingCount = cs.couplings.length