@@ -173,6 +173,19 @@ function contradiction(input) {
...
@@ -173,6 +173,19 @@ function contradiction(input) {
return[output];
return[output];
}
}
// input list of list of ast, return list of sequents
functionaxiom(input){
constgivens=input[0];// list type, given list of sequent
constconclusion=input[1][0];//list type of sequent
if (ast.containExpNode(givens,conclusion)){
return[];
}else{
thrownewError("Invalid application for axiom rule: The list of formulas in left hand side of turnstile must contain the formula in right hand side of turnstile, to apply the imply introduction rule.");
@@ -218,3 +219,21 @@ test('Contradiction rule should return the correct premises', () => {
...
@@ -218,3 +219,21 @@ test('Contradiction rule should return the correct premises', () => {
expect(output).toEqual([parse("!A |- false")]);
expect(output).toEqual([parse("!A |- false")]);
});
});
//axiom
test('Axiom rule should return the correct premises',()=>{
constinput=parse("B, A |- A");
constoutput=axiom(input);
expect(output).toEqual([parse("")]);
});
test('Axiom should throw an error for invalid application',()=>{
constinput=parse("|- !A & B");
expect(()=>axiom(input)).toThrow("Invalid application for axiom rule: The list of formulas in left hand side of turnstile must contain the formula in right hand side of turnstile, to apply the imply introduction rule.");